]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf trace: Always print return value for syscalls returning a pid
authorAnubhav Shelat <ashelat@redhat.com>
Thu, 3 Apr 2025 16:04:12 +0000 (12:04 -0400)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 28 May 2025 18:39:29 +0000 (15:39 -0300)
The syscalls that were consistently observed were set_robust_list and
rseq. This is because perf cannot find their child process.

This change ensures that the return value is always printed.

Before:
     0.256 ( 0.001 ms): set_robust_list(head: 0x7f09c77dba20, len: 24)                        =
     0.259 ( 0.001 ms): rseq(rseq: 0x7f09c77dc0e0, rseq_len: 32, sig: 1392848979)             =
After:
     0.270 ( 0.002 ms): set_robust_list(head: 0x7f0bb14a6a20, len: 24)                        = 0
     0.273 ( 0.002 ms): rseq(rseq: 0x7f0bb14a70e0, rseq_len: 32, sig: 1392848979)             = 0

Committer notes:

As discussed in the thread in the Link: tag below, these two don't
return a pid, but for syscalls returning one, we need to print the
result and if we manage to find the children in 'perf trace' data
structures, then print its name as well.

Fixes: 11c8e39f5133aed9 ("perf trace: Infrastructure to show COMM strings for syscalls returning PIDs")
Reviewed-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250403160411.159238-2-ashelat@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index 07eddd5c0baaa2ee43da549db4de135bbcd0688b..67b557ec3b0d8a570d83cf9d640fa37607fbeec9 100644 (file)
@@ -3005,8 +3005,8 @@ errno_print: {
        else if (sc->fmt->errpid) {
                struct thread *child = machine__find_thread(trace->host, ret, ret);
 
+               fprintf(trace->output, "%ld", ret);
                if (child != NULL) {
-                       fprintf(trace->output, "%ld", ret);
                        if (thread__comm_set(child))
                                fprintf(trace->output, " (%s)", thread__comm_str(child));
                        thread__put(child);