linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] perf list: Fix the --no-desc option
@ 2024-05-13 21:20 Breno Leitao
  2024-05-14  2:51 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2024-05-13 21:20 UTC (permalink / raw)
  To: irogers, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter
  Cc: leit, open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM

Currently, the --no-desc option in perf list isn't functioning as
intended.

This issue arises from the overwriting of struct option->desc with the
opposite value of struct option->long_desc. Consequently, whatever
parse_options() returns at struct option->desc gets overridden later,
rendering the --desc or --no-desc arguments ineffective.

To resolve this, set ->desc as true by default and allow parse_options()
to adjust it accordingly. This adjustment will fix the --no-desc
option while preserving the functionality of the other parameters.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
Changelog:

v2:
	* Do not print desc if long_desc is being printed, as identified
	  by Ian Rogers.
---
 tools/perf/builtin-list.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index e27a1b1288c2..16186acdd301 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -149,7 +149,11 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
 	} else
 		fputc('\n', fp);
 
-	if (desc && print_state->desc) {
+	if (long_desc && print_state->long_desc) {
+		fprintf(fp, "%*s", 8, "[");
+		wordwrap(fp, long_desc, 8, pager_get_columns(), 0);
+		fprintf(fp, "]\n");
+	} else if (desc && print_state->desc) {
 		char *desc_with_unit = NULL;
 		int desc_len = -1;
 
@@ -165,12 +169,6 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
 		fprintf(fp, "]\n");
 		free(desc_with_unit);
 	}
-	long_desc = long_desc ?: desc;
-	if (long_desc && print_state->long_desc) {
-		fprintf(fp, "%*s", 8, "[");
-		wordwrap(fp, long_desc, 8, pager_get_columns(), 0);
-		fprintf(fp, "]\n");
-	}
 
 	if (print_state->detailed && encoding_desc) {
 		fprintf(fp, "%*s", 8, "");
@@ -484,6 +482,7 @@ int cmd_list(int argc, const char **argv)
 	int i, ret = 0;
 	struct print_state default_ps = {
 		.fp = stdout,
+		.desc = true,
 	};
 	struct print_state json_ps = {
 		.fp = stdout,
@@ -556,7 +555,6 @@ int cmd_list(int argc, const char **argv)
 		};
 		ps = &json_ps;
 	} else {
-		default_ps.desc = !default_ps.long_desc;
 		default_ps.last_topic = strdup("");
 		assert(default_ps.last_topic);
 		default_ps.visited_metrics = strlist__new(NULL, NULL);
-- 
2.43.0


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

* Re: [PATCH v2] perf list: Fix the --no-desc option
  2024-05-13 21:20 [PATCH v2] perf list: Fix the --no-desc option Breno Leitao
@ 2024-05-14  2:51 ` Ian Rogers
  2024-05-16 13:08   ` Breno Leitao
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2024-05-14  2:51 UTC (permalink / raw)
  To: Breno Leitao
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, leit, open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM

On Mon, May 13, 2024 at 2:20 PM Breno Leitao <leitao@debian.org> wrote:
>
> Currently, the --no-desc option in perf list isn't functioning as
> intended.
>
> This issue arises from the overwriting of struct option->desc with the
> opposite value of struct option->long_desc. Consequently, whatever
> parse_options() returns at struct option->desc gets overridden later,
> rendering the --desc or --no-desc arguments ineffective.
>
> To resolve this, set ->desc as true by default and allow parse_options()
> to adjust it accordingly. This adjustment will fix the --no-desc
> option while preserving the functionality of the other parameters.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> Changelog:
>
> v2:
>         * Do not print desc if long_desc is being printed, as identified
>           by Ian Rogers.
> ---
>  tools/perf/builtin-list.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index e27a1b1288c2..16186acdd301 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -149,7 +149,11 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
>         } else
>                 fputc('\n', fp);
>
> -       if (desc && print_state->desc) {
> +       if (long_desc && print_state->long_desc) {
> +               fprintf(fp, "%*s", 8, "[");
> +               wordwrap(fp, long_desc, 8, pager_get_columns(), 0);
> +               fprintf(fp, "]\n");
> +       } else if (desc && print_state->desc) {

I think we need the same fix also in default_print_metric, on an Intel
Tigerlake I see the description repeated like:
```
$ perf list --long-desc
...
Bad:
  tma_info_bad_spec_branch_misprediction_cost
       [Branch Misprediction Cost: Fraction of TMA slots wasted per
non-speculative branch
        misprediction (retired JEClear)]
       [Branch Misprediction Cost: Fraction of TMA slots wasted per
non-speculative branch
        misprediction (retired JEClear). Related metrics:
tma_branch_mispredicts,
        tma_info_bottleneck_mispredictions,tma_mispredicts_resteers]
  tma_info_bad_spec_ipmisp_cond_ntaken
       [Instructions per retired mispredicts for conditional non-taken
branches (lower number
        means higher occurrence rate)]
...
```

Thanks,
Ian

>                 char *desc_with_unit = NULL;
>                 int desc_len = -1;
>
> @@ -165,12 +169,6 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
>                 fprintf(fp, "]\n");
>                 free(desc_with_unit);
>         }
> -       long_desc = long_desc ?: desc;
> -       if (long_desc && print_state->long_desc) {
> -               fprintf(fp, "%*s", 8, "[");
> -               wordwrap(fp, long_desc, 8, pager_get_columns(), 0);
> -               fprintf(fp, "]\n");
> -       }
>
>         if (print_state->detailed && encoding_desc) {
>                 fprintf(fp, "%*s", 8, "");
> @@ -484,6 +482,7 @@ int cmd_list(int argc, const char **argv)
>         int i, ret = 0;
>         struct print_state default_ps = {
>                 .fp = stdout,
> +               .desc = true,
>         };
>         struct print_state json_ps = {
>                 .fp = stdout,
> @@ -556,7 +555,6 @@ int cmd_list(int argc, const char **argv)
>                 };
>                 ps = &json_ps;
>         } else {
> -               default_ps.desc = !default_ps.long_desc;
>                 default_ps.last_topic = strdup("");
>                 assert(default_ps.last_topic);
>                 default_ps.visited_metrics = strlist__new(NULL, NULL);
> --
> 2.43.0
>

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

* Re: [PATCH v2] perf list: Fix the --no-desc option
  2024-05-14  2:51 ` Ian Rogers
@ 2024-05-16 13:08   ` Breno Leitao
  0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2024-05-16 13:08 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, leit, open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM

On Mon, May 13, 2024 at 07:51:12PM -0700, Ian Rogers wrote:
> On Mon, May 13, 2024 at 2:20 PM Breno Leitao <leitao@debian.org> wrote:
> >
> > Currently, the --no-desc option in perf list isn't functioning as
> > intended.
> >
> > This issue arises from the overwriting of struct option->desc with the
> > opposite value of struct option->long_desc. Consequently, whatever
> > parse_options() returns at struct option->desc gets overridden later,
> > rendering the --desc or --no-desc arguments ineffective.
> >
> > To resolve this, set ->desc as true by default and allow parse_options()
> > to adjust it accordingly. This adjustment will fix the --no-desc
> > option while preserving the functionality of the other parameters.
> >
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> > Changelog:
> >
> > v2:
> >         * Do not print desc if long_desc is being printed, as identified
> >           by Ian Rogers.
> > ---
> >  tools/perf/builtin-list.c | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> > index e27a1b1288c2..16186acdd301 100644
> > --- a/tools/perf/builtin-list.c
> > +++ b/tools/perf/builtin-list.c
> > @@ -149,7 +149,11 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
> >         } else
> >                 fputc('\n', fp);
> >
> > -       if (desc && print_state->desc) {
> > +       if (long_desc && print_state->long_desc) {
> > +               fprintf(fp, "%*s", 8, "[");
> > +               wordwrap(fp, long_desc, 8, pager_get_columns(), 0);
> > +               fprintf(fp, "]\n");
> > +       } else if (desc && print_state->desc) {
> 
> I think we need the same fix also in default_print_metric, on an Intel
> Tigerlake I see the description repeated like:

Good point. We also need the same for json_print_event().

Thanks for the review.

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

end of thread, other threads:[~2024-05-16 13:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-13 21:20 [PATCH v2] perf list: Fix the --no-desc option Breno Leitao
2024-05-14  2:51 ` Ian Rogers
2024-05-16 13:08   ` Breno Leitao

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).