[PATCH] perf list: fix arguments order issue for events printing

Jean-Philippe Romain posted 1 patch 1 year, 1 month ago
[PATCH] perf list: fix arguments order issue for events printing
Posted by Jean-Philippe Romain 1 year, 1 month ago
Misalignment of callbacks with print_event:
- pmu_name and topic arguments to reverse

Signed-off-by: Jean-Philippe ROMAIN <jean-philippe.romain@foss.st.com>

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 65b8cba324be..c5331721dfee 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -112,7 +112,7 @@ static void wordwrap(FILE *fp, const char *s, int start, int max, int corr)
 	}
 }
 
-static void default_print_event(void *ps, const char *pmu_name, const char *topic,
+static void default_print_event(void *ps, const char *topic, const char *pmu_name,
 				const char *event_name, const char *event_alias,
 				const char *scale_unit __maybe_unused,
 				bool deprecated, const char *event_type_desc,
@@ -353,7 +353,7 @@ static void fix_escape_fprintf(FILE *fp, struct strbuf *buf, const char *fmt, ..
 	fputs(buf->buf, fp);
 }
 
-static void json_print_event(void *ps, const char *pmu_name, const char *topic,
+static void json_print_event(void *ps, const char *topic, const char *pmu_name,
 			     const char *event_name, const char *event_alias,
 			     const char *scale_unit,
 			     bool deprecated, const char *event_type_desc,
-- 
2.34.1
Re: [PATCH] perf list: fix arguments order issue for events printing
Posted by Ian Rogers 1 year, 1 month ago
On Fri, Nov 8, 2024 at 12:31 AM Jean-Philippe Romain
<jean-philippe.romain@foss.st.com> wrote:
>
> Misalignment of callbacks with print_event:
> - pmu_name and topic arguments to reverse
>
> Signed-off-by: Jean-Philippe ROMAIN <jean-philippe.romain@foss.st.com>
>
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 65b8cba324be..c5331721dfee 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -112,7 +112,7 @@ static void wordwrap(FILE *fp, const char *s, int start, int max, int corr)
>         }
>  }
>
> -static void default_print_event(void *ps, const char *pmu_name, const char *topic,
> +static void default_print_event(void *ps, const char *topic, const char *pmu_name,

So it looks like the call sites are doing this wrong too:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/pmus.c?h=perf-tools-next#n504
```
...
print_cb->print_event(print_state,
aliases[j].pmu_name,
aliases[j].topic,
...
```
I'll review the call-sites and send a bigger change.

Thanks,
Ian