Skip to contentSkip to conversation

perf trace: The return from 'write' isn't a pid

PATCH In review Arnaldo Carvalho de Melo 2 participants 2 messages Oct 11, 2024 – Oct 14, 2024 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

PATCH 1/1 perf trace: The return from 'write' isn't a pid

When adding a explicit beautifier for the 'write' syscall when the BPF based buffer collector was introduced there was a cut'n'paste error that carried the syscall_fmt->errpid setting from a nearby syscall (waitid) that returns a pid.

So the write return was being suppressed by the return pretty printer, remove that field, reverting it back to the default return handler, that prints positive numbers as-is and interpret negative values as errnos.

I actually introduced the problem while making Howard's original patch work just with the 'write' syscall, as we couldn't just look for any buffers, the ones that are filled in by the kernel couldn't use the same sys_enter BPF collector.

Fixes b257fac12f38d7f5 ("perf trace: Pretty print buffer data")
Cc Adrian Hunter <[email protected]>
Cc Alan Maguire <[email protected]>
Cc Howard Chu <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/builtin-trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
index f6e8475290739a10..d3f11b90d0255c7e 100644
@@ -1399,7 +1399,7 @@ static const struct syscall_fmt syscall_fmts[] = {
 	  .arg = { [2] = { .scnprintf = SCA_WAITID_OPTIONS, /* options */ }, }, },
 	{ .name	    = "waitid",	    .errpid = true,
 	  .arg = { [3] = { .scnprintf = SCA_WAITID_OPTIONS, /* options */ }, }, },
-	{ .name	    = "write",	    .errpid = true,
+	{ .name	    = "write",
 	  .arg = { [1] = { .scnprintf = SCA_BUF /* buf */, .from_user = true, }, }, },
 };
 
Signature · 1 line
2.47.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Arnaldo Carvalho de Melo

When adding a explicit beautifier for the 'write' syscall when the BPF based buffer collector was introduced there was a cut'n'paste error that carried the syscall_fmt->errpid setting from a nearby syscall (waitid) that returns a pid.

So the write return was being suppressed by the return pretty printer, remove that field, reverting it back to the default return handler, that prints positive numbers as-is and interpret negative values as errnos.

I actually introduced the problem while making Howard's original patch work just with the 'write' syscall, as we couldn't just look for any buffers, the ones that are filled in by the kernel couldn't use the same sys_enter BPF collector.

Fixes b257fac12f38d7f5 ("perf trace: Pretty print buffer data")
Cc Adrian Hunter <[email protected]>
Cc Alan Maguire <[email protected]>
Cc Howard Chu <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Namhyung Kim <[email protected]>
---
  tools/perf/builtin-trace.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +0 -0
index f6e8475290739a10..d3f11b90d0255c7e 100644

tools/perf/builtin-trace.c static const struct syscall_fmt syscall_fmts[] = { · line 1405

Quoted 8 lines
tools/perf/builtin-trace.c +1 -1
@@ -1399,7 +1399,7 @@ static const struct syscall_fmt syscall_fmts[] = {
  	  .arg = { [2] = { .scnprintf = SCA_WAITID_OPTIONS, /* options */ }, }, },
  	{ .name	    = "waitid",	    .errpid = true,
  	  .arg = { [3] = { .scnprintf = SCA_WAITID_OPTIONS, /* options */ }, }, },
-	{ .name	    = "write",	    .errpid = true,
+	{ .name	    = "write",
  	  .arg = { [1] = { .scnprintf = SCA_BUF /* buf */, .from_user = true, }, }, },
  };
 

Fixes the return value:

0.000 ( 0.010 ms): echo/100910 write(fd: 1, buf: , count: 6)

                = 6

I still see the missing address for buf, but I suppose that's a separate issue that's introduced in the same commit. Also whether the address was even useful I don't know.