2023-09-05 17:09:57

by James Clark

[permalink] [raw]
Subject: Re: [PATCH v1 1/6] perf parse-events: Fixes relating to no_value terms



On 02/09/2023 00:39, Ian Rogers wrote:
> A term may have no value in which case it is assumed to have a value
> of 1. It doesn't just apply to alias/event terms so change the
> parse_events_term__to_strbuf assert.
>
> Commit 99e7138eb789 ("perf tools: Fail on using multiple bits long
> terms without value") made it so that no_value terms could only be for
> a single bit. Prior to commit 64199ae4b8a3 ("perf parse-events: Fix
> propagation of term's no_value when cloning") this missed a test case
> where config1 had no_value.
>
> Fixes: 64199ae4b8a3 ("perf parse-events: Fix propagation of term's no_value when cloning")
> Signed-off-by: Ian Rogers <[email protected]>

For the whole set:

Reviewed-by: James Clark <[email protected]>

> ---
> tools/perf/tests/parse-events.c | 2 +-
> tools/perf/util/parse-events.c | 2 +-
> tools/perf/util/parse-events.h | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> index d86076d575ed..d47f1f871164 100644
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -2170,7 +2170,7 @@ static const struct evlist_test test__events[] = {
>
> static const struct evlist_test test__events_pmu[] = {
> {
> - .name = "cpu/config=10,config1,config2=3,period=1000/u",
> + .name = "cpu/config=10,config1=1,config2=3,period=1000/u",
> .valid = test__pmu_cpu_valid,
> .check = test__checkevent_pmu,
> /* 0 */
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 68fe2c4ff49f..65608a3cba81 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -2607,7 +2607,7 @@ int parse_events_term__to_strbuf(struct list_head *term_list, struct strbuf *sb)
>
> if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
> if (term->no_value) {
> - assert(term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
> + assert(term->val.num == 1);
> ret = strbuf_addf(sb, "%s", term->config);
> } else
> ret = strbuf_addf(sb, "%s=%#"PRIx64, term->config, term->val.num);
> diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
> index 855b0725c5d4..594e5d2dc67f 100644
> --- a/tools/perf/util/parse-events.h
> +++ b/tools/perf/util/parse-events.h
> @@ -124,8 +124,8 @@ struct parse_events_term {
> */
> bool weak;
> /**
> - * @no_value: Is there no value. TODO: this should really be part of
> - * type_val.
> + * @no_value: Is there no value. If a numeric term has no value then the
> + * value is assumed to be 1. An event name also has no value.
> */
> bool no_value;
> };


2023-09-06 18:15:09

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v1 1/6] perf parse-events: Fixes relating to no_value terms

Em Tue, Sep 05, 2023 at 10:39:38AM +0100, James Clark escreveu:
>
>
> On 02/09/2023 00:39, Ian Rogers wrote:
> > A term may have no value in which case it is assumed to have a value
> > of 1. It doesn't just apply to alias/event terms so change the
> > parse_events_term__to_strbuf assert.
> >
> > Commit 99e7138eb789 ("perf tools: Fail on using multiple bits long
> > terms without value") made it so that no_value terms could only be for
> > a single bit. Prior to commit 64199ae4b8a3 ("perf parse-events: Fix
> > propagation of term's no_value when cloning") this missed a test case
> > where config1 had no_value.
> >
> > Fixes: 64199ae4b8a3 ("perf parse-events: Fix propagation of term's no_value when cloning")
> > Signed-off-by: Ian Rogers <[email protected]>
>
> For the whole set:
>
> Reviewed-by: James Clark <[email protected]>

Thanks, applied.

- Arnaldo


> > ---
> > tools/perf/tests/parse-events.c | 2 +-
> > tools/perf/util/parse-events.c | 2 +-
> > tools/perf/util/parse-events.h | 4 ++--
> > 3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> > index d86076d575ed..d47f1f871164 100644
> > --- a/tools/perf/tests/parse-events.c
> > +++ b/tools/perf/tests/parse-events.c
> > @@ -2170,7 +2170,7 @@ static const struct evlist_test test__events[] = {
> >
> > static const struct evlist_test test__events_pmu[] = {
> > {
> > - .name = "cpu/config=10,config1,config2=3,period=1000/u",
> > + .name = "cpu/config=10,config1=1,config2=3,period=1000/u",
> > .valid = test__pmu_cpu_valid,
> > .check = test__checkevent_pmu,
> > /* 0 */
> > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > index 68fe2c4ff49f..65608a3cba81 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -2607,7 +2607,7 @@ int parse_events_term__to_strbuf(struct list_head *term_list, struct strbuf *sb)
> >
> > if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
> > if (term->no_value) {
> > - assert(term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
> > + assert(term->val.num == 1);
> > ret = strbuf_addf(sb, "%s", term->config);
> > } else
> > ret = strbuf_addf(sb, "%s=%#"PRIx64, term->config, term->val.num);
> > diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
> > index 855b0725c5d4..594e5d2dc67f 100644
> > --- a/tools/perf/util/parse-events.h
> > +++ b/tools/perf/util/parse-events.h
> > @@ -124,8 +124,8 @@ struct parse_events_term {
> > */
> > bool weak;
> > /**
> > - * @no_value: Is there no value. TODO: this should really be part of
> > - * type_val.
> > + * @no_value: Is there no value. If a numeric term has no value then the
> > + * value is assumed to be 1. An event name also has no value.
> > */
> > bool no_value;
> > };

--

- Arnaldo