From: Howard Chu <howardchu95@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
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, Song Liu <song@kernel.org>,
bpf@vger.kernel.org
Subject: Re: [PATCH v4 1/2] perf trace: Implement syscall summary in BPF
Date: Fri, 28 Mar 2025 18:46:36 -0700 [thread overview]
Message-ID: <CAH0uvojPaZ-byE-quc=sUvXyExaZPU3PUjdTYOzE5iDAT_wNVA@mail.gmail.com> (raw)
In-Reply-To: <20250326044001.3503432-1-namhyung@kernel.org>
Hello Namhyung,
On Tue, Mar 25, 2025 at 9:40 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> When -s/--summary option is used, it doesn't need (augmented) arguments
> of syscalls. Let's skip the augmentation and load another small BPF
> program to collect the statistics in the kernel instead of copying the
> data to the ring-buffer to calculate the stats in userspace. This will
> be much more light-weight than the existing approach and remove any lost
> events.
>
> Let's add a new option --bpf-summary to control this behavior. I cannot
> make it default because there's no way to get e_machine in the BPF which
> is needed for detecting different ABIs like 32-bit compat mode.
>
> No functional changes intended except for no more LOST events. :)
>
> $ sudo ./perf trace -as --summary-mode=total --bpf-summary sleep 1
>
> Summary of events:
>
> total, 6194 events
>
> syscall calls errors total min avg max stddev
> (msec) (msec) (msec) (msec) (%)
> --------------- -------- ------ -------- --------- --------- --------- ------
> epoll_wait 561 0 4530.843 0.000 8.076 520.941 18.75%
> futex 693 45 4317.231 0.000 6.230 500.077 21.98%
> poll 300 0 1040.109 0.000 3.467 120.928 17.02%
> clock_nanosleep 1 0 1000.172 1000.172 1000.172 1000.172 0.00%
> ppoll 360 0 872.386 0.001 2.423 253.275 41.91%
> epoll_pwait 14 0 384.349 0.001 27.453 380.002 98.79%
> pselect6 14 0 108.130 7.198 7.724 8.206 0.85%
> nanosleep 39 0 43.378 0.069 1.112 10.084 44.23%
> ...
>
> Cc: Howard Chu <howardchu95@gmail.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> v4)
> * fix segfault on -S (Howard)
> * correct some comments (Howard)
+ if (!hashmap__find(hash, map_key->nr, &data)) {
I think you should mention the hashmap's map_key->nr update, as this
change is actually important for the feature.
>
> v3)
> * support -S/--with-summary option too (Howard)
> * make it work only with -a/--all-cpus (Howard)
> * fix stddev calculation (Howard)
> * add some comments about syscall_data (Howard)
>
> v2)
> * Rebased on top of Ian's e_machine changes
> * add --bpf-summary option
> * support per-thread summary
> * add stddev calculation (Howard)
>
> tools/perf/Documentation/perf-trace.txt | 6 +
> tools/perf/Makefile.perf | 2 +-
> tools/perf/builtin-trace.c | 54 ++-
> tools/perf/util/Build | 1 +
> tools/perf/util/bpf-trace-summary.c | 347 ++++++++++++++++++
> .../perf/util/bpf_skel/syscall_summary.bpf.c | 118 ++++++
> tools/perf/util/bpf_skel/syscall_summary.h | 25 ++
> tools/perf/util/trace.h | 37 ++
> 8 files changed, 577 insertions(+), 13 deletions(-)
> create mode 100644 tools/perf/util/bpf-trace-summary.c
> create mode 100644 tools/perf/util/bpf_skel/syscall_summary.bpf.c
> create mode 100644 tools/perf/util/bpf_skel/syscall_summary.h
> create mode 100644 tools/perf/util/trace.h
>
> diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
> index 887dc37773d0f4d6..a8a0d8c33438fef7 100644
> --- a/tools/perf/Documentation/perf-trace.txt
> +++ b/tools/perf/Documentation/perf-trace.txt
> @@ -251,6 +251,12 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
> pretty-printing serves as a fallback to hand-crafted pretty printers, as the latter can
> better pretty-print integer flags and struct pointers.
>
> +--bpf-summary::
> + Collect system call statistics in BPF. This is only for live mode and
> + works well with -s/--summary option where no argument information is
> + required.
It works with -S as well, doesn't it?
Anyway, I don't mind adding these details later on, so
Reviewed-by: Howard Chu <howardchu95@gmail.com>
next prev parent reply other threads:[~2025-03-29 1:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 4:40 [PATCH v4 1/2] perf trace: Implement syscall summary in BPF Namhyung Kim
2025-03-26 4:40 ` [PATCH v4 2/2] perf test: Add perf trace summary test Namhyung Kim
2025-03-29 1:48 ` Howard Chu
2025-03-29 1:46 ` Howard Chu [this message]
2025-04-23 16:19 ` [PATCH v4 1/2] perf trace: Implement syscall summary in BPF Arnaldo Carvalho de Melo
2025-04-23 16:26 ` Arnaldo Carvalho de Melo
2025-04-23 17:41 ` Namhyung Kim
2025-04-23 20:50 ` Arnaldo Carvalho de Melo
2025-04-24 22:06 ` Arnaldo Carvalho de Melo
2025-04-25 21:51 ` Namhyung Kim
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='CAH0uvojPaZ-byE-quc=sUvXyExaZPU3PUjdTYOzE5iDAT_wNVA@mail.gmail.com' \
--to=howardchu95@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=bpf@vger.kernel.org \
--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=namhyung@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;
as well as URLs for NNTP newsgroup(s).