linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
@ 2024-12-13  3:56 Benjamin Peterson
  2024-12-13 18:06 ` Howard Chu
  0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Peterson @ 2024-12-13  3:56 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter
  Cc: linux-perf-users, linux-kernel, Benjamin Peterson

The return value of this function was meaningless and therefore ignored by
the caller. Remove it.

Signed-off-by: Benjamin Peterson <benjamin@engflow.com>
---
This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
trace: avoid garbage when not printing a trace event's arguments").
---
 tools/perf/builtin-trace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
 	++trace->nr_events_printed;
 }
 
-static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
-				       struct thread *thread, void *augmented_args, int augmented_args_size)
+static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+				     struct thread *thread, void *augmented_args, int augmented_args_size)
 {
 	char bf[2048];
 	size_t size = sizeof(bf);
@@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
 		printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
 	}
 
-	return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
+	fprintf(trace->output, "%.*s", (int)printed, bf);
 }
 
 static int trace__event_handler(struct trace *trace, struct evsel *evsel,

---
base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f

Best regards,
-- 
Benjamin Peterson <benjamin@engflow.com>


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

* Re: [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
  2024-12-13  3:56 [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields Benjamin Peterson
@ 2024-12-13 18:06 ` Howard Chu
  2025-01-22  3:01   ` Howard Chu
  0 siblings, 1 reply; 7+ messages in thread
From: Howard Chu @ 2024-12-13 18:06 UTC (permalink / raw)
  To: Benjamin Peterson
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, linux-perf-users, linux-kernel

Hello Benjamin,

On Thu, Dec 12, 2024 at 7:56 PM Benjamin Peterson <benjamin@engflow.com> wrote:
>
> The return value of this function was meaningless and therefore ignored by
> the caller. Remove it.
>
> Signed-off-by: Benjamin Peterson <benjamin@engflow.com>
> ---
> This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
> trace: avoid garbage when not printing a trace event's arguments").
> ---
>  tools/perf/builtin-trace.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
>         ++trace->nr_events_printed;
>  }
>
> -static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
> -                                      struct thread *thread, void *augmented_args, int augmented_args_size)
> +static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
> +                                    struct thread *thread, void *augmented_args, int augmented_args_size)
>  {
>         char bf[2048];
>         size_t size = sizeof(bf);
> @@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
>                 printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
>         }
>
> -       return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
> +       fprintf(trace->output, "%.*s", (int)printed, bf);
>  }
>
>  static int trace__event_handler(struct trace *trace, struct evsel *evsel,
>
> ---
> base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
> change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f
>
> Best regards,
> --
> Benjamin Peterson <benjamin@engflow.com>
>
>

Thank you for the follow-up patch, LGTM. Built and tested.

perf $ ./perf test "perf trace"
109: perf trace enum augmentation tests                              : Ok
110: perf trace exit race                                            : Ok

Reviewed-by: Howard Chu <howardchu95@gmail.com>

Thanks,
Howard

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

* Re: [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
  2024-12-13 18:06 ` Howard Chu
@ 2025-01-22  3:01   ` Howard Chu
  2025-01-22 19:08     ` Namhyung Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Howard Chu @ 2025-01-22  3:01 UTC (permalink / raw)
  To: Benjamin Peterson
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, linux-perf-users, linux-kernel

Hello fellow maintainers,

Just a slight ping.

Thanks,
Howard

