* [PATCH] perf record: Fix synthesis failure warnings
@ 2022-09-07 16:24 Adrian Hunter
2022-09-07 17:58 ` Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2022-09-07 16:24 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel
Some calls to synthesis functions set err < 0 but only warn about the
failure and continue. However they do not set err back to zero, relying
on subsequent code to do that.
That changed with the introduction of option --synth. When --synth=no
subsequent functions that set err back to zero are not called.
Fix by setting err = 0 in those cases.
Example:
Before:
$ perf record --no-bpf-event --synth=all -o /tmp/huh uname
Couldn't synthesize bpf events.
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB /tmp/huh (7 samples) ]
$ perf record --no-bpf-event --synth=no -o /tmp/huh uname
Couldn't synthesize bpf events.
After:
$ perf record --no-bpf-event --synth=no -o /tmp/huh uname
Couldn't synthesize bpf events.
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB /tmp/huh (7 samples) ]
Fixes: 41b740b6e8a9 ("perf record: Add --synth option")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/builtin-record.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index bce8c941d558..7713246a393f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1974,14 +1974,18 @@ static int record__synthesize(struct record *rec, bool tail)
err = perf_event__synthesize_bpf_events(session, process_synthesized_event,
machine, opts);
- if (err < 0)
+ if (err < 0) {
pr_warning("Couldn't synthesize bpf events.\n");
+ err = 0;
+ }
if (rec->opts.synth & PERF_SYNTH_CGROUP) {
err = perf_event__synthesize_cgroups(tool, process_synthesized_event,
machine);
- if (err < 0)
+ if (err < 0) {
pr_warning("Couldn't synthesize cgroup events.\n");
+ err = 0;
+ }
}
if (rec->opts.nr_threads_synthesize > 1) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf record: Fix synthesis failure warnings
2022-09-07 16:24 [PATCH] perf record: Fix synthesis failure warnings Adrian Hunter
@ 2022-09-07 17:58 ` Namhyung Kim
2022-09-08 18:58 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2022-09-07 17:58 UTC (permalink / raw)
To: Adrian Hunter
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, linux-kernel
On Wed, Sep 7, 2022 at 9:25 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Some calls to synthesis functions set err < 0 but only warn about the
> failure and continue. However they do not set err back to zero, relying
> on subsequent code to do that.
>
> That changed with the introduction of option --synth. When --synth=no
> subsequent functions that set err back to zero are not called.
>
> Fix by setting err = 0 in those cases.
>
> Example:
>
> Before:
>
> $ perf record --no-bpf-event --synth=all -o /tmp/huh uname
> Couldn't synthesize bpf events.
> Linux
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.014 MB /tmp/huh (7 samples) ]
> $ perf record --no-bpf-event --synth=no -o /tmp/huh uname
> Couldn't synthesize bpf events.
>
> After:
>
> $ perf record --no-bpf-event --synth=no -o /tmp/huh uname
> Couldn't synthesize bpf events.
> Linux
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.014 MB /tmp/huh (7 samples) ]
>
> Fixes: 41b740b6e8a9 ("perf record: Add --synth option")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/builtin-record.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index bce8c941d558..7713246a393f 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1974,14 +1974,18 @@ static int record__synthesize(struct record *rec, bool tail)
>
> err = perf_event__synthesize_bpf_events(session, process_synthesized_event,
> machine, opts);
> - if (err < 0)
> + if (err < 0) {
> pr_warning("Couldn't synthesize bpf events.\n");
> + err = 0;
> + }
>
> if (rec->opts.synth & PERF_SYNTH_CGROUP) {
> err = perf_event__synthesize_cgroups(tool, process_synthesized_event,
> machine);
> - if (err < 0)
> + if (err < 0) {
> pr_warning("Couldn't synthesize cgroup events.\n");
> + err = 0;
> + }
> }
>
> if (rec->opts.nr_threads_synthesize > 1) {
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf record: Fix synthesis failure warnings
2022-09-07 17:58 ` Namhyung Kim
@ 2022-09-08 18:58 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-09-08 18:58 UTC (permalink / raw)
To: Namhyung Kim; +Cc: Adrian Hunter, Jiri Olsa, Ian Rogers, linux-kernel
Em Wed, Sep 07, 2022 at 10:58:58AM -0700, Namhyung Kim escreveu:
> On Wed, Sep 7, 2022 at 9:25 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >
> > Some calls to synthesis functions set err < 0 but only warn about the
> > failure and continue. However they do not set err back to zero, relying
> > on subsequent code to do that.
> >
> > That changed with the introduction of option --synth. When --synth=no
> > subsequent functions that set err back to zero are not called.
> >
> > Fix by setting err = 0 in those cases.
> >
> > Example:
> >
> > Before:
> >
> > $ perf record --no-bpf-event --synth=all -o /tmp/huh uname
> > Couldn't synthesize bpf events.
> > Linux
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.014 MB /tmp/huh (7 samples) ]
> > $ perf record --no-bpf-event --synth=no -o /tmp/huh uname
> > Couldn't synthesize bpf events.
> >
> > After:
> >
> > $ perf record --no-bpf-event --synth=no -o /tmp/huh uname
> > Couldn't synthesize bpf events.
> > Linux
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.014 MB /tmp/huh (7 samples) ]
> >
> > Fixes: 41b740b6e8a9 ("perf record: Add --synth option")
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks, applied.
- Arnaldo
> Thanks,
> Namhyung
>
>
> > ---
> > tools/perf/builtin-record.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> > index bce8c941d558..7713246a393f 100644
> > --- a/tools/perf/builtin-record.c
> > +++ b/tools/perf/builtin-record.c
> > @@ -1974,14 +1974,18 @@ static int record__synthesize(struct record *rec, bool tail)
> >
> > err = perf_event__synthesize_bpf_events(session, process_synthesized_event,
> > machine, opts);
> > - if (err < 0)
> > + if (err < 0) {
> > pr_warning("Couldn't synthesize bpf events.\n");
> > + err = 0;
> > + }
> >
> > if (rec->opts.synth & PERF_SYNTH_CGROUP) {
> > err = perf_event__synthesize_cgroups(tool, process_synthesized_event,
> > machine);
> > - if (err < 0)
> > + if (err < 0) {
> > pr_warning("Couldn't synthesize cgroup events.\n");
> > + err = 0;
> > + }
> > }
> >
> > if (rec->opts.nr_threads_synthesize > 1) {
> > --
> > 2.25.1
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-08 18:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 16:24 [PATCH] perf record: Fix synthesis failure warnings Adrian Hunter
2022-09-07 17:58 ` Namhyung Kim
2022-09-08 18:58 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).