public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1 perf-tools] perf trace: The return from 'write' isn't a pid
@ 2024-10-11 19:21 Arnaldo Carvalho de Melo
  2024-10-14  9:17 ` James Clark
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-11 19:21 UTC (permalink / raw)
  To: James Clark
  Cc: Adrian Hunter, Alan Maguire, Howard Chu, Ian Rogers, Jiri Olsa,
	Kan Liang, Namhyung Kim, Linux Kernel Mailing List

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")
Reported-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/lkml/bcf50648-3c7e-4513-8717-0d14492c53b9@linaro.org
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alan Maguire <alan.maguire@oracle.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 f6e8475290739a10..d3f11b90d0255c7e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -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, }, }, },
 };
 
-- 
2.47.0


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

* Re: [PATCH 1/1 perf-tools] perf trace: The return from 'write' isn't a pid
  2024-10-11 19:21 [PATCH 1/1 perf-tools] perf trace: The return from 'write' isn't a pid Arnaldo Carvalho de Melo
@ 2024-10-14  9:17 ` James Clark
  0 siblings, 0 replies; 2+ messages in thread
From: James Clark @ 2024-10-14  9:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Adrian Hunter, Alan Maguire, Howard Chu, Ian Rogers, Jiri Olsa,
	Kan Liang, Namhyung Kim, Linux Kernel Mailing List



On 11/10/2024 8:21 pm, Arnaldo Carvalho de Melo wrote:
> 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")
> Reported-by: James Clark <james.clark@linaro.org>
> Link: https://lore.kernel.org/lkml/bcf50648-3c7e-4513-8717-0d14492c53b9@linaro.org
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Alan Maguire <alan.maguire@oracle.com>
> Cc: Howard Chu <howardchu95@gmail.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>   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 f6e8475290739a10..d3f11b90d0255c7e 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -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.

Reviewed-by: James Clark <james.clark@linaro.org>


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

end of thread, other threads:[~2024-10-14  9:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 19:21 [PATCH 1/1 perf-tools] perf trace: The return from 'write' isn't a pid Arnaldo Carvalho de Melo
2024-10-14  9:17 ` James Clark

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