]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf trace: Handle task exit in BPF syscall summary
authorNamhyung Kim <namhyung@kernel.org>
Thu, 26 Feb 2026 01:49:55 +0000 (17:49 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 26 Feb 2026 18:49:00 +0000 (10:49 -0800)
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%

Reviewed-by: Ian Rogers <irogers@google.com>
Acked-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/bpf_skel/syscall_summary.bpf.c

index 1bcd066a5199a4768ca9a044d2531020bb0a83bc..4172f3c9fc4839557db2dd1f10ce1fcae78c8dcc 100644 (file)
@@ -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";