perf trace: always print return value for syscalls with set errpid
PATCH 1/1 perf trace: always print return value for syscalls with set errpid
Currently some syscalls that have errpid set to true do not print a return value in perf trace. 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--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -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);
Signature · 1 line
2.48.1
[Resend due to rejection by mailing list]
Hello Anubhav,
Thanks for doing this :)
Quoted 7 lines · Anubhav Shelat
Currently some syscalls that have errpid set to true do not print a return value in perf trace. The syscalls that were consistently observed were
set_robust_listand rseq. This is because perf cannot find their child process. This change ensures that the return value is always printed.
Quoted 8 lines
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) = 0Signed-off-by Anubhav Shelat <[email protected]>
Thanks,
Howard
Hello,
Ping.
Thanks,
Howard
Arnaldo Carvalho de Melo
maintainerQuoted 21 lines · Howard Chu
[Resend due to rejection by mailing list]
Hello Anubhav,
Thanks for doing this :)
Quoted 14 lines · Anubhav Shelat
Currently some syscalls that have errpid set to true do not print a return value in perf trace. The syscalls that were consistently observed were
set_robust_listand 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
Quoted 3 lines
Quoted 1 line
Signed-off-by Anubhav Shelat <[email protected]>Reviewed-by Howard Chu <[email protected]>
Thanks, applied after rewording it a bit to mention that this not related to rseq/set_robust_list as those shouldn't be using errpid, but that the problem predates that and added this, where the problem started:
- Arnaldo
Sent the second patch for errpid.
Best,
Anubhav
Quoted 36 lines · Arnaldo Carvalho de Melo
Quoted 21 lines · Howard Chu
[Resend due to rejection by mailing list]
Hello Anubhav,
Thanks for doing this :)
Quoted 14 lines · Anubhav Shelat
Currently some syscalls that have errpid set to true do not print a return value in perf trace. The syscalls that were consistently observed were
set_robust_listand 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) = 0Quoted 3 lines
Quoted 1 line
Signed-off-by Anubhav Shelat <[email protected]>Reviewed-by Howard Chu <[email protected]>Thanks, applied after rewording it a bit to mention that this not related to rseq/set_robust_list as those shouldn't be using errpid, but that the problem predates that and added this, where the problem started:
Fixes 11c8e39f5133aed9 ("perf trace: Infrastructure to show COMM strings for syscalls returning PIDs")- Arnaldo
Namhyung Kim
maintainerQuoted 6 lines · Anubhav Shelat
Currently some syscalls that have errpid set to true do not print a return value in perf trace. The syscalls that were consistently observed were
set_robust_listand rseq. This is because perf cannot find their child process. This change ensures that the return value is always printed.
Quoted 6 lines
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
I'm ok with the change but I'm not sure if they are right syscalls. It seems neither of syscalls return a thread id.
Thanks,
Namhyung
Quoted 23 lines
Signed-off-by Anubhav Shelat <[email protected]>--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/builtin-trace.c +1
-1@@ -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);Signature · 1 line
2.48.1
A message that is not in the archive (sent off-list or not yet received): CA+G8DhK05FPgdLhN0LVYsDUTsJou4x4BxqycbPweGYgL_b4_VQ@mail.gmail.com
Arnaldo Carvalho de Melo
maintainerQuoted 6 lines · Anubhav Shelat
Every time I ran perf trace I saw that the return value for only
set_robust_listand rseq was empty, even though while stepping through the code the return value was 0. So I do think that these are the right syscalls.
The cause of the problem is that no thread id is returned, so the logic skips printing the return value. The change ensures the return value
Well:
RETURN VALUE
The set_robust_list() and get_robust_list() system calls return zero when the operation is successful, an error code otherwise.
and rset return -errno on failure, so they are both not returning a pid and should print errno when less than zero.
Quoted 2 lines
always gets printed. Another solution would be to set errpid to false for both
set_robust_listand rseq.
Can you please send a new patch with this? please add a Fixes tag as well, for these two csets:
⬢ [acme@toolbx perf-tools-next]$ git blame tools/perf/builtin-trace.c | grep -E '"(rseq|set_robust_list)"'
0c1019e3463b263a8 (Arnaldo Carvalho de Melo 2024-09-11 16:34:16 -0300 1351) { .name = "rseq", .errpid = true,
1de5b5dcb8353f365 (Arnaldo Carvalho de Melo 2024-09-11 17:10:33 -0300 1375) { .name = "set_robust_list", .errpid = true,⬢ [acme@toolbx perf-tools-next]$
My mistake, that was a copy'n'paste error, those '.errpid = true' shouldn't be there, as you noticed.
The first patch from you is also valid, but due to a different reason, as Namhyung pointed out.
So I'm applying it now.
- Arnaldo
Quoted 64 lines
Best, Anubhav On Sun, May 18, 2025 at 2:03 PM Namhyung Kim <[1][email protected]> wrote: On Thu, Apr 03, 2025 at 12:04:12PM -0400, Anubhav Shelat wrote: > Currently some syscalls that have errpid set to true do not print a > return value in perf trace. 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 I'm ok with the change but I'm not sure if they are right syscalls. It seems neither of syscalls return a thread id. Thanks, Namhyung > > Signed-off-by: Anubhav Shelat <[2][email protected]> > --- > tools/perf/builtin-trace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c > index 6ac51925ea42..c192f0219b2b 100644 > --- a/tools/perf/builtin-trace.c > +++ b/tools/perf/builtin-trace.c > @@ -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); > -- > 2.48.1 >References
1. mailto:[email protected]
2. mailto:[email protected]