From: Namhyung Kim <namhyung@kernel.org>
To: Howard Chu <howardchu95@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org, bpf@vger.kernel.org,
Song Liu <song@kernel.org>
Subject: Re: [PATCH v2] perf trace: Implement syscall summary in BPF
Date: Wed, 19 Mar 2025 17:17:30 -0700 [thread overview]
Message-ID: <Z9temnrmEHVTfSZD@google.com> (raw)
In-Reply-To: <CAH0uvoi_Soj=b1YdsqN=RhHMf340r1YZm72JgkyAyUi-Rox7_g@mail.gmail.com>
On Wed, Mar 19, 2025 at 04:39:17PM -0700, Howard Chu wrote:
> Hi Namhyung,
>
> I haven't finished the code review yet, but here are something that I
> found interesting to share:
Thanks a lot for your review!
>
> ## 1
> You used sudo ./perf trace -as --bpf-summary --summary-mode=total -- sleep 1 as
> an example
>
> If I use perf trace --bpf-summary without the '-a', that is to record
> the process / task of 'sleep 1':
>
> sudo ./perf trace -s --bpf-summary --summary-mode=total -- sleep 1
>
> It won't be recording this one process. So there should be a sentence
> saying that bpf-summary only does system wide summaries.
Hmm.. you're right. I added per-thread summary but it still works for
system-wide only. I'll check the target and make it fail with an error
message if it's not in system-wide mode for now. I think we can add
support for other targets later.
>
> ## 2
> there is a bug in min section, which made min always 0
>
> you can see it in the sample output you provided above:
> syscall calls errors total min avg
> max stddev
> (msec) (msec) (msec)
> (msec) (%)
> --------------- -------- ------ -------- --------- ---------
> --------- ------
> futex 372 18 4373.773 0.000 11.757
> 997.715 660.42%
> poll 241 0 2757.963 0.000 11.444
> 997.758 580.34%
> epoll_wait 161 0 2460.854 0.000 15.285
> 325.189 260.73%
> ppoll 19 0 1298.652 0.000 68.350
> 667.172 281.46%
> clock_nanosleep 1 0 1000.093 0.000 1000.093
> 1000.093 0.00%
> epoll_pwait 16 0 192.787 0.000 12.049
> 173.994 348.73%
> nanosleep 6 0 50.926 0.000 8.488
> 10.210 43.96%
>
> clock_nanosleep has only 1 call so min can never be 0, it has to be
> equal to the max and the mean.
Oops, right.
>
> This can be resolved by adding this line (same as what you did in the BPF code):
>
> diff --git a/tools/perf/util/bpf-trace-summary.c
> b/tools/perf/util/bpf-trace-summary.c
> index 5ae9feca244d..eb98db7d6e33 100644
> --- a/tools/perf/util/bpf-trace-summary.c
> +++ b/tools/perf/util/bpf-trace-summary.c
> @@ -243,7 +243,7 @@ static int update_total_stats(struct hashmap
> *hash, struct syscall_key *map_key,
>
> if (stat->max_time < map_data->max_time)
> stat->max_time = map_data->max_time;
> - if (stat->min_time > map_data->min_time)
> + if (stat->min_time > map_data->min_time || !stat->min_time)
> stat->min_time = map_data->min_time;
>
> return 0;
>
> (sorry for the poor formatting from the gmail browser app)
No problem, I'll add this change.
>
> ## 3
> Apologies for misunderstanding how the calculation of the 'standard
> deviation of mean' works. You can decide what to do with it. :) Thanks
> for the explanation in the thread of the previous version.
No, it turns out that it can be calculated easily with the squared sum.
So I've added it.
Thanks,
Namhyung
>
> Thanks,
> Howard
>
> On Wed, Mar 19, 2025 at 3:19 PM Howard Chu <howardchu95@gmail.com> wrote:
> >
> > Hi Namhyung,
> >
> > On Wed, Mar 19, 2025 at 3:07 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > Hello Howard,
> > >
> > > On Wed, Mar 19, 2025 at 12:00:10PM -0700, Howard Chu wrote:
> > > > Hello Namhyung,
> > > >
> > > > Can you please rebase it? I cannot apply it, getting:
> > > >
> > > > perf $ git apply --reject --whitespace=fix
> > > > ./v2_20250317_namhyung_perf_trace_implement_syscall_summary_in_bpf.mbx
> > > > Checking patch tools/perf/Documentation/perf-trace.txt...
> > > > Checking patch tools/perf/Makefile.perf...
> > > > Hunk #1 succeeded at 1198 (offset -8 lines).
> > > > Checking patch tools/perf/builtin-trace.c...
> > > > error: while searching for:
> > > > bool hexret;
> > > > };
> > > >
> > > > enum summary_mode {
> > > > SUMMARY__NONE = 0,
> > > > SUMMARY__BY_TOTAL,
> > > > SUMMARY__BY_THREAD,
> > > > };
> > > >
> > > > struct trace {
> > > > struct perf_tool tool;
> > > > struct {
> > > >
> > > > error: patch failed: tools/perf/builtin-trace.c:140
> > >
> > > Oops, I think I forgot to say it's on top of Ian's change.
> > > Please try this first. Sorry for the confusion.
> > >
> > > https://lore.kernel.org/r/20250319050741.269828-1-irogers@google.com
> >
> > Yep, with Ian's patches it successfully applied. :)
> >
> > Thanks,
> > Howard
> > >
> > > Thanks,
> > > Namhyung
> > >
next prev parent reply other threads:[~2025-03-20 0:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 18:08 [PATCH v2] perf trace: Implement syscall summary in BPF Namhyung Kim
2025-03-17 18:37 ` Ian Rogers
2025-03-20 6:07 ` Namhyung Kim
2025-03-19 19:00 ` Howard Chu
2025-03-19 22:07 ` Namhyung Kim
2025-03-19 22:19 ` Howard Chu
2025-03-19 23:39 ` Howard Chu
2025-03-20 0:17 ` Namhyung Kim [this message]
2025-03-21 2:35 ` Howard Chu
2025-03-21 5:54 ` Namhyung Kim
2025-03-21 17:19 ` Howard Chu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9temnrmEHVTfSZD@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=bpf@vger.kernel.org \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox