Commit 0d3f0e6f authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Introduce 'struct parse_events_terms'

parse_events_terms() existed in function names but was passed a
'struct list_head'.

As many parse_events functions take an evsel_config list as well as a
parse_event_term list, and the naming head_terms and head_config is
inconsistent, there's a potential to switch the lists and get errors.

Introduce a 'struct parse_events_terms', that just wraps a list_head, to
avoid this. Add the regular init/exit functions and transition the code
to use them.
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230901233949.2930562-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 727adeed
...@@ -64,28 +64,23 @@ static int intel_pt_parse_terms_with_default(struct perf_pmu *pmu, ...@@ -64,28 +64,23 @@ static int intel_pt_parse_terms_with_default(struct perf_pmu *pmu,
const char *str, const char *str,
u64 *config) u64 *config)
{ {
struct list_head *terms; struct parse_events_terms terms;
struct perf_event_attr attr = { .size = 0, }; struct perf_event_attr attr = { .size = 0, };
int err; int err;
terms = malloc(sizeof(struct list_head)); parse_events_terms__init(&terms);
if (!terms) err = parse_events_terms(&terms, str, /*input=*/ NULL);
return -ENOMEM;
INIT_LIST_HEAD(terms);
err = parse_events_terms(terms, str, /*input=*/ NULL);
if (err) if (err)
goto out_free; goto out_free;
attr.config = *config; attr.config = *config;
err = perf_pmu__config_terms(pmu, &attr, terms, /*zero=*/true, /*err=*/NULL); err = perf_pmu__config_terms(pmu, &attr, &terms, /*zero=*/true, /*err=*/NULL);
if (err) if (err)
goto out_free; goto out_free;
*config = attr.config; *config = attr.config;
out_free: out_free:
parse_events_terms__delete(terms); parse_events_terms__exit(&terms);
return err; return err;
} }
......
...@@ -771,12 +771,12 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist) ...@@ -771,12 +771,12 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist)
return TEST_OK; return TEST_OK;
} }
static int test__checkterms_simple(struct list_head *terms) static int test__checkterms_simple(struct parse_events_terms *terms)
{ {
struct parse_events_term *term; struct parse_events_term *term;
/* config=10 */ /* config=10 */
term = list_entry(terms->next, struct parse_events_term, list); term = list_entry(terms->terms.next, struct parse_events_term, list);
TEST_ASSERT_VAL("wrong type term", TEST_ASSERT_VAL("wrong type term",
term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
TEST_ASSERT_VAL("wrong type val", TEST_ASSERT_VAL("wrong type val",
...@@ -2363,7 +2363,7 @@ static const struct evlist_test test__events_pmu[] = { ...@@ -2363,7 +2363,7 @@ static const struct evlist_test test__events_pmu[] = {
struct terms_test { struct terms_test {
const char *str; const char *str;
int (*check)(struct list_head *terms); int (*check)(struct parse_events_terms *terms);
}; };
static const struct terms_test test__terms[] = { static const struct terms_test test__terms[] = {
...@@ -2467,11 +2467,11 @@ static int test__events2(struct test_suite *test __maybe_unused, int subtest __m ...@@ -2467,11 +2467,11 @@ static int test__events2(struct test_suite *test __maybe_unused, int subtest __m
static int test_term(const struct terms_test *t) static int test_term(const struct terms_test *t)
{ {
struct list_head terms; struct parse_events_terms terms;
int ret; int ret;
INIT_LIST_HEAD(&terms);
parse_events_terms__init(&terms);
ret = parse_events_terms(&terms, t->str, /*input=*/ NULL); ret = parse_events_terms(&terms, t->str, /*input=*/ NULL);
if (ret) { if (ret) {
pr_debug("failed to parse terms '%s', err %d\n", pr_debug("failed to parse terms '%s', err %d\n",
...@@ -2480,7 +2480,7 @@ static int test_term(const struct terms_test *t) ...@@ -2480,7 +2480,7 @@ static int test_term(const struct terms_test *t)
} }
ret = t->check(&terms); ret = t->check(&terms);
parse_events_terms__purge(&terms); parse_events_terms__exit(&terms);
return ret; return ret;
} }
......
...@@ -128,30 +128,35 @@ static int test_format_dir_put(char *dir) ...@@ -128,30 +128,35 @@ static int test_format_dir_put(char *dir)
return system(buf); return system(buf);
} }
static struct list_head *test_terms_list(void) static void add_test_terms(struct parse_events_terms *terms)
{ {
static LIST_HEAD(terms);
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(test_terms); i++) for (i = 0; i < ARRAY_SIZE(test_terms); i++) {
list_add_tail(&test_terms[i].list, &terms); struct parse_events_term *clone;
return &terms; parse_events_term__clone(&clone, &test_terms[i]);
list_add_tail(&clone->list, &terms->terms);
}
} }
static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe_unused) static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{ {
char dir[PATH_MAX]; char dir[PATH_MAX];
char *format; char *format;
struct list_head *terms = test_terms_list(); struct parse_events_terms terms;
struct perf_event_attr attr; struct perf_event_attr attr;
struct perf_pmu *pmu; struct perf_pmu *pmu;
int fd; int fd;
int ret; int ret;
parse_events_terms__init(&terms);
add_test_terms(&terms);
pmu = zalloc(sizeof(*pmu)); pmu = zalloc(sizeof(*pmu));
if (!pmu) if (!pmu) {
parse_events_terms__exit(&terms);
return -ENOMEM; return -ENOMEM;
}
INIT_LIST_HEAD(&pmu->format); INIT_LIST_HEAD(&pmu->format);
INIT_LIST_HEAD(&pmu->aliases); INIT_LIST_HEAD(&pmu->aliases);
...@@ -159,6 +164,7 @@ static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe ...@@ -159,6 +164,7 @@ static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe
format = test_format_dir_get(dir, sizeof(dir)); format = test_format_dir_get(dir, sizeof(dir));
if (!format) { if (!format) {
free(pmu); free(pmu);
parse_events_terms__exit(&terms);
return -EINVAL; return -EINVAL;
} }
...@@ -175,7 +181,7 @@ static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe ...@@ -175,7 +181,7 @@ static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe
if (ret) if (ret)
goto out; goto out;
ret = perf_pmu__config_terms(pmu, &attr, terms, /*zero=*/false, /*err=*/NULL); ret = perf_pmu__config_terms(pmu, &attr, &terms, /*zero=*/false, /*err=*/NULL);
if (ret) if (ret)
goto out; goto out;
...@@ -191,6 +197,7 @@ static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe ...@@ -191,6 +197,7 @@ static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe
out: out:
test_format_dir_put(format); test_format_dir_put(format);
perf_pmu__delete(pmu); perf_pmu__delete(pmu);
parse_events_terms__exit(&terms);
return ret; return ret;
} }
......
This diff is collapsed.
...@@ -44,7 +44,6 @@ static inline int parse_events(struct evlist *evlist, const char *str, ...@@ -44,7 +44,6 @@ static inline int parse_events(struct evlist *evlist, const char *str,
int parse_event(struct evlist *evlist, const char *str); int parse_event(struct evlist *evlist, const char *str);
int parse_events_terms(struct list_head *terms, const char *str, FILE *input);
int parse_filter(const struct option *opt, const char *str, int unset); int parse_filter(const struct option *opt, const char *str, int unset);
int exclude_perf(const struct option *opt, const char *arg, int unset); int exclude_perf(const struct option *opt, const char *arg, int unset);
...@@ -140,6 +139,11 @@ struct parse_events_error { ...@@ -140,6 +139,11 @@ struct parse_events_error {
char *first_help; char *first_help;
}; };
/* A wrapper around a list of terms for the sake of better type safety. */
struct parse_events_terms {
struct list_head terms;
};
struct parse_events_state { struct parse_events_state {
/* The list parsed events are placed on. */ /* The list parsed events are placed on. */
struct list_head list; struct list_head list;
...@@ -148,7 +152,7 @@ struct parse_events_state { ...@@ -148,7 +152,7 @@ struct parse_events_state {
/* Error information. */ /* Error information. */
struct parse_events_error *error; struct parse_events_error *error;
/* Holds returned terms for term parsing. */ /* Holds returned terms for term parsing. */
struct list_head *terms; struct parse_events_terms *terms;
/* Start token. */ /* Start token. */
int stoken; int stoken;
/* Special fake PMU marker for testing. */ /* Special fake PMU marker for testing. */
...@@ -181,35 +185,38 @@ int parse_events_term__term(struct parse_events_term **term, ...@@ -181,35 +185,38 @@ int parse_events_term__term(struct parse_events_term **term,
int parse_events_term__clone(struct parse_events_term **new, int parse_events_term__clone(struct parse_events_term **new,
struct parse_events_term *term); struct parse_events_term *term);
void parse_events_term__delete(struct parse_events_term *term); void parse_events_term__delete(struct parse_events_term *term);
void parse_events_terms__delete(struct list_head *terms);
void parse_events_terms__purge(struct list_head *terms); void parse_events_terms__delete(struct parse_events_terms *terms);
int parse_events_term__to_strbuf(struct list_head *term_list, struct strbuf *sb); void parse_events_terms__init(struct parse_events_terms *terms);
void parse_events_terms__exit(struct parse_events_terms *terms);
int parse_events_terms(struct parse_events_terms *terms, const char *str, FILE *input);
int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, struct strbuf *sb);
int parse_events__modifier_event(struct list_head *list, char *str, bool add); int parse_events__modifier_event(struct list_head *list, char *str, bool add);
int parse_events__modifier_group(struct list_head *list, char *event_mod); int parse_events__modifier_group(struct list_head *list, char *event_mod);
int parse_events_name(struct list_head *list, const char *name); int parse_events_name(struct list_head *list, const char *name);
int parse_events_add_tracepoint(struct list_head *list, int *idx, int parse_events_add_tracepoint(struct list_head *list, int *idx,
const char *sys, const char *event, const char *sys, const char *event,
struct parse_events_error *error, struct parse_events_error *error,
struct list_head *head_config, void *loc); struct parse_events_terms *head_config, void *loc);
int parse_events_add_numeric(struct parse_events_state *parse_state, int parse_events_add_numeric(struct parse_events_state *parse_state,
struct list_head *list, struct list_head *list,
u32 type, u64 config, u32 type, u64 config,
struct list_head *head_config, struct parse_events_terms *head_config,
bool wildcard); bool wildcard);
int parse_events_add_tool(struct parse_events_state *parse_state, int parse_events_add_tool(struct parse_events_state *parse_state,
struct list_head *list, struct list_head *list,
int tool_event); int tool_event);
int parse_events_add_cache(struct list_head *list, int *idx, const char *name, int parse_events_add_cache(struct list_head *list, int *idx, const char *name,
struct parse_events_state *parse_state, struct parse_events_state *parse_state,
struct list_head *head_config); struct parse_events_terms *head_config);
int parse_events__decode_legacy_cache(const char *name, int pmu_type, __u64 *config); int parse_events__decode_legacy_cache(const char *name, int pmu_type, __u64 *config);
int parse_events_add_breakpoint(struct parse_events_state *parse_state, int parse_events_add_breakpoint(struct parse_events_state *parse_state,
struct list_head *list, struct list_head *list,
u64 addr, char *type, u64 len, u64 addr, char *type, u64 len,
struct list_head *head_config); struct parse_events_terms *head_config);
int parse_events_add_pmu(struct parse_events_state *parse_state, int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, const char *name, struct list_head *list, const char *name,
const struct list_head *const_head_terms, const struct parse_events_terms *const_parsed_terms,
bool auto_merge_stats, void *loc); bool auto_merge_stats, void *loc);
struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr,
...@@ -218,7 +225,7 @@ struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, ...@@ -218,7 +225,7 @@ struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr,
int parse_events_multi_pmu_add(struct parse_events_state *parse_state, int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
const char *event_name, const char *event_name,
const struct list_head *head_terms, const struct parse_events_terms *const_parsed_terms,
struct list_head **listp, void *loc); struct list_head **listp, void *loc);
void parse_events__set_leader(char *name, struct list_head *list); void parse_events__set_leader(char *name, struct list_head *list);
......
...@@ -113,7 +113,7 @@ static void free_list_evsel(struct list_head* list_evsel) ...@@ -113,7 +113,7 @@ static void free_list_evsel(struct list_head* list_evsel)
u64 num; u64 num;
enum parse_events__term_type term_type; enum parse_events__term_type term_type;
struct list_head *list_evsel; struct list_head *list_evsel;
struct list_head *list_terms; struct parse_events_terms *list_terms;
struct parse_events_term *term; struct parse_events_term *term;
struct tracepoint_name { struct tracepoint_name {
char *sys; char *sys;
...@@ -644,26 +644,26 @@ start_terms: event_config ...@@ -644,26 +644,26 @@ start_terms: event_config
event_config: event_config:
event_config ',' event_term event_config ',' event_term
{ {
struct list_head *head = $1; struct parse_events_terms *head = $1;
struct parse_events_term *term = $3; struct parse_events_term *term = $3;
if (!head) { if (!head) {
parse_events_term__delete(term); parse_events_term__delete(term);
YYABORT; YYABORT;
} }
list_add_tail(&term->list, head); list_add_tail(&term->list, &head->terms);
$$ = $1; $$ = $1;
} }
| |
event_term event_term
{ {
struct list_head *head = malloc(sizeof(*head)); struct parse_events_terms *head = malloc(sizeof(*head));
struct parse_events_term *term = $1; struct parse_events_term *term = $1;
if (!head) if (!head)
YYNOMEM; YYNOMEM;
INIT_LIST_HEAD(head); parse_events_terms__init(head);
list_add_tail(&term->list, head); list_add_tail(&term->list, &head->terms);
$$ = head; $$ = head;
} }
......
...@@ -52,7 +52,7 @@ struct perf_pmu_alias { ...@@ -52,7 +52,7 @@ struct perf_pmu_alias {
*/ */
char *topic; char *topic;
/** @terms: Owned list of the original parsed parameters. */ /** @terms: Owned list of the original parsed parameters. */
struct list_head terms; struct parse_events_terms terms;
/** @list: List element of struct perf_pmu aliases. */ /** @list: List element of struct perf_pmu aliases. */
struct list_head list; struct list_head list;
/** /**
...@@ -404,7 +404,7 @@ static void perf_pmu_free_alias(struct perf_pmu_alias *newalias) ...@@ -404,7 +404,7 @@ static void perf_pmu_free_alias(struct perf_pmu_alias *newalias)
zfree(&newalias->long_desc); zfree(&newalias->long_desc);
zfree(&newalias->topic); zfree(&newalias->topic);
zfree(&newalias->pmu_name); zfree(&newalias->pmu_name);
parse_events_terms__purge(&newalias->terms); parse_events_terms__exit(&newalias->terms);
free(newalias); free(newalias);
} }
...@@ -484,7 +484,7 @@ static int update_alias(const struct pmu_event *pe, ...@@ -484,7 +484,7 @@ static int update_alias(const struct pmu_event *pe,
assign_str(pe->name, "topic", &data->alias->topic, pe->topic); assign_str(pe->name, "topic", &data->alias->topic, pe->topic);
data->alias->per_pkg = pe->perpkg; data->alias->per_pkg = pe->perpkg;
if (pe->event) { if (pe->event) {
parse_events_terms__purge(&data->alias->terms); parse_events_terms__exit(&data->alias->terms);
ret = parse_events_terms(&data->alias->terms, pe->event, /*input=*/NULL); ret = parse_events_terms(&data->alias->terms, pe->event, /*input=*/NULL);
} }
if (!ret && pe->unit) { if (!ret && pe->unit) {
...@@ -524,7 +524,7 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, const char *name, ...@@ -524,7 +524,7 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, const char *name,
if (!alias) if (!alias)
return -ENOMEM; return -ENOMEM;
INIT_LIST_HEAD(&alias->terms); parse_events_terms__init(&alias->terms);
alias->scale = 1.0; alias->scale = 1.0;
alias->unit[0] = '\0'; alias->unit[0] = '\0';
alias->per_pkg = perpkg; alias->per_pkg = perpkg;
...@@ -656,17 +656,17 @@ static int pmu_aliases_parse(struct perf_pmu *pmu) ...@@ -656,17 +656,17 @@ static int pmu_aliases_parse(struct perf_pmu *pmu)
return 0; return 0;
} }
static int pmu_alias_terms(struct perf_pmu_alias *alias, static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms)
struct list_head *terms)
{ {
struct parse_events_term *term, *cloned; struct parse_events_term *term, *cloned;
LIST_HEAD(list); struct parse_events_terms clone_terms;
int ret;
parse_events_terms__init(&clone_terms);
list_for_each_entry(term, &alias->terms.terms, list) {
int ret = parse_events_term__clone(&cloned, term);
list_for_each_entry(term, &alias->terms, list) {
ret = parse_events_term__clone(&cloned, term);
if (ret) { if (ret) {
parse_events_terms__purge(&list); parse_events_terms__exit(&clone_terms);
return ret; return ret;
} }
/* /*
...@@ -674,9 +674,10 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias, ...@@ -674,9 +674,10 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias,
* which we don't want for implicit terms in aliases. * which we don't want for implicit terms in aliases.
*/ */
cloned->weak = true; cloned->weak = true;
list_add_tail(&cloned->list, &list); list_add_tail(&cloned->list, &clone_terms.terms);
} }
list_splice(&list, terms); list_splice_init(&clone_terms.terms, terms);
parse_events_terms__exit(&clone_terms);
return 0; return 0;
} }
...@@ -1188,12 +1189,12 @@ static __u64 pmu_format_max_value(const unsigned long *format) ...@@ -1188,12 +1189,12 @@ static __u64 pmu_format_max_value(const unsigned long *format)
* in a config string) later on in the term list. * in a config string) later on in the term list.
*/ */
static int pmu_resolve_param_term(struct parse_events_term *term, static int pmu_resolve_param_term(struct parse_events_term *term,
struct list_head *head_terms, struct parse_events_terms *head_terms,
__u64 *value) __u64 *value)
{ {
struct parse_events_term *t; struct parse_events_term *t;
list_for_each_entry(t, head_terms, list) { list_for_each_entry(t, &head_terms->terms, list) {
if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM && if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM &&
t->config && !strcmp(t->config, term->config)) { t->config && !strcmp(t->config, term->config)) {
t->used = true; t->used = true;
...@@ -1237,7 +1238,7 @@ static char *pmu_formats_string(struct list_head *formats) ...@@ -1237,7 +1238,7 @@ static char *pmu_formats_string(struct list_head *formats)
static int pmu_config_term(struct perf_pmu *pmu, static int pmu_config_term(struct perf_pmu *pmu,
struct perf_event_attr *attr, struct perf_event_attr *attr,
struct parse_events_term *term, struct parse_events_term *term,
struct list_head *head_terms, struct parse_events_terms *head_terms,
bool zero, struct parse_events_error *err) bool zero, struct parse_events_error *err)
{ {
struct perf_pmu_format *format; struct perf_pmu_format *format;
...@@ -1359,13 +1360,13 @@ static int pmu_config_term(struct perf_pmu *pmu, ...@@ -1359,13 +1360,13 @@ static int pmu_config_term(struct perf_pmu *pmu,
int perf_pmu__config_terms(struct perf_pmu *pmu, int perf_pmu__config_terms(struct perf_pmu *pmu,
struct perf_event_attr *attr, struct perf_event_attr *attr,
struct list_head *head_terms, struct parse_events_terms *terms,
bool zero, struct parse_events_error *err) bool zero, struct parse_events_error *err)
{ {
struct parse_events_term *term; struct parse_events_term *term;
list_for_each_entry(term, head_terms, list) { list_for_each_entry(term, &terms->terms, list) {
if (pmu_config_term(pmu, attr, term, head_terms, zero, err)) if (pmu_config_term(pmu, attr, term, terms, zero, err))
return -EINVAL; return -EINVAL;
} }
...@@ -1378,7 +1379,7 @@ int perf_pmu__config_terms(struct perf_pmu *pmu, ...@@ -1378,7 +1379,7 @@ int perf_pmu__config_terms(struct perf_pmu *pmu,
* 2) pmu format definitions - specified by pmu parameter * 2) pmu format definitions - specified by pmu parameter
*/ */
int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
struct list_head *head_terms, struct parse_events_terms *head_terms,
struct parse_events_error *err) struct parse_events_error *err)
{ {
bool zero = !!pmu->default_config; bool zero = !!pmu->default_config;
...@@ -1472,7 +1473,7 @@ static int check_info_data(struct perf_pmu *pmu, ...@@ -1472,7 +1473,7 @@ static int check_info_data(struct perf_pmu *pmu,
* Find alias in the terms list and replace it with the terms * Find alias in the terms list and replace it with the terms
* defined for the alias * defined for the alias
*/ */
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, int perf_pmu__check_alias(struct perf_pmu *pmu, struct parse_events_terms *head_terms,
struct perf_pmu_info *info, struct parse_events_error *err) struct perf_pmu_info *info, struct parse_events_error *err)
{ {
struct parse_events_term *term, *h; struct parse_events_term *term, *h;
...@@ -1489,7 +1490,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, ...@@ -1489,7 +1490,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
info->scale = 0.0; info->scale = 0.0;
info->snapshot = false; info->snapshot = false;
list_for_each_entry_safe(term, h, head_terms, list) { list_for_each_entry_safe(term, h, &head_terms->terms, list) {
alias = pmu_find_alias(pmu, term); alias = pmu_find_alias(pmu, term);
if (!alias) if (!alias)
continue; continue;
...@@ -1634,7 +1635,7 @@ static char *format_alias(char *buf, int len, const struct perf_pmu *pmu, ...@@ -1634,7 +1635,7 @@ static char *format_alias(char *buf, int len, const struct perf_pmu *pmu,
: (int)strlen(pmu->name); : (int)strlen(pmu->name);
int used = snprintf(buf, len, "%.*s/%s", pmu_name_len, pmu->name, alias->name); int used = snprintf(buf, len, "%.*s/%s", pmu_name_len, pmu->name, alias->name);
list_for_each_entry(term, &alias->terms, list) { list_for_each_entry(term, &alias->terms.terms, list) {
if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
used += snprintf(buf + used, sub_non_neg(len, used), used += snprintf(buf + used, sub_non_neg(len, used),
",%s=%s", term->config, ",%s=%s", term->config,
...@@ -1693,7 +1694,7 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bool skip_duplicate_pmus, ...@@ -1693,7 +1694,7 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bool skip_duplicate_pmus,
info.desc = event->desc; info.desc = event->desc;
info.long_desc = event->long_desc; info.long_desc = event->long_desc;
info.encoding_desc = buf + buf_used; info.encoding_desc = buf + buf_used;
parse_events_term__to_strbuf(&event->terms, &sb); parse_events_terms__to_strbuf(&event->terms, &sb);
buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used, buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used,
"%s/%s/", info.pmu_name, sb.buf) + 1; "%s/%s/", info.pmu_name, sb.buf) + 1;
info.topic = event->topic; info.topic = event->topic;
......
...@@ -191,15 +191,15 @@ typedef int (*pmu_event_callback)(void *state, struct pmu_event_info *info); ...@@ -191,15 +191,15 @@ typedef int (*pmu_event_callback)(void *state, struct pmu_event_info *info);
void pmu_add_sys_aliases(struct perf_pmu *pmu); void pmu_add_sys_aliases(struct perf_pmu *pmu);
int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
struct list_head *head_terms, struct parse_events_terms *head_terms,
struct parse_events_error *error); struct parse_events_error *error);
int perf_pmu__config_terms(struct perf_pmu *pmu, int perf_pmu__config_terms(struct perf_pmu *pmu,
struct perf_event_attr *attr, struct perf_event_attr *attr,
struct list_head *head_terms, struct parse_events_terms *terms,
bool zero, struct parse_events_error *error); bool zero, struct parse_events_error *error);
__u64 perf_pmu__format_bits(struct perf_pmu *pmu, const char *name); __u64 perf_pmu__format_bits(struct perf_pmu *pmu, const char *name);
int perf_pmu__format_type(struct perf_pmu *pmu, const char *name); int perf_pmu__format_type(struct perf_pmu *pmu, const char *name);
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, int perf_pmu__check_alias(struct perf_pmu *pmu, struct parse_events_terms *head_terms,
struct perf_pmu_info *info, struct parse_events_error *err); struct perf_pmu_info *info, struct parse_events_error *err);
int perf_pmu__find_event(struct perf_pmu *pmu, const char *event, void *state, pmu_event_callback cb); int perf_pmu__find_event(struct perf_pmu *pmu, const char *event, void *state, pmu_event_callback cb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment