Messages in this thread | | | Subject | Re: [PATCH v5 12/26] perf parse-events: Support event inside hybrid pmu | From | "Jin, Yao" <> | Date | Mon, 26 Apr 2021 08:56:28 +0800 |
| |
Hi Jiri,
On 4/26/2021 12:17 AM, Jiri Olsa wrote: > On Fri, Apr 23, 2021 at 01:35:27PM +0800, Jin Yao wrote: > > SNIP > >> +static int parse_events__inside_hybrid_pmu(struct parse_events_state *parse_state, >> + struct list_head *list, char *name, >> + struct list_head *head_config) >> +{ >> + struct parse_events_term *term; >> + int ret = -1; >> + >> + if (parse_state->fake_pmu || !head_config || list_empty(head_config) || >> + !perf_pmu__is_hybrid(name)) { >> + return -1; >> + } >> + >> + /* >> + * More than one term in list. >> + */ >> + if (head_config->next && head_config->next->next != head_config) >> + return -1; >> + >> + term = list_first_entry(head_config, struct parse_events_term, list); >> + if (term && term->config && strcmp(term->config, "event")) { > > so 'event' is set only for HW events, I don't see it being for other > types.. also should the check be !strcmp ? >
For some HW events, such as branch-instructions, branch-misses and other HW events which are defined under /sys/devices/cpu_core/events, the term->config is "event". For these events, we don't need to do the second parsing. So I just use 'strcmp(term->config, "event")' to avoid the second parsing.
If we check with !strcmp, the second parsing will be executed but the result after parsing should be empty.
> also please add some tests for cache events with pmu syntax >
OK, I will add new test case for that.
Thanks Jin Yao
> jirka > >> + ret = parse_events__with_hybrid_pmu(parse_state, term->config, >> + name, list); >> + } >> + >> + return ret; >> +} >> + >> int parse_events_add_pmu(struct parse_events_state *parse_state, >> struct list_head *list, char *name, >> struct list_head *head_config, >> @@ -1567,6 +1598,11 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, >> if (pmu->default_config && get_config_chgs(pmu, head_config, &config_terms)) >> return -ENOMEM; >> >> + if (!parse_events__inside_hybrid_pmu(parse_state, list, name, >> + head_config)) { >> + return 0; >> + } >> + >> if (!parse_state->fake_pmu && perf_pmu__config(pmu, &attr, head_config, parse_state->error)) { >> struct evsel_config_term *pos, *tmp; >> >> @@ -2183,6 +2219,33 @@ int parse_events_terms(struct list_head *terms, const char *str) >> return ret; >> } >> >> +static int parse_events__with_hybrid_pmu(struct parse_events_state *parse_state, >> + const char *str, char *pmu_name, >> + struct list_head *list) >> +{ >> + struct parse_events_state ps = { >> + .list = LIST_HEAD_INIT(ps.list), >> + .stoken = PE_START_EVENTS, >> + .hybrid_pmu_name = pmu_name, >> + .idx = parse_state->idx, >> + }; >> + int ret; >> + >> + ret = parse_events__scanner(str, &ps); >> + perf_pmu__parse_cleanup(); >> + >> + if (!ret) { >> + if (!list_empty(&ps.list)) { >> + list_splice(&ps.list, list); >> + parse_state->idx = ps.idx; >> + return 0; >> + } else >> + return -1; >> + } >> + >> + return ret; >> +} >> + >> int __parse_events(struct evlist *evlist, const char *str, >> struct parse_events_error *err, struct perf_pmu *fake_pmu) >> { >> -- >> 2.17.1 >> >
| |