mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf trace: Handle task exit in BPF syscall summary
@ 2026-02-26  1:49 Namhyung Kim
  2026-02-26  3:52 ` Ian Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Namhyung Kim @ 2026-02-26  1:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers, James Clark
  Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users, Howard Chu

Some system calls never return because it'd terminate the calling
thread.  Let's hook the task exit path and update the duration of the
last syscall.

Before:
  $ sudo perf trace -as --bpf-summary -- true |& grep exit
  (nothing)

After:
  $ sudo perf trace -as --bpf-summary -- true |& grep exit
     exit_group             1      0     0.004     0.004     0.004     0.004      0.00%

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/bpf_skel/syscall_summary.bpf.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/bpf_skel/syscall_summary.bpf.c b/tools/perf/util/bpf_skel/syscall_summary.bpf.c
index 1bcd066a5199a476..4172f3c9fc483955 100644
--- a/tools/perf/util/bpf_skel/syscall_summary.bpf.c
+++ b/tools/perf/util/bpf_skel/syscall_summary.bpf.c
@@ -118,13 +118,11 @@ int sys_enter(u64 *ctx)
 	return 0;
 }
 
-SEC("tp_btf/sys_exit")
-int sys_exit(u64 *ctx)
+static int do_exit(long ret)
 {
 	int tid;
 	int key = 0;
 	u64 cgroup = 0;
-	long ret = ctx[1]; /* return value of the syscall */
 	struct syscall_trace *st;
 	s64 delta;
 
@@ -150,4 +148,18 @@ int sys_exit(u64 *ctx)
 	return 0;
 }
 
+SEC("tp_btf/sys_exit")
+int sys_exit(u64 *ctx)
+{
+	long ret = ctx[1]; /* return value of the syscall */
+
+	return do_exit(ret);
+}
+
+SEC("tp_btf/sched_process_exit")
+int process_exit(u64 *ctx)
+{
+	return do_exit(0);
+}
+
 char _license[] SEC("license") = "GPL";
-- 
2.53.0.414.gf7e9f6c205-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf trace: Handle task exit in BPF syscall summary
  2026-02-26  1:49 [PATCH] perf trace: Handle task exit in BPF syscall summary Namhyung Kim
@ 2026-02-26  3:52 ` Ian Rogers
  2026-02-26 11:05 ` Howard Chu
  2026-02-27 21:32 ` Namhyung Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2026-02-26  3:52 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, James Clark, Jiri Olsa, Adrian Hunter,
	Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users, Howard Chu

