Commit ba63f76e authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-core-for-mingo-4.14-20170821' of...

Merge tag 'perf-core-for-mingo-4.14-20170821' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

- Support --show-nr-samples in annotate's --stdio and --tui, using
  the existing 't' toggle to circulate 'percent', 'total-period' and
  'nr-samples' as the first column (Taeung Song)

- Support FCMask and PortMask in JSON vendor events (Andi Kleen)

- Fix off by one string allocation problem in 'perf trace' (Arnaldo Carvalho de Melo)

- Use just one parse events state struct in yyparse(), fixing one
  reported segfault when a routine received a different data struct,
  smaller than the one it expected to use (Arnaldo Carvalho de Melo)

- Remove unused cpu_relax() macros, they stopped being used when
  tools/perf lived in Documentation/ (Arnaldo Carvalho de Melo)

- Fix double file test in libbpf's Makefile (Daniel Díaz):
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 9881223c 3a555c77
......@@ -154,10 +154,10 @@ all: fixdep $(VERSION_FILES) all_cmd
all_cmd: $(CMD_TARGETS)
$(BPF_IN): force elfdep bpfdep
@(test -f ../../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
@(test -f ../../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
@(test -f ../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
(diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linux/bpf_common.h >/dev/null) || \
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf_common.h' differs from latest version at 'include/uapi/linux/bpf_common.h'" >&2 )) || true
$(Q)$(MAKE) $(build)=libbpf
......
......@@ -43,6 +43,10 @@ OPTIONS
--quiet::
Do not show any message. (Suppress -v)
-n::
--show-nr-samples::
Show the number of samples for each symbol
-D::
--dump-raw-trace::
Dump raw trace in ASCII.
......@@ -88,6 +92,8 @@ OPTIONS
--asm-raw::
Show raw instruction encoding of assembly instructions.
--show-total-period:: Show a column with the sum of periods.
--source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.
......
......@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode = PERF_DATA_MODE_READ,
};
const struct option options[] = {
struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
......@@ -445,13 +445,20 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
"Show a column with the sum of periods"),
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
"'always' (default), 'never' or 'auto' only applicable to --stdio mode",
stdio__config_color, "always"),
OPT_END()
};
int ret = hists__init();
int ret;
set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
ret = hists__init();
if (ret < 0)
return ret;
......@@ -467,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}
if (symbol_conf.show_nr_samples && annotate.use_gtk) {
pr_err("--show-nr-samples is not available in --gtk mode at this time\n");
return ret;
}
if (quiet)
perf_quiet_option();
......
......@@ -2806,7 +2806,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
struct trace *trace = (struct trace *)opt->value;
const char *s = str;
char *sep = NULL, *lists[2] = { NULL, NULL, };
int len = strlen(str), err = -1, list;
int len = strlen(str) + 1, err = -1, list;
char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
char group_name[PATH_MAX];
......
......@@ -9,16 +9,6 @@
#include <linux/perf_event.h>
#include <asm/barrier.h>
#if defined(__i386__)
#define cpu_relax() asm volatile("rep; nop" ::: "memory");
#define CPUINFO_PROC {"model name"}
#endif
#if defined(__x86_64__)
#define cpu_relax() asm volatile("rep; nop" ::: "memory");
#define CPUINFO_PROC {"model name"}
#endif
#ifdef __powerpc__
#define CPUINFO_PROC {"cpu"}
#endif
......@@ -43,19 +33,10 @@
#define CPUINFO_PROC {"cpu model"}
#endif
#ifdef __ia64__
#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
#define CPUINFO_PROC {"model name"}
#endif
#ifdef __arm__
#define CPUINFO_PROC {"model name", "Processor"}
#endif
#ifdef __aarch64__
#define cpu_relax() asm volatile("yield" ::: "memory")
#endif
#ifdef __mips__
#define CPUINFO_PROC {"cpu model"}
#endif
......@@ -72,13 +53,8 @@
#define CPUINFO_PROC {"core ID"}
#endif
#ifdef __tile__
#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory")
#define CPUINFO_PROC {"model name"}
#endif
#ifndef cpu_relax
#define cpu_relax() barrier()
#ifndef CPUINFO_PROC
#define CPUINFO_PROC { "model name", }
#endif
static inline int
......
......@@ -137,6 +137,8 @@ static struct field {
{ "AnyThread", "any=" },
{ "EdgeDetect", "edge=" },
{ "SampleAfterValue", "period=" },
{ "FCMask", "fc_mask=" },
{ "PortMask", "ch_mask=" },
{ NULL, NULL }
};
......
......@@ -124,16 +124,16 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
struct perf_evlist *evlist;
int i, ret = TEST_FAIL, err = 0, count = 0;
struct parse_events_evlist parse_evlist;
struct parse_events_state parse_state;
struct parse_events_error parse_error;
bzero(&parse_error, sizeof(parse_error));
bzero(&parse_evlist, sizeof(parse_evlist));
parse_evlist.error = &parse_error;
INIT_LIST_HEAD(&parse_evlist.list);
bzero(&parse_state, sizeof(parse_state));
parse_state.error = &parse_error;
INIT_LIST_HEAD(&parse_state.list);
err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj, NULL);
if (err || list_empty(&parse_evlist.list)) {
err = parse_events_load_bpf_obj(&parse_state, &parse_state.list, obj, NULL);
if (err || list_empty(&parse_state.list)) {
pr_debug("Failed to add events selected by BPF\n");
return TEST_FAIL;
}
......@@ -155,8 +155,8 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
goto out_delete_evlist;
}
perf_evlist__splice_list_tail(evlist, &parse_evlist.list);
evlist->nr_groups = parse_evlist.nr_groups;
perf_evlist__splice_list_tail(evlist, &parse_state.list);
evlist->nr_groups = parse_state.nr_groups;
perf_evlist__config(evlist, &opts, NULL);
......
......@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
jump_arrows,
show_linenr,
show_nr_jumps,
show_nr_samples,
show_total_period;
} annotate_browser__opts = {
.use_offset = true,
......@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
bdl->samples[i].he.period);
} else if (annotate_browser__opts.show_nr_samples) {
ui_browser__printf(browser, "%6" PRIu64 " ",
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
bdl->samples[i].percent);
......@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
annotate_browser__opts.show_total_period ? "Period" : "Percent");
annotate_browser__opts.show_total_period ? "Period" :
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
......@@ -830,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
"t Toggle total period view\n"
"t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
......@@ -907,8 +912,13 @@ static int annotate_browser__run(struct annotate_browser *browser,
}
continue;
case 't':
annotate_browser__opts.show_total_period =
!annotate_browser__opts.show_total_period;
if (annotate_browser__opts.show_total_period) {
annotate_browser__opts.show_total_period = false;
annotate_browser__opts.show_nr_samples = true;
} else if (annotate_browser__opts.show_nr_samples)
annotate_browser__opts.show_nr_samples = false;
else
annotate_browser__opts.show_total_period = true;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
......@@ -931,9 +941,11 @@ static int annotate_browser__run(struct annotate_browser *browser,
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
struct hist_browser_timer *hbt)
{
/* Set default value for show_total_period. */
/* Set default value for show_total_period and show_nr_samples */
annotate_browser__opts.show_total_period =
symbol_conf.show_total_period;
symbol_conf.show_total_period;
annotate_browser__opts.show_nr_samples =
symbol_conf.show_nr_samples;
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
}
......@@ -1184,6 +1196,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
};
......
......@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
sample.period);
else if (symbol_conf.show_nr_samples)
color_fprintf(stdout, color, " %7" PRIu64,
sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
......@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
width *= evsel->nr_members;
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
width, width, symbol_conf.show_total_period ? "Event count" : "Percent",
width, width, symbol_conf.show_total_period ? "Period" :
symbol_conf.show_nr_samples ? "Samples" : "Percent",
d_filename, evsel_name, h->nr_samples);
printf("%-*.*s----\n",
......
......@@ -380,9 +380,6 @@ static int __write_cpudesc(struct feat_fd *ff, const char *cpuinfo_proc)
static int write_cpudesc(struct feat_fd *ff,
struct perf_evlist *evlist __maybe_unused)
{
#ifndef CPUINFO_PROC
#define CPUINFO_PROC {"model name", }
#endif
const char *cpuinfo_procs[] = CPUINFO_PROC;
unsigned int i;
......
......@@ -34,7 +34,7 @@
#ifdef PARSER_DEBUG
extern int parse_events_debug;
#endif
int parse_events_parse(void *data, void *scanner);
int parse_events_parse(void *parse_state, void *scanner);
static int get_config_terms(struct list_head *head_config,
struct list_head *head_terms __maybe_unused);
......@@ -589,7 +589,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
}
struct __add_bpf_event_param {
struct parse_events_evlist *data;
struct parse_events_state *parse_state;
struct list_head *list;
struct list_head *head_config;
};
......@@ -599,7 +599,7 @@ static int add_bpf_event(const char *group, const char *event, int fd,
{
LIST_HEAD(new_evsels);
struct __add_bpf_event_param *param = _param;
struct parse_events_evlist *evlist = param->data;
struct parse_events_state *parse_state = param->parse_state;
struct list_head *list = param->list;
struct perf_evsel *pos;
int err;
......@@ -607,8 +607,8 @@ static int add_bpf_event(const char *group, const char *event, int fd,
pr_debug("add bpf event %s:%s and attach bpf program %d\n",
group, event, fd);
err = parse_events_add_tracepoint(&new_evsels, &evlist->idx, group,
event, evlist->error,
err = parse_events_add_tracepoint(&new_evsels, &parse_state->idx, group,
event, parse_state->error,
param->head_config);
if (err) {
struct perf_evsel *evsel, *tmp;
......@@ -632,14 +632,14 @@ static int add_bpf_event(const char *group, const char *event, int fd,
return 0;
}
int parse_events_load_bpf_obj(struct parse_events_evlist *data,
int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
struct list_head *list,
struct bpf_object *obj,
struct list_head *head_config)
{
int err;
char errbuf[BUFSIZ];
struct __add_bpf_event_param param = {data, list, head_config};
struct __add_bpf_event_param param = {parse_state, list, head_config};
static bool registered_unprobe_atexit = false;
if (IS_ERR(obj) || !obj) {
......@@ -680,13 +680,13 @@ int parse_events_load_bpf_obj(struct parse_events_evlist *data,
return 0;
errout:
data->error->help = strdup("(add -v to see detail)");
data->error->str = strdup(errbuf);
parse_state->error->help = strdup("(add -v to see detail)");
parse_state->error->str = strdup(errbuf);
return err;
}
static int
parse_events_config_bpf(struct parse_events_evlist *data,
parse_events_config_bpf(struct parse_events_state *parse_state,
struct bpf_object *obj,
struct list_head *head_config)
{
......@@ -705,28 +705,28 @@ parse_events_config_bpf(struct parse_events_evlist *data,
"Invalid config term for BPF object");
errbuf[BUFSIZ - 1] = '\0';
data->error->idx = term->err_term;
data->error->str = strdup(errbuf);
parse_state->error->idx = term->err_term;
parse_state->error->str = strdup(errbuf);
return -EINVAL;
}
err = bpf__config_obj(obj, term, data->evlist, &error_pos);
err = bpf__config_obj(obj, term, parse_state->evlist, &error_pos);
if (err) {
bpf__strerror_config_obj(obj, term, data->evlist,
bpf__strerror_config_obj(obj, term, parse_state->evlist,
&error_pos, err, errbuf,
sizeof(errbuf));
data->error->help = strdup(
parse_state->error->help = strdup(
"Hint:\tValid config terms:\n"
" \tmap:[<arraymap>].value<indices>=[value]\n"
" \tmap:[<eventmap>].event<indices>=[event]\n"
"\n"
" \twhere <indices> is something like [0,3...5] or [all]\n"
" \t(add -v to see detail)");
data->error->str = strdup(errbuf);
parse_state->error->str = strdup(errbuf);
if (err == -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUE)
data->error->idx = term->err_val;
parse_state->error->idx = term->err_val;
else
data->error->idx = term->err_term + error_pos;
parse_state->error->idx = term->err_term + error_pos;
return err;
}
}
......@@ -762,7 +762,7 @@ split_bpf_config_terms(struct list_head *evt_head_config,
list_move_tail(&term->list, obj_head_config);
}
int parse_events_load_bpf(struct parse_events_evlist *data,
int parse_events_load_bpf(struct parse_events_state *parse_state,
struct list_head *list,
char *bpf_file_name,
bool source,
......@@ -790,15 +790,15 @@ int parse_events_load_bpf(struct parse_events_evlist *data,
-err, errbuf,
sizeof(errbuf));
data->error->help = strdup("(add -v to see detail)");
data->error->str = strdup(errbuf);
parse_state->error->help = strdup("(add -v to see detail)");
parse_state->error->str = strdup(errbuf);
return err;
}
err = parse_events_load_bpf_obj(data, list, obj, head_config);
err = parse_events_load_bpf_obj(parse_state, list, obj, head_config);
if (err)
return err;
err = parse_events_config_bpf(data, obj, &obj_head_config);
err = parse_events_config_bpf(parse_state, obj, &obj_head_config);
/*
* Caller doesn't know anything about obj_head_config,
......@@ -1184,7 +1184,7 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
err, head_config);
}
int parse_events_add_numeric(struct parse_events_evlist *data,
int parse_events_add_numeric(struct parse_events_state *parse_state,
struct list_head *list,
u32 type, u64 config,
struct list_head *head_config)
......@@ -1197,7 +1197,7 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
attr.config = config;
if (head_config) {
if (config_attr(&attr, head_config, data->error,
if (config_attr(&attr, head_config, parse_state->error,
config_term_common))
return -EINVAL;
......@@ -1205,11 +1205,11 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
return -ENOMEM;
}
return add_event(list, &data->idx, &attr,
return add_event(list, &parse_state->idx, &attr,
get_config_name(head_config), &config_terms);
}
int parse_events_add_pmu(struct parse_events_evlist *data,
int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, char *name,
struct list_head *head_config)
{
......@@ -1232,7 +1232,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
if (!head_config) {
attr.type = pmu->type;
evsel = __add_event(list, &data->idx, &attr, NULL, pmu->cpus, NULL);
evsel = __add_event(list, &parse_state->idx, &attr, NULL, pmu->cpus, NULL);
return evsel ? 0 : -ENOMEM;
}
......@@ -1243,16 +1243,16 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
* Configure hardcoded terms first, no need to check
* return value when called with fail == 0 ;)
*/
if (config_attr(&attr, head_config, data->error, config_term_pmu))
if (config_attr(&attr, head_config, parse_state->error, config_term_pmu))
return -EINVAL;
if (get_config_terms(head_config, &config_terms))
return -ENOMEM;
if (perf_pmu__config(pmu, &attr, head_config, data->error))
if (perf_pmu__config(pmu, &attr, head_config, parse_state->error))
return -EINVAL;
evsel = __add_event(list, &data->idx, &attr,
evsel = __add_event(list, &parse_state->idx, &attr,
get_config_name(head_config), pmu->cpus,
&config_terms);
if (evsel) {
......@@ -1267,7 +1267,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
return evsel ? 0 : -ENOMEM;
}
int parse_events_multi_pmu_add(struct parse_events_evlist *data,
int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str, struct list_head **listp)
{
struct list_head *head;
......@@ -1296,7 +1296,7 @@ int parse_events_multi_pmu_add(struct parse_events_evlist *data,
return -1;
list_add_tail(&term->list, head);
if (!parse_events_add_pmu(data, list,
if (!parse_events_add_pmu(parse_state, list,
pmu->name, head)) {
pr_debug("%s -> %s/%s/\n", str,
pmu->name, alias->str);
......@@ -1628,7 +1628,7 @@ perf_pmu__parse_check(const char *name)
return r ? r->type : PMU_EVENT_SYMBOL_ERR;
}
static int parse_events__scanner(const char *str, void *data, int start_token)
static int parse_events__scanner(const char *str, void *parse_state, int start_token)
{
YY_BUFFER_STATE buffer;
void *scanner;
......@@ -1643,7 +1643,7 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
#ifdef PARSER_DEBUG
parse_events_debug = 1;
#endif
ret = parse_events_parse(data, scanner);
ret = parse_events_parse(parse_state, scanner);
parse_events__flush_buffer(buffer, scanner);
parse_events__delete_buffer(buffer, scanner);
......@@ -1656,45 +1656,45 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
*/
int parse_events_terms(struct list_head *terms, const char *str)
{
struct parse_events_terms data = {
struct parse_events_state parse_state = {
.terms = NULL,
};
int ret;
ret = parse_events__scanner(str, &data, PE_START_TERMS);
ret = parse_events__scanner(str, &parse_state, PE_START_TERMS);
if (!ret) {
list_splice(data.terms, terms);
zfree(&data.terms);
list_splice(parse_state.terms, terms);
zfree(&parse_state.terms);
return 0;
}
parse_events_terms__delete(data.terms);
parse_events_terms__delete(parse_state.terms);
return ret;
}
int parse_events(struct perf_evlist *evlist, const char *str,
struct parse_events_error *err)
{
struct parse_events_evlist data = {
.list = LIST_HEAD_INIT(data.list),
struct parse_events_state parse_state = {
.list = LIST_HEAD_INIT(parse_state.list),
.idx = evlist->nr_entries,
.error = err,
.evlist = evlist,
};
int ret;
ret = parse_events__scanner(str, &data, PE_START_EVENTS);
ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS);
perf_pmu__parse_cleanup();
if (!ret) {
struct perf_evsel *last;
if (list_empty(&data.list)) {
if (list_empty(&parse_state.list)) {
WARN_ONCE(true, "WARNING: event parser found nothing");
return -1;
}
perf_evlist__splice_list_tail(evlist, &data.list);
evlist->nr_groups += data.nr_groups;
perf_evlist__splice_list_tail(evlist, &parse_state.list);
evlist->nr_groups += parse_state.nr_groups;
last = perf_evlist__last(evlist);
last->cmdline_group_boundary = true;
......@@ -2520,10 +2520,10 @@ void parse_events__clear_array(struct parse_events_array *a)
zfree(&a->ranges);
}
void parse_events_evlist_error(struct parse_events_evlist *data,
void parse_events_evlist_error(struct parse_events_state *parse_state,
int idx, const char *str)
{
struct parse_events_error *err = data->error;
struct parse_events_error *err = parse_state->error;
if (!err)
return;
......
......@@ -108,16 +108,13 @@ struct parse_events_error {
char *help; /* optional help string */
};
struct parse_events_evlist {
struct parse_events_state {
struct list_head list;
int idx;
int nr_groups;
struct parse_events_error *error;
struct perf_evlist *evlist;
};
struct parse_events_terms {
struct list_head *terms;
struct list_head *terms;
};
void parse_events__shrink_config_terms(void);
......@@ -143,18 +140,18 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
const char *sys, const char *event,
struct parse_events_error *error,
struct list_head *head_config);
int parse_events_load_bpf(struct parse_events_evlist *data,
int parse_events_load_bpf(struct parse_events_state *parse_state,
struct list_head *list,
char *bpf_file_name,
bool source,
struct list_head *head_config);
/* Provide this function for perf test */
struct bpf_object;
int parse_events_load_bpf_obj(struct parse_events_evlist *data,
int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
struct list_head *list,
struct bpf_object *obj,
struct list_head *head_config);
int parse_events_add_numeric(struct parse_events_evlist *data,
int parse_events_add_numeric(struct parse_events_state *parse_state,
struct list_head *list,
u32 type, u64 config,
struct list_head *head_config);
......@@ -164,11 +161,11 @@ int parse_events_add_cache(struct list_head *list, int *idx,
struct list_head *head_config);
int parse_events_add_breakpoint(struct list_head *list, int *idx,
void *ptr, char *type, u64 len);
int parse_events_add_pmu(struct parse_events_evlist *data,
int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, char *name,
struct list_head *head_config);
int parse_events_multi_pmu_add(struct parse_events_evlist *data,
int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str,
struct list_head **listp);
......@@ -180,7 +177,7 @@ perf_pmu__parse_check(const char *name);
void parse_events__set_leader(char *name, struct list_head *list);
void parse_events_update_lists(struct list_head *list_event,
struct list_head *list_all);
void parse_events_evlist_error(struct parse_events_evlist *data,
void parse_events_evlist_error(struct parse_events_state *parse_state,
int idx, const char *str);
void print_events(const char *event_glob, bool name_only, bool quiet,
......
%pure-parser
%parse-param {void *_data}
%parse-param {void *_parse_state}
%parse-param {void *scanner}
%lex-param {void* scanner}
%locations
......@@ -17,7 +17,7 @@
#include "parse-events.h"
#include "parse-events-bison.h"
void parse_events_error(YYLTYPE *loc, void *data, void *scanner, char const *msg);
void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
#define ABORT_ON(val) \
do { \
......@@ -33,11 +33,11 @@ do { \
} while (0)
static void inc_group_count(struct list_head *list,
struct parse_events_evlist *data)
struct parse_events_state *parse_state)
{
/* Count groups only have more than 1 members */
if (!list_is_last(list->next, list))
data->nr_groups++;
parse_state->nr_groups++;
}
%}
......@@ -115,9 +115,9 @@ PE_START_TERMS start_terms
start_events: groups
{
struct parse_events_evlist *data = _data;
struct parse_events_state *parse_state = _parse_state;
parse_events_update_lists($1, &data->list);
parse_events_update_lists($1, &parse_state->list);
}
groups:
......@@ -159,7 +159,7 @@ PE_NAME '{' events '}'
{
struct list_head *list = $3;
inc_group_count(list, _data);
inc_group_count(list, _parse_state);
parse_events__set_leader($1, list);
$$ = list;
}
......@@ -168,7 +168,7 @@ PE_NAME '{' events '}'
{
struct list_head *list = $2;
inc_group_count(list, _data);
inc_group_count(list, _parse_state);
parse_events__set_leader(NULL, list);
$$ = list;
}
......@@ -225,14 +225,13 @@ event_def: event_pmu |
event_pmu:
PE_NAME opt_event_config
{
struct parse_events_evlist *data = _data;
struct list_head *list, *orig_terms, *terms;
if (parse_events_copy_term_list($2, &orig_terms))
YYABORT;
ALLOC_LIST(list);
if (parse_events_add_pmu(data, list, $1, $2)) {
if (parse_events_add_pmu(_parse_state, list, $1, $2)) {
struct perf_pmu *pmu = NULL;
int ok = 0;
......@@ -245,7 +244,7 @@ PE_NAME opt_event_config
if (!strncmp($1, name, strlen($1))) {
if (parse_events_copy_term_list(orig_terms, &terms))
YYABORT;
if (!parse_events_add_pmu(data, list, pmu->name, terms))
if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms))
ok++;
parse_events_terms__delete(terms);
}
......@@ -262,7 +261,7 @@ PE_KERNEL_PMU_EVENT sep_dc
{
struct list_head *list;
if (parse_events_multi_pmu_add(_data, $1, &list) < 0)
if (parse_events_multi_pmu_add(_parse_state, $1, &list) < 0)
YYABORT;
$$ = list;
}
......@@ -273,7 +272,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
char pmu_name[128];
snprintf(&pmu_name, 128, "%s-%s", $1, $3);
if (parse_events_multi_pmu_add(_data, pmu_name, &list) < 0)
if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
YYABORT;
$$ = list;
}
......@@ -286,62 +285,60 @@ PE_VALUE_SYM_SW
event_legacy_symbol:
value_sym '/' event_config '/'
{
struct parse_events_evlist *data = _data;
struct list_head *list;
int type = $1 >> 16;
int config = $1 & 255;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_numeric(data, list, type, config, $3));
ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, $3));
parse_events_terms__delete($3);
$$ = list;
}
|
value_sym sep_slash_dc
{
struct parse_events_evlist *data = _data;
struct list_head *list;
int type = $1 >> 16;
int config = $1 & 255;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL));
ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
$$ = list;
}
event_legacy_cache:
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
{
struct parse_events_evlist *data = _data;
struct parse_events_error *error = data->error;
struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5, error, $6));
ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6));
parse_events_terms__delete($6);
$$ = list;
}
|
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
{
struct parse_events_evlist *data = _data;
struct parse_events_error *error = data->error;
struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL, error, $4));
ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4));
parse_events_terms__delete($4);
$$ = list;
}
|
PE_NAME_CACHE_TYPE opt_event_config
{
struct parse_events_evlist *data = _data;
struct parse_events_error *error = data->error;
struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL, error, $2));
ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2));
parse_events_terms__delete($2);
$$ = list;
}
......@@ -349,44 +346,44 @@ PE_NAME_CACHE_TYPE opt_event_config
event_legacy_mem:
PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
{
struct parse_events_evlist *data = _data;
struct parse_events_state *parse_state = _parse_state;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
(void *) $2, $6, $4));
$$ = list;
}
|
PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
{
struct parse_events_evlist *data = _data;
struct parse_events_state *parse_state = _parse_state;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
(void *) $2, NULL, $4));
$$ = list;
}
|
PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
{
struct parse_events_evlist *data = _data;
struct parse_events_state *parse_state = _parse_state;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
(void *) $2, $4, 0));
$$ = list;
}
|
PE_PREFIX_MEM PE_VALUE sep_dc
{
struct parse_events_evlist *data = _data;
struct parse_events_state *parse_state = _parse_state;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
(void *) $2, NULL, 0));
$$ = list;
}
......@@ -394,15 +391,15 @@ PE_PREFIX_MEM PE_VALUE sep_dc
event_legacy_tracepoint:
tracepoint_name opt_event_config
{
struct parse_events_evlist *data = _data;
struct parse_events_error *error = data->error;
struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
struct list_head *list;
ALLOC_LIST(list);
if (error)
error->idx = @1.first_column;
if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
if (parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
error, $2))
return -1;
......@@ -432,11 +429,10 @@ PE_NAME ':' PE_NAME
event_legacy_numeric:
PE_VALUE ':' PE_VALUE opt_event_config
{
struct parse_events_evlist *data = _data;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4));
ABORT_ON(parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4));
parse_events_terms__delete($4);
$$ = list;
}
......@@ -444,11 +440,10 @@ PE_VALUE ':' PE_VALUE opt_event_config
event_legacy_raw:
PE_RAW opt_event_config
{
struct parse_events_evlist *data = _data;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2));
ABORT_ON(parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2));
parse_events_terms__delete($2);
$$ = list;
}
......@@ -456,23 +451,22 @@ PE_RAW opt_event_config
event_bpf_file:
PE_BPF_OBJECT opt_event_config
{
struct parse_events_evlist *data = _data;
struct parse_events_error *error = data->error;
struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_load_bpf(data, list, $1, false, $2));
ABORT_ON(parse_events_load_bpf(parse_state, list, $1, false, $2));
parse_events_terms__delete($2);
$$ = list;
}
|
PE_BPF_SOURCE opt_event_config
{
struct parse_events_evlist *data = _data;
struct list_head *list;
ALLOC_LIST(list);
ABORT_ON(parse_events_load_bpf(data, list, $1, true, $2));
ABORT_ON(parse_events_load_bpf(_parse_state, list, $1, true, $2));
parse_events_terms__delete($2);
$$ = list;
}
......@@ -494,8 +488,8 @@ opt_event_config:
start_terms: event_config
{
struct parse_events_terms *data = _data;
data->terms = $1;
struct parse_events_state *parse_state = _parse_state;
parse_state->terms = $1;
}
event_config:
......@@ -685,9 +679,9 @@ sep_slash_dc: '/' | ':' |
%%
void parse_events_error(YYLTYPE *loc, void *data,
void parse_events_error(YYLTYPE *loc, void *parse_state,
void *scanner __maybe_unused,
char const *msg __maybe_unused)
{
parse_events_evlist_error(data, loc->last_column, "parser error");
parse_events_evlist_error(parse_state, loc->last_column, "parser error");
}
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