Re: [PATCH v2] perf list: Fix the --no-desc option

From: Breno Leitao
Date: Thu May 16 2024 - 09:09:45 EST


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@xxxxxxxxxx> 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@xxxxxxxxxx>
> > ---
> > 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.