On Wed, Feb 25, 2026 at 5:49 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Some system calls never return because it'd terminate the calling
> thread.  Let's hook the task exit path and update the duration of the
> last syscall.
>
> Before:
>   $ sudo perf trace -as --bpf-summary -- true |& grep exit
>   (nothing)
>
> After:
>   $ sudo perf trace -as --bpf-summary -- true |& grep exit
>      exit_group             1      0     0.004     0.004     0.004     0.004      0.00%
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/util/bpf_skel/syscall_summary.bpf.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/bpf_skel/syscall_summary.bpf.c b/tools/perf/util/bpf_skel/syscall_summary.bpf.c
> index 1bcd066a5199a476..4172f3c9fc483955 100644
> --- a/tools/perf/util/bpf_skel/syscall_summary.bpf.c
> +++ b/tools/perf/util/bpf_skel/syscall_summary.bpf.c
> @@ -118,13 +118,11 @@ int sys_enter(u64 *ctx)
>         return 0;
>  }
>
> -SEC("tp_btf/sys_exit")
> -int sys_exit(u64 *ctx)
> +static int do_exit(long ret)
>  {
>         int tid;
>         int key = 0;
>         u64 cgroup = 0;
> -       long ret = ctx[1]; /* return value of the syscall */
>         struct syscall_trace *st;
>         s64 delta;
>
> @@ -150,4 +148,18 @@ int sys_exit(u64 *ctx)
>         return 0;
>  }
>
> +SEC("tp_btf/sys_exit")
> +int sys_exit(u64 *ctx)
> +{
> +       long ret = ctx[1]; /* return value of the syscall */
> +
> +       return do_exit(ret);
> +}
> +
> +SEC("tp_btf/sched_process_exit")
> +int process_exit(u64 *ctx)
> +{
> +       return do_exit(0);
> +}
> +
>  char _license[] SEC("license") = "GPL";
> --
> 2.53.0.414.gf7e9f6c205-goog
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf trace: Handle task exit in BPF syscall summary
  2026-02-26  1:49 [PATCH] perf trace: Handle task exit in BPF syscall summary Namhyung Kim
  2026-02-26  3:52 ` Ian Rogers
@ 2026-02-26 11:05 ` Howard Chu
  2026-02-27 21:32 ` Namhyung Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Howard Chu @ 2026-02-26 11:05 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, James Clark, Jiri Olsa,
	Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users

Hi Namhyung,

On Wed, Feb 25, 2026 at 5:49 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Some system calls never return because it'd terminate the calling
> thread.  Let's hook the task exit path and update the duration of the
> last syscall.
>
> Before:
>   $ sudo perf trace -as --bpf-summary -- true |& grep exit
>   (nothing)
>
> After:
>   $ sudo perf trace -as --bpf-summary -- true |& grep exit
>      exit_group             1      0     0.004     0.004     0.004     0.004      0.00%
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Howard Chu <howardchu95@gmail.com>

Thanks,
Howard

> ---
>  tools/perf/util/bpf_skel/syscall_summary.bpf.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/bpf_skel/syscall_summary.bpf.c b/tools/perf/util/bpf_skel/syscall_summary.bpf.c
> index 1bcd066a5199a476..4172f3c9fc483955 100644
> --- a/tools/perf/util/bpf_skel/syscall_summary.bpf.c
> +++ b/tools/perf/util/bpf_skel/syscall_summary.bpf.c
> @@ -118,13 +118,11 @@ int sys_enter(u64 *ctx)
>         return 0;
>  }
>
> -SEC("tp_btf/sys_exit")
> -int sys_exit(u64 *ctx)
> +static int do_exit(long ret)
>  {
>         int tid;
>         int key = 0;
>         u64 cgroup = 0;
> -       long ret = ctx[1]; /* return value of the syscall */
>         struct syscall_trace *st;
>         s64 delta;
>
> @@ -150,4 +148,18 @@ int sys_exit(u64 *ctx)
>         return 0;
>  }
>
> +SEC("tp_btf/sys_exit")
> +int sys_exit(u64 *ctx)
> +{
> +       long ret = ctx[1]; /* return value of the syscall */
> +
> +       return do_exit(ret);
> +}
> +
> +SEC("tp_btf/sched_process_exit")
> +int process_exit(u64 *ctx)
> +{
> +       return do_exit(0);
> +}
> +
>  char _license[] SEC("license") = "GPL";
> --
> 2.53.0.414.gf7e9f6c205-goog
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf trace: Handle task exit in BPF syscall summary
  2026-02-26  1:49 [PATCH] perf trace: Handle task exit in BPF syscall summary Namhyung Kim
  2026-02-26  3:52 ` Ian Rogers
  2026-02-26 11:05 ` Howard Chu
@ 2026-02-27 21:32 ` Namhyung Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2026-02-27 21:32 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers, James Clark, Namhyung Kim
  Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users, Howard Chu

On Wed, 25 Feb 2026 17:49:55 -0800, Namhyung Kim wrote:
> Some system calls never return because it'd terminate the calling
> thread.  Let's hook the task exit path and update the duration of the
> last syscall.
> 
> Before:
>   $ sudo perf trace -as --bpf-summary -- true |& grep exit
>   (nothing)
> 
> [...]
Applied to perf-tools-next, thanks!

Best regards,
Namhyung



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-27 21:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26  1:49 [PATCH] perf trace: Handle task exit in BPF syscall summary Namhyung Kim
2026-02-26  3:52 ` Ian Rogers
2026-02-26 11:05 ` Howard Chu
2026-02-27 21:32 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®