On Fri, Dec 13, 2024 at 10:06 AM Howard Chu <howardchu95@gmail.com> wrote:
>
> Hello Benjamin,
>
> On Thu, Dec 12, 2024 at 7:56 PM Benjamin Peterson <benjamin@engflow.com> wrote:
> >
> > The return value of this function was meaningless and therefore ignored by
> > the caller. Remove it.
> >
> > Signed-off-by: Benjamin Peterson <benjamin@engflow.com>
> > ---
> > This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
> > trace: avoid garbage when not printing a trace event's arguments").
> > ---
> >  tools/perf/builtin-trace.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
> > --- a/tools/perf/builtin-trace.c
> > +++ b/tools/perf/builtin-trace.c
> > @@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
> >         ++trace->nr_events_printed;
> >  }
> >
> > -static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
> > -                                      struct thread *thread, void *augmented_args, int augmented_args_size)
> > +static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
> > +                                    struct thread *thread, void *augmented_args, int augmented_args_size)
> >  {
> >         char bf[2048];
> >         size_t size = sizeof(bf);
> > @@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
> >                 printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
> >         }
> >
> > -       return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
> > +       fprintf(trace->output, "%.*s", (int)printed, bf);
> >  }
> >
> >  static int trace__event_handler(struct trace *trace, struct evsel *evsel,
> >
> > ---
> > base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
> > change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f
> >
> > Best regards,
> > --
> > Benjamin Peterson <benjamin@engflow.com>
> >
> >
>
> Thank you for the follow-up patch, LGTM. Built and tested.
>
> perf $ ./perf test "perf trace"
> 109: perf trace enum augmentation tests                              : Ok
> 110: perf trace exit race                                            : Ok
>
> Reviewed-by: Howard Chu <howardchu95@gmail.com>
>
> Thanks,
> Howard

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

* Re: [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
  2025-01-22  3:01   ` Howard Chu
@ 2025-01-22 19:08     ` Namhyung Kim
  2025-01-22 19:19       ` Benjamin Peterson
  0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2025-01-22 19:08 UTC (permalink / raw)
  To: Howard Chu
  Cc: Benjamin Peterson, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, linux-perf-users,
	linux-kernel

Hello,

On Tue, Jan 21, 2025 at 07:01:53PM -0800, Howard Chu wrote:
> Hello fellow maintainers,
> 
> Just a slight ping.

Thanks for the reminder.

> 
> Thanks,
> Howard
> 
> On Fri, Dec 13, 2024 at 10:06 AM Howard Chu <howardchu95@gmail.com> wrote:
> >
> > Hello Benjamin,
> >
> > On Thu, Dec 12, 2024 at 7:56 PM Benjamin Peterson <benjamin@engflow.com> wrote:
> > >
> > > The return value of this function was meaningless and therefore ignored by
> > > the caller. Remove it.

In fact, I don't see the reason to merge this, as it's the convention to
return the number of characters it prints.  Yes, it's not used but not
much reason to remove it.

Thanks,
Namhyung

> > >
> > > Signed-off-by: Benjamin Peterson <benjamin@engflow.com>
> > > ---
> > > This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
> > > trace: avoid garbage when not printing a trace event's arguments").
> > > ---
> > >  tools/perf/builtin-trace.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > > index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
> > > --- a/tools/perf/builtin-trace.c
> > > +++ b/tools/perf/builtin-trace.c
> > > @@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
> > >         ++trace->nr_events_printed;
> > >  }
> > >
> > > -static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
> > > -                                      struct thread *thread, void *augmented_args, int augmented_args_size)
> > > +static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
> > > +                                    struct thread *thread, void *augmented_args, int augmented_args_size)
> > >  {
> > >         char bf[2048];
> > >         size_t size = sizeof(bf);
> > > @@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
> > >                 printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
> > >         }
> > >
> > > -       return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
> > > +       fprintf(trace->output, "%.*s", (int)printed, bf);
> > >  }
> > >
> > >  static int trace__event_handler(struct trace *trace, struct evsel *evsel,
> > >
> > > ---
> > > base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
> > > change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f
> > >
> > > Best regards,
> > > --
> > > Benjamin Peterson <benjamin@engflow.com>
> > >
> > >
> >
> > Thank you for the follow-up patch, LGTM. Built and tested.
> >
> > perf $ ./perf test "perf trace"
> > 109: perf trace enum augmentation tests                              : Ok
> > 110: perf trace exit race                                            : Ok
> >
> > Reviewed-by: Howard Chu <howardchu95@gmail.com>
> >
> > Thanks,
> > Howard

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

* Re: [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
  2025-01-22 19:08     ` Namhyung Kim
@ 2025-01-22 19:19       ` Benjamin Peterson
  2025-01-23 23:48         ` Namhyung Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Peterson @ 2025-01-22 19:19 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Howard Chu, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, linux-perf-users, linux-kernel

On Wed, Jan 22, 2025 at 11:08 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> On Tue, Jan 21, 2025 at 07:01:53PM -0800, Howard Chu wrote:
> > Hello fellow maintainers,
> >
> > Just a slight ping.
>
> Thanks for the reminder.

Thanks for taking a look.

>
> >
> > Thanks,
> > Howard
> >
> > On Fri, Dec 13, 2024 at 10:06 AM Howard Chu <howardchu95@gmail.com> wrote:
> > >
> > > Hello Benjamin,
> > >
> > > On Thu, Dec 12, 2024 at 7:56 PM Benjamin Peterson <benjamin@engflow.com> wrote:
> > > >
> > > > The return value of this function was meaningless and therefore ignored by
> > > > the caller. Remove it.
>
> In fact, I don't see the reason to merge this, as it's the convention to
> return the number of characters it prints.  Yes, it's not used but not
> much reason to remove it.

The main reason to remove the return value is that it has no useful
interpretation and is therefore confusing. To wit, the function
returns two times the number of bytes it prints.

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

* Re: [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
  2025-01-22 19:19       ` Benjamin Peterson
@ 2025-01-23 23:48         ` Namhyung Kim
  2025-01-24 17:37           ` Benjamin Peterson
  0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2025-01-23 23:48 UTC (permalink / raw)
  To: Benjamin Peterson
  Cc: Howard Chu, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, linux-perf-users, linux-kernel

On Wed, Jan 22, 2025 at 11:19:05AM -0800, Benjamin Peterson wrote:
> On Wed, Jan 22, 2025 at 11:08 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Hello,
> >
> > On Tue, Jan 21, 2025 at 07:01:53PM -0800, Howard Chu wrote:
> > > Hello fellow maintainers,
> > >
> > > Just a slight ping.
> >
> > Thanks for the reminder.
> 
> Thanks for taking a look.
> 
> >
> > >
> > > Thanks,
> > > Howard
> > >
> > > On Fri, Dec 13, 2024 at 10:06 AM Howard Chu <howardchu95@gmail.com> wrote:
> > > >
> > > > Hello Benjamin,
> > > >
> > > > On Thu, Dec 12, 2024 at 7:56 PM Benjamin Peterson <benjamin@engflow.com> wrote:
> > > > >
> > > > > The return value of this function was meaningless and therefore ignored by
> > > > > the caller. Remove it.
> >
> > In fact, I don't see the reason to merge this, as it's the convention to
> > return the number of characters it prints.  Yes, it's not used but not
> > much reason to remove it.
> 
> The main reason to remove the return value is that it has no useful
> interpretation and is therefore confusing. To wit, the function
> returns two times the number of bytes it prints.

Oh, ok.  Then please just fix it to return the correct number.

Thanks,
Namhyung


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

* Re: [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields
  2025-01-23 23:48         ` Namhyung Kim
@ 2025-01-24 17:37           ` Benjamin Peterson
  0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Peterson @ 2025-01-24 17:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Howard Chu, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, linux-perf-users, linux-kernel

On Thu, Jan 23, 2025 at 3:48 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Wed, Jan 22, 2025 at 11:19:05AM -0800, Benjamin Peterson wrote:
> > On Wed, Jan 22, 2025 at 11:08 AM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > Hello,
> > >
> > > On Tue, Jan 21, 2025 at 07:01:53PM -0800, Howard Chu wrote:
> > > > Hello fellow maintainers,
> > > >
> > > > Just a slight ping.
> > >
> > > Thanks for the reminder.
> >
> > Thanks for taking a look.
> >
> > >
> > > >
> > > > Thanks,
> > > > Howard
> > > >
> > > > On Fri, Dec 13, 2024 at 10:06 AM Howard Chu <howardchu95@gmail.com> wrote:
> > > > >
> > > > > Hello Benjamin,
> > > > >
> > > > > On Thu, Dec 12, 2024 at 7:56 PM Benjamin Peterson <benjamin@engflow.com> wrote:
> > > > > >
> > > > > > The return value of this function was meaningless and therefore ignored by
> > > > > > the caller. Remove it.
> > >
> > > In fact, I don't see the reason to merge this, as it's the convention to
> > > return the number of characters it prints.  Yes, it's not used but not
> > > much reason to remove it.
> >
> > The main reason to remove the return value is that it has no useful
> > interpretation and is therefore confusing. To wit, the function
> > returns two times the number of bytes it prints.
>
> Oh, ok.  Then please just fix it to return the correct number.

Alright, I've submitted v2 that simply propagates the return value of fprintf.

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

end of thread, other threads:[~2025-01-24 17:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13  3:56 [PATCH] perf trace: Remove return value of trace__fprintf_tp_fields Benjamin Peterson
2024-12-13 18:06 ` Howard Chu
2025-01-22  3:01   ` Howard Chu
2025-01-22 19:08     ` Namhyung Kim
2025-01-22 19:19       ` Benjamin Peterson
2025-01-23 23:48         ` Namhyung Kim
2025-01-24 17:37           ` Benjamin Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).