Skip to content

Commit 9ea150a

Browse files
captain5050acmel
authored andcommitted
perf parse-events: Fixes relating to no_value terms
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 99e7138 ("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 64199ae ("perf parse-events: Fix propagation of term's no_value when cloning") this missed a test case where config1 had no_value. Fixes: 64199ae ("perf parse-events: Fix propagation of term's no_value when cloning") Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rob Herring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 64199ae commit 9ea150a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

tools/perf/tests/parse-events.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ static const struct evlist_test test__events[] = {
21702170

21712171
static const struct evlist_test test__events_pmu[] = {
21722172
{
2173-
.name = "cpu/config=10,config1,config2=3,period=1000/u",
2173+
.name = "cpu/config=10,config1=1,config2=3,period=1000/u",
21742174
.valid = test__pmu_cpu_valid,
21752175
.check = test__checkevent_pmu,
21762176
/* 0 */

tools/perf/util/parse-events.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,7 @@ int parse_events_term__to_strbuf(struct list_head *term_list, struct strbuf *sb)
26072607

26082608
if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
26092609
if (term->no_value) {
2610-
assert(term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
2610+
assert(term->val.num == 1);
26112611
ret = strbuf_addf(sb, "%s", term->config);
26122612
} else
26132613
ret = strbuf_addf(sb, "%s=%#"PRIx64, term->config, term->val.num);

tools/perf/util/parse-events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ struct parse_events_term {
124124
*/
125125
bool weak;
126126
/**
127-
* @no_value: Is there no value. TODO: this should really be part of
128-
* type_val.
127+
* @no_value: Is there no value. If a numeric term has no value then the
128+
* value is assumed to be 1. An event name also has no value.
129129
*/
130130
bool no_value;
131131
};

0 commit comments

Comments
 (0)