Commit 17cb5f84 authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

perf tools: Create config_term_names array

config_term_names[] is introduced for future commits which will be able
to retrieve the config name through the config term.

Utilize this array in parse_events_formats_error_string() so the missing
'{,no-}inherit' terms are added.
Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-10-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 26dee028
...@@ -746,6 +746,25 @@ static int check_type_val(struct parse_events_term *term, ...@@ -746,6 +746,25 @@ static int check_type_val(struct parse_events_term *term,
return -EINVAL; return -EINVAL;
} }
/*
* Update according to parse-events.l
*/
static const char *config_term_names[__PARSE_EVENTS__TERM_TYPE_NR] = {
[PARSE_EVENTS__TERM_TYPE_USER] = "<sysfs term>",
[PARSE_EVENTS__TERM_TYPE_CONFIG] = "config",
[PARSE_EVENTS__TERM_TYPE_CONFIG1] = "config1",
[PARSE_EVENTS__TERM_TYPE_CONFIG2] = "config2",
[PARSE_EVENTS__TERM_TYPE_NAME] = "name",
[PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD] = "period",
[PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ] = "freq",
[PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE] = "branch_type",
[PARSE_EVENTS__TERM_TYPE_TIME] = "time",
[PARSE_EVENTS__TERM_TYPE_CALLGRAPH] = "call-graph",
[PARSE_EVENTS__TERM_TYPE_STACKSIZE] = "stack-size",
[PARSE_EVENTS__TERM_TYPE_NOINHERIT] = "no-inherit",
[PARSE_EVENTS__TERM_TYPE_INHERIT] = "inherit",
};
typedef int config_term_func_t(struct perf_event_attr *attr, typedef int config_term_func_t(struct perf_event_attr *attr,
struct parse_events_term *term, struct parse_events_term *term,
struct parse_events_error *err); struct parse_events_error *err);
...@@ -2097,6 +2116,31 @@ void parse_events_evlist_error(struct parse_events_evlist *data, ...@@ -2097,6 +2116,31 @@ void parse_events_evlist_error(struct parse_events_evlist *data,
WARN_ONCE(!err->str, "WARNING: failed to allocate error string"); WARN_ONCE(!err->str, "WARNING: failed to allocate error string");
} }
static void config_terms_list(char *buf, size_t buf_sz)
{
int i;
bool first = true;
buf[0] = '\0';
for (i = 0; i < __PARSE_EVENTS__TERM_TYPE_NR; i++) {
const char *name = config_term_names[i];
if (!name)
continue;
if (name[0] == '<')
continue;
if (strlen(buf) + strlen(name) + 2 >= buf_sz)
return;
if (!first)
strcat(buf, ",");
else
first = false;
strcat(buf, name);
}
}
/* /*
* Return string contains valid config terms of an event. * Return string contains valid config terms of an event.
* @additional_terms: For terms such as PMU sysfs terms. * @additional_terms: For terms such as PMU sysfs terms.
...@@ -2104,10 +2148,11 @@ void parse_events_evlist_error(struct parse_events_evlist *data, ...@@ -2104,10 +2148,11 @@ void parse_events_evlist_error(struct parse_events_evlist *data,
char *parse_events_formats_error_string(char *additional_terms) char *parse_events_formats_error_string(char *additional_terms)
{ {
char *str; char *str;
static const char *static_terms = "config,config1,config2,name," /* "branch_type" is the longest name */
"period,freq,branch_type,time," char static_terms[__PARSE_EVENTS__TERM_TYPE_NR *
"call-graph,stack-size\n"; (sizeof("branch_type") - 1)];
config_terms_list(static_terms, sizeof(static_terms));
/* valid terms */ /* valid terms */
if (additional_terms) { if (additional_terms) {
if (asprintf(&str, "valid terms: %s,%s", if (asprintf(&str, "valid terms: %s,%s",
......
...@@ -68,7 +68,8 @@ enum { ...@@ -68,7 +68,8 @@ enum {
PARSE_EVENTS__TERM_TYPE_CALLGRAPH, PARSE_EVENTS__TERM_TYPE_CALLGRAPH,
PARSE_EVENTS__TERM_TYPE_STACKSIZE, PARSE_EVENTS__TERM_TYPE_STACKSIZE,
PARSE_EVENTS__TERM_TYPE_NOINHERIT, PARSE_EVENTS__TERM_TYPE_NOINHERIT,
PARSE_EVENTS__TERM_TYPE_INHERIT PARSE_EVENTS__TERM_TYPE_INHERIT,
__PARSE_EVENTS__TERM_TYPE_NR,
}; };
struct parse_events_term { struct parse_events_term {
......
...@@ -178,8 +178,7 @@ modifier_bp [rwx]{1,3} ...@@ -178,8 +178,7 @@ modifier_bp [rwx]{1,3}
<config>{ <config>{
/* /*
* Please update parse_events_formats_error_string any time * Please update config_term_names when new static term is added.
* new static term is added.
*/ */
config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); } config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
......
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