* [PATCH v2] perf record: add dummy event during system wide synthesis
@ 2020-04-21 6:11 Ian Rogers
2020-04-22 8:46 ` Jiri Olsa
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2020-04-21 6:11 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Kan Liang, linux-kernel, linux-perf-users
Cc: Stephane Eranian, Ian Rogers
During the processing of /proc during event synthesis new processes may
start. Add a dummy event if /proc is to be processed, to capture mmaps
for starting processes. This reuses the existing logic for
initial-delay.
v2 fixes the dummy event configuration and a branch stack issue.
Suggested-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/builtin-record.c | 19 ++++++++++++++-----
tools/perf/util/evsel.c | 5 ++++-
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 1ab349abe904..8d1e93351298 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -805,19 +805,28 @@ static int record__open(struct record *rec)
int rc = 0;
/*
- * For initial_delay we need to add a dummy event so that we can track
- * PERF_RECORD_MMAP while we wait for the initial delay to enable the
- * real events, the ones asked by the user.
+ * For initial_delay or system wide, we need to add a dummy event so
+ * that we can track PERF_RECORD_MMAP to cover the delay of waiting or
+ * event synthesis.
*/
- if (opts->initial_delay) {
+ if (opts->initial_delay || target__has_cpu(&opts->target)) {
if (perf_evlist__add_dummy(evlist))
return -ENOMEM;
+ /* Disable tracking of mmaps on lead event. */
pos = evlist__first(evlist);
pos->tracking = 0;
+ /* Set up dummy event. */
pos = evlist__last(evlist);
pos->tracking = 1;
- pos->core.attr.enable_on_exec = 1;
+ /*
+ * Enable the dummy event when the process is forked for
+ * initial_delay, immediately for system wide.
+ */
+ if (opts->initial_delay)
+ pos->core.attr.enable_on_exec = 1;
+ else
+ pos->immediate = 1;
}
perf_evlist__config(evlist, opts, &callchain_param);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 6a571d322bb2..ca8f9533d8f9 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1163,11 +1163,14 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
}
/*
+ * A dummy event never triggers any actual counter and therefore
+ * cannot be used with branch_stack.
+ *
* For initial_delay, a dummy event is added implicitly.
* The software event will trigger -EOPNOTSUPP error out,
* if BRANCH_STACK bit is set.
*/
- if (opts->initial_delay && is_dummy_event(evsel))
+ if (is_dummy_event(evsel))
perf_evsel__reset_sample_bit(evsel, BRANCH_STACK);
}
--
2.26.1.301.g55bc3eb7cb9-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] perf record: add dummy event during system wide synthesis
2020-04-21 6:11 [PATCH v2] perf record: add dummy event during system wide synthesis Ian Rogers
@ 2020-04-22 8:46 ` Jiri Olsa
2020-04-22 17:37 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2020-04-22 8:46 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Namhyung Kim, Kan Liang,
linux-kernel, linux-perf-users, Stephane Eranian
On Mon, Apr 20, 2020 at 11:11:03PM -0700, Ian Rogers wrote:
> During the processing of /proc during event synthesis new processes may
> start. Add a dummy event if /proc is to be processed, to capture mmaps
> for starting processes. This reuses the existing logic for
> initial-delay.
>
> v2 fixes the dummy event configuration and a branch stack issue.
heya,
it's breaking attr tests for me:
[jolsa@krava perf]$ sudo ./perf test -v 17
17: Setup struct perf_event_attr :
--- start ---
test child forked, pid 1046560
running './tests/attr/test-record-graph-default'
running './tests/attr/test-record-raw'
running './tests/attr/test-record-branch-filter-any'
running './tests/attr/test-record-freq'
running './tests/attr/test-record-branch-any'
running './tests/attr/test-stat-group1'
running './tests/attr/test-record-no-samples'
running './tests/attr/test-record-graph-dwarf'
running './tests/attr/test-stat-C0'
running './tests/attr/test-stat-basic'
running './tests/attr/test-record-group'
running './tests/attr/test-record-branch-filter-k'
running './tests/attr/test-stat-group'
running './tests/attr/test-record-C0'
expected config=0, got 9
expected sample_type=391, got 455
expected disabled=1, got 0
FAILED './tests/attr/test-record-C0' - match failure
test child finished with -1
---- end ----
Setup struct perf_event_attr: FAILED!
jirka
>
> Suggested-by: Stephane Eranian <eranian@google.com>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/builtin-record.c | 19 ++++++++++++++-----
> tools/perf/util/evsel.c | 5 ++++-
> 2 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 1ab349abe904..8d1e93351298 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -805,19 +805,28 @@ static int record__open(struct record *rec)
> int rc = 0;
>
> /*
> - * For initial_delay we need to add a dummy event so that we can track
> - * PERF_RECORD_MMAP while we wait for the initial delay to enable the
> - * real events, the ones asked by the user.
> + * For initial_delay or system wide, we need to add a dummy event so
> + * that we can track PERF_RECORD_MMAP to cover the delay of waiting or
> + * event synthesis.
> */
> - if (opts->initial_delay) {
> + if (opts->initial_delay || target__has_cpu(&opts->target)) {
> if (perf_evlist__add_dummy(evlist))
> return -ENOMEM;
>
> + /* Disable tracking of mmaps on lead event. */
> pos = evlist__first(evlist);
> pos->tracking = 0;
> + /* Set up dummy event. */
> pos = evlist__last(evlist);
> pos->tracking = 1;
> - pos->core.attr.enable_on_exec = 1;
> + /*
> + * Enable the dummy event when the process is forked for
> + * initial_delay, immediately for system wide.
> + */
> + if (opts->initial_delay)
> + pos->core.attr.enable_on_exec = 1;
> + else
> + pos->immediate = 1;
> }
>
> perf_evlist__config(evlist, opts, &callchain_param);
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 6a571d322bb2..ca8f9533d8f9 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1163,11 +1163,14 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
> }
>
> /*
> + * A dummy event never triggers any actual counter and therefore
> + * cannot be used with branch_stack.
> + *
> * For initial_delay, a dummy event is added implicitly.
> * The software event will trigger -EOPNOTSUPP error out,
> * if BRANCH_STACK bit is set.
> */
> - if (opts->initial_delay && is_dummy_event(evsel))
> + if (is_dummy_event(evsel))
> perf_evsel__reset_sample_bit(evsel, BRANCH_STACK);
> }
>
> --
> 2.26.1.301.g55bc3eb7cb9-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] perf record: add dummy event during system wide synthesis
2020-04-22 8:46 ` Jiri Olsa
@ 2020-04-22 17:37 ` Ian Rogers
0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2020-04-22 17:37 UTC (permalink / raw)
To: Jiri Olsa
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Namhyung Kim, Kan Liang, LKML,
linux-perf-users, Stephane Eranian
On Wed, Apr 22, 2020 at 1:46 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Mon, Apr 20, 2020 at 11:11:03PM -0700, Ian Rogers wrote:
> > During the processing of /proc during event synthesis new processes may
> > start. Add a dummy event if /proc is to be processed, to capture mmaps
> > for starting processes. This reuses the existing logic for
> > initial-delay.
> >
> > v2 fixes the dummy event configuration and a branch stack issue.
>
> heya,
> it's breaking attr tests for me:
>
> [jolsa@krava perf]$ sudo ./perf test -v 17
> 17: Setup struct perf_event_attr :
> --- start ---
> test child forked, pid 1046560
> running './tests/attr/test-record-graph-default'
> running './tests/attr/test-record-raw'
> running './tests/attr/test-record-branch-filter-any'
> running './tests/attr/test-record-freq'
> running './tests/attr/test-record-branch-any'
> running './tests/attr/test-stat-group1'
> running './tests/attr/test-record-no-samples'
> running './tests/attr/test-record-graph-dwarf'
> running './tests/attr/test-stat-C0'
> running './tests/attr/test-stat-basic'
> running './tests/attr/test-record-group'
> running './tests/attr/test-record-branch-filter-k'
> running './tests/attr/test-stat-group'
> running './tests/attr/test-record-C0'
> expected config=0, got 9
> expected sample_type=391, got 455
> expected disabled=1, got 0
> FAILED './tests/attr/test-record-C0' - match failure
> test child finished with -1
> ---- end ----
> Setup struct perf_event_attr: FAILED!
>
> jirka
Thanks, fixed in v3:
https://lore.kernel.org/lkml/20200422173615.59436-1-irogers@google.com/
Ian
> >
> > Suggested-by: Stephane Eranian <eranian@google.com>
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> > tools/perf/builtin-record.c | 19 ++++++++++++++-----
> > tools/perf/util/evsel.c | 5 ++++-
> > 2 files changed, 18 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> > index 1ab349abe904..8d1e93351298 100644
> > --- a/tools/perf/builtin-record.c
> > +++ b/tools/perf/builtin-record.c
> > @@ -805,19 +805,28 @@ static int record__open(struct record *rec)
> > int rc = 0;
> >
> > /*
> > - * For initial_delay we need to add a dummy event so that we can track
> > - * PERF_RECORD_MMAP while we wait for the initial delay to enable the
> > - * real events, the ones asked by the user.
> > + * For initial_delay or system wide, we need to add a dummy event so
> > + * that we can track PERF_RECORD_MMAP to cover the delay of waiting or
> > + * event synthesis.
> > */
> > - if (opts->initial_delay) {
> > + if (opts->initial_delay || target__has_cpu(&opts->target)) {
> > if (perf_evlist__add_dummy(evlist))
> > return -ENOMEM;
> >
> > + /* Disable tracking of mmaps on lead event. */
> > pos = evlist__first(evlist);
> > pos->tracking = 0;
> > + /* Set up dummy event. */
> > pos = evlist__last(evlist);
> > pos->tracking = 1;
> > - pos->core.attr.enable_on_exec = 1;
> > + /*
> > + * Enable the dummy event when the process is forked for
> > + * initial_delay, immediately for system wide.
> > + */
> > + if (opts->initial_delay)
> > + pos->core.attr.enable_on_exec = 1;
> > + else
> > + pos->immediate = 1;
> > }
> >
> > perf_evlist__config(evlist, opts, &callchain_param);
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index 6a571d322bb2..ca8f9533d8f9 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -1163,11 +1163,14 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
> > }
> >
> > /*
> > + * A dummy event never triggers any actual counter and therefore
> > + * cannot be used with branch_stack.
> > + *
> > * For initial_delay, a dummy event is added implicitly.
> > * The software event will trigger -EOPNOTSUPP error out,
> > * if BRANCH_STACK bit is set.
> > */
> > - if (opts->initial_delay && is_dummy_event(evsel))
> > + if (is_dummy_event(evsel))
> > perf_evsel__reset_sample_bit(evsel, BRANCH_STACK);
> > }
> >
> > --
> > 2.26.1.301.g55bc3eb7cb9-goog
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-22 17:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 6:11 [PATCH v2] perf record: add dummy event during system wide synthesis Ian Rogers
2020-04-22 8:46 ` Jiri Olsa
2020-04-22 17:37 ` Ian Rogers
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.