From 6a648b534d3d4f6532241fd9b97c0dab7b0c3f89 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 2 Aug 2018 10:30:08 -0300 Subject: perf trace: Associate vfs_getname()'ed pathname with fd returned from 'openat' When the vfs_getname() wannabe tracepoint is in place: # perf probe -l probe:vfs_getname (on getname_flags:73@acme/git/linux/fs/namei.c with pathname) # 'perf trace' will use it to get the pathname when it is copied from userspace to the kernel, right after syscalls:sys_enter_open, copied in the 'probe:vfs_getname', stash it somewhere and then, at syscalls:sys_exit_open time, if the 'open' return is not -1, i.e. a successfull open syscall, associate that pathname to this return, i.e. the fd. We were not doing this for the 'openat' syscall, which would cause 'perf trace' to fallback to using /proc to get the fd, change it so that we use what we got from probe:vfs_getname, reducing the 'openat' beautification process cost, ditching the syscalls performed to read procfs state and avoiding some possible races in the process. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-xnp44ao3bkb6ejeczxfnjwsh@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 88561eed7950..2a85f5198da0 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -121,7 +121,6 @@ struct trace { bool force; bool vfs_getname; int trace_pgfaults; - int open_id; }; struct tp_field { @@ -805,12 +804,17 @@ static struct syscall_fmt *syscall_fmt__find(const char *name) return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp); } +/* + * is_exit: is this "exit" or "exit_group"? + * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter. + */ struct syscall { struct event_format *tp_format; int nr_args; + bool is_exit; + bool is_open; struct format_field *args; const char *name; - bool is_exit; struct syscall_fmt *fmt; struct syscall_arg_fmt *arg_fmt; }; @@ -1299,6 +1303,7 @@ static int trace__read_syscall_info(struct trace *trace, int id) } sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit"); + sc->is_open = !strcmp(name, "open") || !strcmp(name, "openat"); return syscall__set_arg_fmts(sc); } @@ -1722,7 +1727,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel, ret = perf_evsel__sc_tp_uint(evsel, ret, sample); - if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) { + if (sc->is_open && ret >= 0 && ttrace->filename.pending_open) { trace__set_fd_pathname(thread, ret, ttrace->filename.name); ttrace->filename.pending_open = false; ++trace->stats.vfs_getname; @@ -3205,8 +3210,6 @@ int cmd_trace(int argc, const char **argv) } } - trace.open_id = syscalltbl__id(trace.sctbl, "open"); - err = target__validate(&trace.opts.target); if (err) { target__strerror(&trace.opts.target, err, bf, sizeof(bf)); -- cgit v1.2.3 From a98392bb1e169a04aad83ed28f2b7a63010104ec Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 2 Aug 2018 14:05:09 -0300 Subject: perf trace: Use beautifiers on syscalls:sys_enter_ handlers We were using the beautifiers only when processing the raw_syscalls:sys_enter events, but we can as well use them for the syscalls:sys_enter_NAME events, as the layout is the same. Some more tweaking is needed as we're processing them straight away, i.e. there is no buffering in the sys_enter_NAME event to wait for things like vfs_getname to provide pointer contents and then flushing at sys_exit_NAME, so we need to state in the syscall_arg that this is unbuffered, just print the pointer values, beautifying just non-pointer syscall args. This just shows an alternative way of processing tracepoints, that we will end up using when creating "tracepoint" payloads that already copy pointer contents (or chunks of it, i.e. not the whole filename, but just the end of it, not all the bf for a read/write, but just the start, etc), directly in the kernel using eBPF. E.g.: # perf trace -e syscalls:*enter*sleep,*sleep sleep 1 0.303 ( ): syscalls:sys_enter_nanosleep:rqtp: 0x7ffc93d5ecc0 0.305 (1000.229 ms): sleep/8746 nanosleep(rqtp: 0x7ffc93d5ecc0) = 0 # perf trace -e syscalls:*_*sleep,*sleep sleep 1 0.288 ( ): syscalls:sys_enter_nanosleep:rqtp: 0x7ffecde87e40 0.289 ( ): sleep/8748 nanosleep(rqtp: 0x7ffecde87e40) ... 1000.479 ( ): syscalls:sys_exit_nanosleep:0x0 0.289 (1000.208 ms): sleep/8748 ... [continued]: nanosleep()) = 0 # Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-jehyd2zwhw00z3p7v7mg9632@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 47 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 2a85f5198da0..7336552c22cf 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1666,6 +1666,44 @@ out_put: return err; } +static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evsel, + struct perf_sample *sample) +{ + struct format_field *field = perf_evsel__field(evsel, "__syscall_nr"); + struct thread_trace *ttrace; + struct thread *thread; + struct syscall *sc; + char msg[1024]; + int id, err = -1; + void *args; + + if (field == NULL) + return -1; + + id = format_field__intval(field, sample, evsel->needs_swap); + sc = trace__syscall_info(trace, evsel, id); + + if (sc == NULL) + return -1; + + thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + ttrace = thread__trace(thread, trace->output); + /* + * We need to get ttrace just to make sure it is there when syscall__scnprintf_args() + * and the rest of the beautifiers accessing it via struct syscall_arg touches it. + */ + if (ttrace == NULL) + goto out_put; + + args = sample->raw_data + field->offset + sizeof(u64); /* skip __syscall_nr, there is where args are */ + syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread); + fprintf(trace->output, "%s", msg); + err = 0; +out_put: + thread__put(thread); + return err; +} + static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel, struct perf_sample *sample, struct callchain_cursor *cursor) @@ -1964,9 +2002,12 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, if (perf_evsel__is_bpf_output(evsel)) { bpf_output__fprintf(trace, sample); } else if (evsel->tp_format) { - event_format__fprintf(evsel->tp_format, sample->cpu, - sample->raw_data, sample->raw_size, - trace->output); + if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || + trace__fprintf_sys_enter(trace, evsel, sample)) { + event_format__fprintf(evsel->tp_format, sample->cpu, + sample->raw_data, sample->raw_size, + trace->output); + } } fprintf(trace->output, "\n"); -- cgit v1.2.3 From 63f11c80e5dd4afae69ea2578addf896ddc06fee Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 2 Aug 2018 14:27:09 -0300 Subject: perf trace: Rename some syscall_tp methods to raw_syscall Because raw_syscalls have the field for the syscall number as 'id' while the syscalls:sys_{enter,exit}_NAME have it as __syscall_nr... Since we want to support both for being able to enable just a syscalls:sys_{enter,exit}_name instead of asking for raw_syscalls:sys_{enter,exit} plus filters, make the method names for each kind of tracepoint more explicit. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-4rixbfzco6tsry0w9ghx3ktb@git.kernel.org Signef-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7336552c22cf..039f94467968 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -239,7 +239,7 @@ static void perf_evsel__delete_priv(struct perf_evsel *evsel) perf_evsel__delete(evsel); } -static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler) +static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) { evsel->priv = malloc(sizeof(struct syscall_tp)); if (evsel->priv != NULL) { @@ -257,7 +257,7 @@ out_delete: return -ENOENT; } -static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler) +static struct perf_evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler) { struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction); @@ -268,7 +268,7 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void if (IS_ERR(evsel)) return NULL; - if (perf_evsel__init_syscall_tp(evsel, handler)) + if (perf_evsel__init_raw_syscall_tp(evsel, handler)) goto out_delete; return evsel; @@ -2288,14 +2288,14 @@ static int trace__add_syscall_newtp(struct trace *trace) struct perf_evlist *evlist = trace->evlist; struct perf_evsel *sys_enter, *sys_exit; - sys_enter = perf_evsel__syscall_newtp("sys_enter", trace__sys_enter); + sys_enter = perf_evsel__raw_syscall_newtp("sys_enter", trace__sys_enter); if (sys_enter == NULL) goto out; if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args)) goto out_delete_sys_enter; - sys_exit = perf_evsel__syscall_newtp("sys_exit", trace__sys_exit); + sys_exit = perf_evsel__raw_syscall_newtp("sys_exit", trace__sys_exit); if (sys_exit == NULL) goto out_delete_sys_enter; @@ -2717,7 +2717,7 @@ static int trace__replay(struct trace *trace) "syscalls:sys_enter"); if (evsel && - (perf_evsel__init_syscall_tp(evsel, trace__sys_enter) < 0 || + (perf_evsel__init_raw_syscall_tp(evsel, trace__sys_enter) < 0 || perf_evsel__init_sc_tp_ptr_field(evsel, args))) { pr_err("Error during initialize raw_syscalls:sys_enter event\n"); goto out; @@ -2729,7 +2729,7 @@ static int trace__replay(struct trace *trace) evsel = perf_evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_exit"); if (evsel && - (perf_evsel__init_syscall_tp(evsel, trace__sys_exit) < 0 || + (perf_evsel__init_raw_syscall_tp(evsel, trace__sys_exit) < 0 || perf_evsel__init_sc_tp_uint_field(evsel, ret))) { pr_err("Error during initialize raw_syscalls:sys_exit event\n"); goto out; -- cgit v1.2.3 From aa823f58f7abf42f181fbaef4fdbe76eccea1c29 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 2 Aug 2018 15:03:02 -0300 Subject: perf trace: Allow setting up a syscall_tp struct without a format_field To avoid having to ask libtraceevent to find a field by name when handling each tracepoint event, we setup a struct syscall_tp with a tp_field struct having an extractor function + the offset for the "id", "args" and "ret" raw_syscalls:sys_{enter,exit} tracepoints. Now that we want to do the same with syscalls:sys_{entry,exit}_NAME individual syscall tracepoints, where we have "id" as "__syscall_nr" and "args" as the actual series of per syscall parameters, we need more flexibility from the routines that set up these pre-looked up syscall tracepoint arg fields. The next cset will use it. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-v59q5e0jrlzkpl9a1c7t81ni@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 039f94467968..7fca844ced0b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -156,13 +156,11 @@ TP_UINT_FIELD__SWAPPED(16); TP_UINT_FIELD__SWAPPED(32); TP_UINT_FIELD__SWAPPED(64); -static int tp_field__init_uint(struct tp_field *field, - struct format_field *format_field, - bool needs_swap) +static int __tp_field__init_uint(struct tp_field *field, int size, int offset, bool needs_swap) { - field->offset = format_field->offset; + field->offset = offset; - switch (format_field->size) { + switch (size) { case 1: field->integer = tp_field__u8; break; @@ -182,18 +180,28 @@ static int tp_field__init_uint(struct tp_field *field, return 0; } +static int tp_field__init_uint(struct tp_field *field, struct format_field *format_field, bool needs_swap) +{ + return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap); +} + static void *tp_field__ptr(struct tp_field *field, struct perf_sample *sample) { return sample->raw_data + field->offset; } -static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field) +static int __tp_field__init_ptr(struct tp_field *field, int offset) { - field->offset = format_field->offset; + field->offset = offset; field->pointer = tp_field__ptr; return 0; } +static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field) +{ + return __tp_field__init_ptr(field, format_field->offset); +} + struct syscall_tp { struct tp_field id; union { -- cgit v1.2.3 From d32855fa35b94a066c5860c94adc3ebcac7d2c66 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 2 Aug 2018 15:09:24 -0300 Subject: perf trace: Setup struct syscall_tp for syscalls:sys_{enter,exit}_NAME events Mapping "__syscall_nr" to "id" and setting up "args" from the offset of "__syscall_nr" + sizeof(u64), as the payload for syscalls:* is the same as for raw_syscalls:*, just the fields have different names. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-ogeenrpviwcpwl3oy1l55f3m@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 53 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7fca844ced0b..41799596c045 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -247,6 +247,22 @@ static void perf_evsel__delete_priv(struct perf_evsel *evsel) perf_evsel__delete(evsel); } +static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel) +{ + struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp)); + + if (evsel->priv != NULL) { + if (perf_evsel__init_tp_uint_field(evsel, &sc->id, "__syscall_nr")) + goto out_delete; + return 0; + } + + return -ENOMEM; +out_delete: + zfree(&evsel->priv); + return -ENOENT; +} + static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) { evsel->priv = malloc(sizeof(struct syscall_tp)); @@ -2977,6 +2993,36 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler) evsel->handler = handler; } +static int evlist__set_syscall_tp_fields(struct perf_evlist *evlist) +{ + struct perf_evsel *evsel; + + evlist__for_each_entry(evlist, evsel) { + if (evsel->priv || !evsel->tp_format) + continue; + + if (strcmp(evsel->tp_format->system, "syscalls")) + continue; + + if (perf_evsel__init_syscall_tp(evsel)) + return -1; + + if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) { + struct syscall_tp *sc = evsel->priv; + + if (__tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64))) + return -1; + } else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) { + struct syscall_tp *sc = evsel->priv; + + if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap)) + return -1; + } + } + + return 0; +} + /* * XXX: Hackish, just splitting the combined -e+--event (syscalls * (raw_syscalls:{sys_{enter,exit}} + events (tracepoints, HW, SW, etc) to use @@ -3236,8 +3282,13 @@ int cmd_trace(int argc, const char **argv) symbol_conf.use_callchain = true; } - if (trace.evlist->nr_entries > 0) + if (trace.evlist->nr_entries > 0) { evlist__set_evsel_handler(trace.evlist, trace__event_handler); + if (evlist__set_syscall_tp_fields(trace.evlist)) { + perror("failed to set syscalls:* tracepoint fields"); + goto out; + } + } if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) return trace__record(&trace, argc-1, &argv[1]); -- cgit v1.2.3 From f3acd8869b9badcfd91cf50a2b6242be7b9368e2 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 2 Aug 2018 15:11:58 -0300 Subject: perf trace: Use perf_evsel__sc_tp_{uint,ptr} for "id"/"args" handling syscalls:* events Now it looks just about the same as for the trace__sys_{enter,exit}. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-y59may7zx1eccnp4m3qm4u0b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 41799596c045..7232a7302580 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1693,20 +1693,13 @@ out_put: static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evsel, struct perf_sample *sample) { - struct format_field *field = perf_evsel__field(evsel, "__syscall_nr"); struct thread_trace *ttrace; struct thread *thread; - struct syscall *sc; + int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; + struct syscall *sc = trace__syscall_info(trace, evsel, id); char msg[1024]; - int id, err = -1; void *args; - if (field == NULL) - return -1; - - id = format_field__intval(field, sample, evsel->needs_swap); - sc = trace__syscall_info(trace, evsel, id); - if (sc == NULL) return -1; @@ -1719,7 +1712,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evse if (ttrace == NULL) goto out_put; - args = sample->raw_data + field->offset + sizeof(u64); /* skip __syscall_nr, there is where args are */ + args = perf_evsel__sc_tp_ptr(evsel, args, sample); syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread); fprintf(trace->output, "%s", msg); err = 0; -- cgit v1.2.3 From b96e6615cd197022017808a9fe82f1737e307875 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Thu, 2 Aug 2018 09:46:20 +0200 Subject: perf auxtrace: Support for perf report -D for s390 Add initial support for s390 auxiliary traces using the CPU-Measurement Sampling Facility. Support and ignore PERF_REPORT_AUXTRACE_INFO records in the perf data file. Later patches will show the contents of the auxiliary traces. Setup the auxtrace queues and data structures for s390. A raw dump of the perf.data file now does not show an error when an auxtrace event is encountered. Output before: [root@s35lp76 perf]# ./perf report -D -i perf.data.auxtrace 0x128 [0x10]: failed to process type: 70 Error: failed to process sample 0x128 [0x10]: event: 70 . . ... raw event: size 16 bytes . 0000: 00 00 00 46 00 00 00 10 00 00 00 00 00 00 00 00 ...F............ 0x128 [0x10]: PERF_RECORD_AUXTRACE_INFO type: 0 [root@s35lp76 perf]# Output after: # ./perf report -D -i perf.data.auxtrace |fgrep PERF_RECORD_AUXTRACE 0 0 0x128 [0x10]: PERF_RECORD_AUXTRACE_INFO type: 5 0 0 0x25a66 [0x30]: PERF_RECORD_AUXTRACE size: 0x40000 offset: 0 ref: 0 idx: 4 tid: -1 cpu: 4 .... Additional notes about the underlying hardware and software implementation, provided by Hendrik Brueckner (see Link: below). ============================================================================= The CPU-Measurement Facility (CPU-MF) provides a set of functions to obtain performance information on the mainframe. Basically, it was introduced with System z10 years ago for the z/Architecture, that means, 64-bit. For Linux, there are two facilities of interest, counter facility and sampling facility. The counter facility provides hardware counters for instructions, cycles, crypto-activities, and many more. The sampling facility is a hardware sampler that when started will write samples at a particular interval into a sampling buffer. At some point, for example, if a sample block is full, it generates an interrupt to collect samples (while the sampler continues to run). Few years ago, I started to provide the a perf PMU to use the counter and sampling facilities. Recently, the device driver was updated to also "export" the sampling buffer into the AUX area. Thomas now completed the related perf work to interpret and process these AUX data. If people are more interested in the sampling facility, they can have a look into: - The Load-Program-Parameter and the CPU-Measurement Facilities, SA23-2260-05 http://www-01.ibm.com/support/docview.wss?uid=isg26fcd1cc32246f4c8852574ce0044734a and to learn how-to use it for Linux on Z, have look at chapter 54, "Using the CPU-measurement facilities" in the: - Device Drivers, Features, and Commands, SC33-8411-34 http://public.dhe.ibm.com/software/dw/linux390/docu/l416dd34.pdf ============================================================================= Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Link: http://lkml.kernel.org/r/20180803100758.GA28475@linux.ibm.com Cc: Heiko Carstens Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180802074622.13641-2-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/s390/util/auxtrace.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 3 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/s390-cpumsf.c | 123 +++++++++++++++++++++++++++++++++++ tools/perf/util/s390-cpumsf.h | 21 ++++++ 6 files changed, 150 insertions(+) create mode 100644 tools/perf/util/s390-cpumsf.c create mode 100644 tools/perf/util/s390-cpumsf.h diff --git a/tools/perf/arch/s390/util/auxtrace.c b/tools/perf/arch/s390/util/auxtrace.c index 3afe8256eff2..44c857388897 100644 --- a/tools/perf/arch/s390/util/auxtrace.c +++ b/tools/perf/arch/s390/util/auxtrace.c @@ -30,6 +30,7 @@ cpumsf_info_fill(struct auxtrace_record *itr __maybe_unused, struct auxtrace_info_event *auxtrace_info __maybe_unused, size_t priv_size __maybe_unused) { + auxtrace_info->type = PERF_AUXTRACE_S390_CPUMSF; return 0; } diff --git a/tools/perf/util/Build b/tools/perf/util/Build index b604ef334dc9..7efe15b9618d 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -87,6 +87,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-pt.o libperf-$(CONFIG_AUXTRACE) += intel-bts.o libperf-$(CONFIG_AUXTRACE) += arm-spe.o libperf-$(CONFIG_AUXTRACE) += arm-spe-pkt-decoder.o +libperf-$(CONFIG_AUXTRACE) += s390-cpumsf.o ifdef CONFIG_LIBOPENCSD libperf-$(CONFIG_AUXTRACE) += cs-etm.o diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index d056447520a2..ae8c37b219c9 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -56,6 +56,7 @@ #include "intel-pt.h" #include "intel-bts.h" #include "arm-spe.h" +#include "s390-cpumsf.h" #include "sane_ctype.h" #include "symbol/kallsyms.h" @@ -920,6 +921,8 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, return arm_spe_process_auxtrace_info(event, session); case PERF_AUXTRACE_CS_ETM: return cs_etm__process_auxtrace_info(event, session); + case PERF_AUXTRACE_S390_CPUMSF: + return s390_cpumsf_process_auxtrace_info(event, session); case PERF_AUXTRACE_UNKNOWN: default: return -EINVAL; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index e731f55da072..71fc3bd74299 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -44,6 +44,7 @@ enum auxtrace_type { PERF_AUXTRACE_INTEL_BTS, PERF_AUXTRACE_CS_ETM, PERF_AUXTRACE_ARM_SPE, + PERF_AUXTRACE_S390_CPUMSF, }; enum itrace_period_type { diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c new file mode 100644 index 000000000000..e9a5ea21dbbf --- /dev/null +++ b/tools/perf/util/s390-cpumsf.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright IBM Corp. 2018 + * Auxtrace support for s390 CPU-Measurement Sampling Facility + * + * Author(s): Thomas Richter + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cpumap.h" +#include "color.h" +#include "evsel.h" +#include "evlist.h" +#include "machine.h" +#include "session.h" +#include "util.h" +#include "thread.h" +#include "debug.h" +#include "auxtrace.h" +#include "s390-cpumsf.h" + +struct s390_cpumsf { + struct auxtrace auxtrace; + struct auxtrace_queues queues; + struct auxtrace_heap heap; + struct perf_session *session; + struct machine *machine; + u32 auxtrace_type; + u32 pmu_type; +}; + +static int +s390_cpumsf_process_event(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct perf_tool *tool __maybe_unused) +{ + return 0; +} + +static int +s390_cpumsf_process_auxtrace_event(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_tool *tool __maybe_unused) +{ + return 0; +} + +static int s390_cpumsf_flush(struct perf_session *session __maybe_unused, + struct perf_tool *tool __maybe_unused) +{ + return 0; +} + +static void s390_cpumsf_free_events(struct perf_session *session) +{ + struct s390_cpumsf *sf = container_of(session->auxtrace, + struct s390_cpumsf, + auxtrace); + struct auxtrace_queues *queues = &sf->queues; + unsigned int i; + + for (i = 0; i < queues->nr_queues; i++) + zfree(&queues->queue_array[i].priv); + auxtrace_queues__free(queues); +} + +static void s390_cpumsf_free(struct perf_session *session) +{ + struct s390_cpumsf *sf = container_of(session->auxtrace, + struct s390_cpumsf, + auxtrace); + + auxtrace_heap__free(&sf->heap); + s390_cpumsf_free_events(session); + session->auxtrace = NULL; + free(sf); +} + +int s390_cpumsf_process_auxtrace_info(union perf_event *event, + struct perf_session *session) +{ + struct auxtrace_info_event *auxtrace_info = &event->auxtrace_info; + struct s390_cpumsf *sf; + int err; + + if (auxtrace_info->header.size < sizeof(struct auxtrace_info_event)) + return -EINVAL; + + sf = zalloc(sizeof(struct s390_cpumsf)); + if (sf == NULL) + return -ENOMEM; + + err = auxtrace_queues__init(&sf->queues); + if (err) + goto err_free; + + sf->session = session; + sf->machine = &session->machines.host; /* No kvm support */ + sf->auxtrace_type = auxtrace_info->type; + sf->pmu_type = PERF_TYPE_RAW; + + sf->auxtrace.process_event = s390_cpumsf_process_event; + sf->auxtrace.process_auxtrace_event = s390_cpumsf_process_auxtrace_event; + sf->auxtrace.flush_events = s390_cpumsf_flush; + sf->auxtrace.free_events = s390_cpumsf_free_events; + sf->auxtrace.free = s390_cpumsf_free; + session->auxtrace = &sf->auxtrace; + + return 0; + +err_free: + free(sf); + return err; +} diff --git a/tools/perf/util/s390-cpumsf.h b/tools/perf/util/s390-cpumsf.h new file mode 100644 index 000000000000..fb64d100555c --- /dev/null +++ b/tools/perf/util/s390-cpumsf.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright IBM Corp. 2018 + * Auxtrace support for s390 CPU-Measurement Sampling Facility + * + * Author(s): Thomas Richter + */ + +#ifndef INCLUDE__PERF_S390_CPUMSF_H +#define INCLUDE__PERF_S390_CPUMSF_H + +union perf_event; +struct perf_session; +struct perf_pmu; + +struct auxtrace_record * +s390_cpumsf_recording_init(int *err, struct perf_pmu *s390_cpumsf_pmu); + +int s390_cpumsf_process_auxtrace_info(union perf_event *event, + struct perf_session *session); +#endif -- cgit v1.2.3 From 2b1444f2e28be94b8f0b37376e1c619fd8cad63b Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Thu, 2 Aug 2018 09:46:21 +0200 Subject: perf report: Add raw report support for s390 auxiliary trace Add support for s390 auxiliary trace support. Use 'perf record -e rbd000' to create the perf.data file. The event also has the symbolic name SF_CYCLES_BASIC_DIAG, using 'perf record -e SF_CYCLES_BASIC_DIAG' is equivalent. Use 'perf report -D' to display the auxiliary trace data. Output before: 0 0 0x25a66 [0x30]: PERF_RECORD_AUXTRACE size: 0x40000 offset: 0 ref: 0 idx: 4 tid: -1 cpu: 4 Nothing else Output after: 0 0 0x25a66 [0x30]: PERF_RECORD_AUXTRACE size: 0x40000 offset: 0 ref: 0 idx: 4 tid: -1 cpu: 4 . . ... s390 AUX data: size 262144 bytes [00000000] Basic Def:0001 Inst:0000 TW AS:3 ASN:0xffff IA:0x0000000000c2f1bc CL:1 HPP:0x8000000000000000 GPP:000000000000000000 [0x000020] Diag Def:8005 [0x0000bf] Basic Def:0001 Inst:0000 TW AS:3 ASN:0xffff IA:0x0000000000c2f1bc CL:1 HPP:0x8000000000000000 GPP:000000000000000000 [0x0000df] Diag Def:8005 [0x00017e] Basic Def:0001 Inst:0000 TW AS:3 ASN:0xffff IA:0x0000000000c2f1bc CL:1 HPP:0x8000000000000000 GPP:000000000000000000 .... [0x000fc0] Trailer F T bsdes:32 dsdes:159 Overflow:0 Time:0xd4ab59a8450fa108 C:1 TOD:0xd4ab4ec98ceb3832 1:0x8000000000000000 2:0xd4ab4ec98ceb3832 This output is shown for every sampled data block. The output contains the - basic-sampling data entry - diagnostic-sampling data entry - trailer entry The basic sampling entry and diagnostic sampling entry sizes can be extracted using the trailer entries in the SDB. On older hardware these values (bsdes and dsdes in the trailer entry) are reserved and zero. Older hardware use hard coded values based on the s390 machine type. Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Cc: Heiko Carstens Cc: Martin Schwidefsky Cc: Michael Ellerman Link: http://lkml.kernel.org/r/20180802074622.13641-3-tmricht@linux.ibm.com Link: http://lkml.kernel.org/r/eda2632e-7919-5ffd-5f68-821e77d216fa@linux.ibm.com [ Merged a fix for a 'tipe puned' problem reported by Michael Ellerman see last Link tag. ] [ Removed __packed from two structs, they're already naturally packed and having that. ] [ attribute breaks the build in gcc 8.1.1 mips, 4.4.7 x86_64, 7.1.1 ARCompact ISA, etc) ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/s390-cpumsf-kernel.h | 71 ++++++++++ tools/perf/util/s390-cpumsf.c | 247 ++++++++++++++++++++++++++++++++++- 2 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/s390-cpumsf-kernel.h diff --git a/tools/perf/util/s390-cpumsf-kernel.h b/tools/perf/util/s390-cpumsf-kernel.h new file mode 100644 index 000000000000..de8c7ad0eca8 --- /dev/null +++ b/tools/perf/util/s390-cpumsf-kernel.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Auxtrace support for s390 CPU measurement sampling facility + * + * Copyright IBM Corp. 2018 + * Author(s): Hendrik Brueckner + * Thomas Richter + */ +#ifndef S390_CPUMSF_KERNEL_H +#define S390_CPUMSF_KERNEL_H + +#define S390_CPUMSF_PAGESZ 4096 /* Size of sample block units */ +#define S390_CPUMSF_DIAG_DEF_FIRST 0x8001 /* Diagnostic entry lowest id */ + +struct hws_basic_entry { + unsigned int def:16; /* 0-15 Data Entry Format */ + unsigned int R:4; /* 16-19 reserved */ + unsigned int U:4; /* 20-23 Number of unique instruct. */ + unsigned int z:2; /* zeros */ + unsigned int T:1; /* 26 PSW DAT mode */ + unsigned int W:1; /* 27 PSW wait state */ + unsigned int P:1; /* 28 PSW Problem state */ + unsigned int AS:2; /* 29-30 PSW address-space control */ + unsigned int I:1; /* 31 entry valid or invalid */ + unsigned int CL:2; /* 32-33 Configuration Level */ + unsigned int:14; + unsigned int prim_asn:16; /* primary ASN */ + unsigned long long ia; /* Instruction Address */ + unsigned long long gpp; /* Guest Program Parameter */ + unsigned long long hpp; /* Host Program Parameter */ +}; + +struct hws_diag_entry { + unsigned int def:16; /* 0-15 Data Entry Format */ + unsigned int R:15; /* 16-19 and 20-30 reserved */ + unsigned int I:1; /* 31 entry valid or invalid */ + u8 data[]; /* Machine-dependent sample data */ +}; + +struct hws_combined_entry { + struct hws_basic_entry basic; /* Basic-sampling data entry */ + struct hws_diag_entry diag; /* Diagnostic-sampling data entry */ +}; + +struct hws_trailer_entry { + union { + struct { + unsigned int f:1; /* 0 - Block Full Indicator */ + unsigned int a:1; /* 1 - Alert request control */ + unsigned int t:1; /* 2 - Timestamp format */ + unsigned int:29; /* 3 - 31: Reserved */ + unsigned int bsdes:16; /* 32-47: size of basic SDE */ + unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */ + }; + unsigned long long flags; /* 0 - 64: All indicators */ + }; + unsigned long long overflow; /* 64 - sample Overflow count */ + unsigned char timestamp[16]; /* 16 - 31 timestamp */ + unsigned long long reserved1; /* 32 -Reserved */ + unsigned long long reserved2; /* */ + union { /* 48 - reserved for programming use */ + struct { + unsigned long long clock_base:1; /* in progusage2 */ + unsigned long long progusage1:63; + unsigned long long progusage2; + }; + unsigned long long progusage[2]; + }; +}; + +#endif diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index e9a5ea21dbbf..14728b0834c6 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -26,6 +26,7 @@ #include "debug.h" #include "auxtrace.h" #include "s390-cpumsf.h" +#include "s390-cpumsf-kernel.h" struct s390_cpumsf { struct auxtrace auxtrace; @@ -35,8 +36,213 @@ struct s390_cpumsf { struct machine *machine; u32 auxtrace_type; u32 pmu_type; + u16 machine_type; }; +/* Display s390 CPU measurement facility basic-sampling data entry */ +static bool s390_cpumsf_basic_show(const char *color, size_t pos, + struct hws_basic_entry *basic) +{ + if (basic->def != 1) { + pr_err("Invalid AUX trace basic entry [%#08zx]\n", pos); + return false; + } + color_fprintf(stdout, color, " [%#08zx] Basic Def:%04x Inst:%#04x" + " %c%c%c%c AS:%d ASN:%#04x IA:%#018llx\n" + "\t\tCL:%d HPP:%#018llx GPP:%#018llx\n", + pos, basic->def, basic->U, + basic->T ? 'T' : ' ', + basic->W ? 'W' : ' ', + basic->P ? 'P' : ' ', + basic->I ? 'I' : ' ', + basic->AS, basic->prim_asn, basic->ia, basic->CL, + basic->hpp, basic->gpp); + return true; +} + +/* Display s390 CPU measurement facility diagnostic-sampling data entry */ +static bool s390_cpumsf_diag_show(const char *color, size_t pos, + struct hws_diag_entry *diag) +{ + if (diag->def < S390_CPUMSF_DIAG_DEF_FIRST) { + pr_err("Invalid AUX trace diagnostic entry [%#08zx]\n", pos); + return false; + } + color_fprintf(stdout, color, " [%#08zx] Diag Def:%04x %c\n", + pos, diag->def, diag->I ? 'I' : ' '); + return true; +} + +/* Return TOD timestamp contained in an trailer entry */ +static unsigned long long trailer_timestamp(struct hws_trailer_entry *te) +{ + /* te->t set: TOD in STCKE format, bytes 8-15 + * to->t not set: TOD in STCK format, bytes 0-7 + */ + unsigned long long ts; + + memcpy(&ts, &te->timestamp[te->t], sizeof(ts)); + return ts; +} + +/* Display s390 CPU measurement facility trailer entry */ +static bool s390_cpumsf_trailer_show(const char *color, size_t pos, + struct hws_trailer_entry *te) +{ + if (te->bsdes != sizeof(struct hws_basic_entry)) { + pr_err("Invalid AUX trace trailer entry [%#08zx]\n", pos); + return false; + } + color_fprintf(stdout, color, " [%#08zx] Trailer %c%c%c bsdes:%d" + " dsdes:%d Overflow:%lld Time:%#llx\n" + "\t\tC:%d TOD:%#lx 1:%#llx 2:%#llx\n", + pos, + te->f ? 'F' : ' ', + te->a ? 'A' : ' ', + te->t ? 'T' : ' ', + te->bsdes, te->dsdes, te->overflow, + trailer_timestamp(te), te->clock_base, te->progusage2, + te->progusage[0], te->progusage[1]); + return true; +} + +/* Test a sample data block. It must be 4KB or a multiple thereof in size and + * 4KB page aligned. Each sample data page has a trailer entry at the + * end which contains the sample entry data sizes. + * + * Return true if the sample data block passes the checks and set the + * basic set entry size and diagnostic set entry size. + * + * Return false on failure. + * + * Note: Old hardware does not set the basic or diagnostic entry sizes + * in the trailer entry. Use the type number instead. + */ +static bool s390_cpumsf_validate(int machine_type, + unsigned char *buf, size_t len, + unsigned short *bsdes, + unsigned short *dsdes) +{ + struct hws_basic_entry *basic = (struct hws_basic_entry *)buf; + struct hws_trailer_entry *te; + + *dsdes = *bsdes = 0; + if (len & (S390_CPUMSF_PAGESZ - 1)) /* Illegal size */ + return false; + if (basic->def != 1) /* No basic set entry, must be first */ + return false; + /* Check for trailer entry at end of SDB */ + te = (struct hws_trailer_entry *)(buf + S390_CPUMSF_PAGESZ + - sizeof(*te)); + *bsdes = te->bsdes; + *dsdes = te->dsdes; + if (!te->bsdes && !te->dsdes) { + /* Very old hardware, use CPUID */ + switch (machine_type) { + case 2097: + case 2098: + *dsdes = 64; + *bsdes = 32; + break; + case 2817: + case 2818: + *dsdes = 74; + *bsdes = 32; + break; + case 2827: + case 2828: + *dsdes = 85; + *bsdes = 32; + break; + default: + /* Illegal trailer entry */ + return false; + } + } + return true; +} + +/* Return true if there is room for another entry */ +static bool s390_cpumsf_reached_trailer(size_t entry_sz, size_t pos) +{ + size_t payload = S390_CPUMSF_PAGESZ - sizeof(struct hws_trailer_entry); + + if (payload - (pos & (S390_CPUMSF_PAGESZ - 1)) < entry_sz) + return false; + return true; +} + +/* Dump an auxiliary buffer. These buffers are multiple of + * 4KB SDB pages. + */ +static void s390_cpumsf_dump(struct s390_cpumsf *sf, + unsigned char *buf, size_t len) +{ + const char *color = PERF_COLOR_BLUE; + struct hws_basic_entry *basic; + struct hws_diag_entry *diag; + size_t pos = 0; + unsigned short bsdes, dsdes; + + color_fprintf(stdout, color, + ". ... s390 AUX data: size %zu bytes\n", + len); + + if (!s390_cpumsf_validate(sf->machine_type, buf, len, &bsdes, + &dsdes)) { + pr_err("Invalid AUX trace data block size:%zu" + " (type:%d bsdes:%hd dsdes:%hd)\n", + len, sf->machine_type, bsdes, dsdes); + return; + } + + /* s390 kernel always returns 4KB blocks fully occupied, + * no partially filled SDBs. + */ + while (pos < len) { + /* Handle Basic entry */ + basic = (struct hws_basic_entry *)(buf + pos); + if (s390_cpumsf_basic_show(color, pos, basic)) + pos += bsdes; + else + return; + + /* Handle Diagnostic entry */ + diag = (struct hws_diag_entry *)(buf + pos); + if (s390_cpumsf_diag_show(color, pos, diag)) + pos += dsdes; + else + return; + + /* Check for trailer entry */ + if (!s390_cpumsf_reached_trailer(bsdes + dsdes, pos)) { + /* Show trailer entry */ + struct hws_trailer_entry te; + + pos = (pos + S390_CPUMSF_PAGESZ) + & ~(S390_CPUMSF_PAGESZ - 1); + pos -= sizeof(te); + memcpy(&te, buf + pos, sizeof(te)); + /* Set descriptor sizes in case of old hardware + * where these values are not set. + */ + te.bsdes = bsdes; + te.dsdes = dsdes; + if (s390_cpumsf_trailer_show(color, pos, &te)) + pos += sizeof(te); + else + return; + } + } +} + +static void s390_cpumsf_dump_event(struct s390_cpumsf *sf, unsigned char *buf, + size_t len) +{ + printf(".\n"); + s390_cpumsf_dump(sf, buf, len); +} + static int s390_cpumsf_process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused, @@ -47,10 +253,40 @@ s390_cpumsf_process_event(struct perf_session *session __maybe_unused, } static int -s390_cpumsf_process_auxtrace_event(struct perf_session *session __maybe_unused, +s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, struct perf_tool *tool __maybe_unused) { + struct s390_cpumsf *sf = container_of(session->auxtrace, + struct s390_cpumsf, + auxtrace); + + int fd = perf_data__fd(session->data); + struct auxtrace_buffer *buffer; + off_t data_offset; + int err; + + if (perf_data__is_pipe(session->data)) { + data_offset = 0; + } else { + data_offset = lseek(fd, 0, SEEK_CUR); + if (data_offset == -1) + return -errno; + } + + err = auxtrace_queues__add_event(&sf->queues, session, event, + data_offset, &buffer); + if (err) + return err; + + /* Dump here after copying piped trace out of the pipe */ + if (dump_trace) { + if (auxtrace_buffer__get_data(buffer, fd)) { + s390_cpumsf_dump_event(sf, buffer->data, + buffer->size); + auxtrace_buffer__put_data(buffer); + } + } return 0; } @@ -85,6 +321,14 @@ static void s390_cpumsf_free(struct perf_session *session) free(sf); } +static int s390_cpumsf_get_type(const char *cpuid) +{ + int ret, family = 0; + + ret = sscanf(cpuid, "%*[^,],%u", &family); + return (ret == 1) ? family : 0; +} + int s390_cpumsf_process_auxtrace_info(union perf_event *event, struct perf_session *session) { @@ -107,6 +351,7 @@ int s390_cpumsf_process_auxtrace_info(union perf_event *event, sf->machine = &session->machines.host; /* No kvm support */ sf->auxtrace_type = auxtrace_info->type; sf->pmu_type = PERF_TYPE_RAW; + sf->machine_type = s390_cpumsf_get_type(session->evlist->env->cpuid); sf->auxtrace.process_event = s390_cpumsf_process_event; sf->auxtrace.process_auxtrace_event = s390_cpumsf_process_auxtrace_event; -- cgit v1.2.3 From 33d9e1832e528ff61f481558882ee0f82e288440 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Thu, 2 Aug 2018 09:46:22 +0200 Subject: perf report: Add GUI report support for s390 auxiliary trace Add support for s390 auxiliary trace support. Use 'perf record -e rbd000 -- ls' to create the perf.data file. Use 'perf report' to display the auxiliary trace data. Output before: [root@s35lp76 perf]# ./perf report --stdio 0x128 [0x10]: failed to process type: 70 Error: failed to process sample [root@s35lp76 perf]# Output after: [root@s35lp76 perf]# ./perf report --stdio 18.21% 18.21% ls [kernel.kallsyms] [k] ftrace_likely_update 9.52% 9.52% ls [kernel.kallsyms] [k] lock_acquire 9.38% 9.38% ls [kernel.kallsyms] [k] lock_release 3.45% 3.45% ls [kernel.kallsyms] [k] lock_acquired 2.88% 2.88% ls [kernel.kallsyms] [k] link_path_walk 2.63% 2.63% ls [kernel.kallsyms] [k] __d_lookup 2.38% 2.38% ls [kernel.kallsyms] [k] __d_lookup_rcu 2.04% 2.04% ls [kernel.kallsyms] [k] ___might_sleep 1.83% 1.83% ls [kernel.kallsyms] [k] debug_lockdep_rcu_enabled 1.44% 1.44% ls [kernel.kallsyms] [k] dput .... Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Cc: Heiko Carstens Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180802074622.13641-4-tmricht@linux.ibm.com [ Use PRI[xd]64 to fix the build on debian:experimental-x-mips (gcc 8.1.0) and others ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/s390-cpumsf.c | 593 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 585 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 14728b0834c6..d2c78ffd9fee 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -4,6 +4,138 @@ * Auxtrace support for s390 CPU-Measurement Sampling Facility * * Author(s): Thomas Richter + * + * Auxiliary traces are collected during 'perf record' using rbd000 event. + * Several PERF_RECORD_XXX are generated during recording: + * + * PERF_RECORD_AUX: + * Records that new data landed in the AUX buffer part. + * PERF_RECORD_AUXTRACE: + * Defines auxtrace data. Followed by the actual data. The contents of + * the auxtrace data is dependent on the event and the CPU. + * This record is generated by perf record command. For details + * see Documentation/perf.data-file-format.txt. + * PERF_RECORD_AUXTRACE_INFO: + * Defines a table of contains for PERF_RECORD_AUXTRACE records. This + * record is generated during 'perf record' command. Each record contains up + * to 256 entries describing offset and size of the AUXTRACE data in the + * perf.data file. + * PERF_RECORD_AUXTRACE_ERROR: + * Indicates an error during AUXTRACE collection such as buffer overflow. + * PERF_RECORD_FINISHED_ROUND: + * Perf events are not necessarily in time stamp order, as they can be + * collected in parallel on different CPUs. If the events should be + * processed in time order they need to be sorted first. + * Perf report guarantees that there is no reordering over a + * PERF_RECORD_FINISHED_ROUND boundary event. All perf records with a + * time stamp lower than this record are processed (and displayed) before + * the succeeding perf record are processed. + * + * These records are evaluated during perf report command. + * + * 1. PERF_RECORD_AUXTRACE_INFO is used to set up the infrastructure for + * auxiliary trace data processing. See s390_cpumsf_process_auxtrace_info() + * below. + * Auxiliary trace data is collected per CPU. To merge the data into the report + * an auxtrace_queue is created for each CPU. It is assumed that the auxtrace + * data is in ascending order. + * + * Each queue has a double linked list of auxtrace_buffers. This list contains + * the offset and size of a CPU's auxtrace data. During auxtrace processing + * the data portion is mmap()'ed. + * + * To sort the queues in chronological order, all queue access is controlled + * by the auxtrace_heap. This is basicly a stack, each stack element has two + * entries, the queue number and a time stamp. However the stack is sorted by + * the time stamps. The highest time stamp is at the bottom the lowest + * (nearest) time stamp is at the top. That sort order is maintained at all + * times! + * + * After the auxtrace infrastructure has been setup, the auxtrace queues are + * filled with data (offset/size pairs) and the auxtrace_heap is populated. + * + * 2. PERF_RECORD_XXX processing triggers access to the auxtrace_queues. + * Each record is handled by s390_cpumsf_process_event(). The time stamp of + * the perf record is compared with the time stamp located on the auxtrace_heap + * top element. If that time stamp is lower than the time stamp from the + * record sample, the auxtrace queues will be processed. As auxtrace queues + * control many auxtrace_buffers and each buffer can be quite large, the + * auxtrace buffer might be processed only partially. In this case the + * position in the auxtrace_buffer of that queue is remembered and the time + * stamp of the last processed entry of the auxtrace_buffer replaces the + * current auxtrace_heap top. + * + * 3. Auxtrace_queues might run of out data and are feeded by the + * PERF_RECORD_AUXTRACE handling, see s390_cpumsf_process_auxtrace_event(). + * + * Event Generation + * Each sampling-data entry in the auxilary trace data generates a perf sample. + * This sample is filled + * with data from the auxtrace such as PID/TID, instruction address, CPU state, + * etc. This sample is processed with perf_session__deliver_synth_event() to + * be included into the GUI. + * + * 4. PERF_RECORD_FINISHED_ROUND event is used to process all the remaining + * auxiliary traces entries until the time stamp of this record is reached + * auxtrace_heap top. This is triggered by ordered_event->deliver(). + * + * + * Perf event processing. + * Event processing of PERF_RECORD_XXX entries relies on time stamp entries. + * This is the function call sequence: + * + * __cmd_report() + * | + * perf_session__process_events() + * | + * __perf_session__process_events() + * | + * perf_session__process_event() + * | This functions splits the PERF_RECORD_XXX records. + * | - Those generated by perf record command (type number equal or higher + * | than PERF_RECORD_USER_TYPE_START) are handled by + * | perf_session__process_user_event(see below) + * | - Those generated by the kernel are handled by + * | perf_evlist__parse_sample_timestamp() + * | + * perf_evlist__parse_sample_timestamp() + * | Extract time stamp from sample data. + * | + * perf_session__queue_event() + * | If timestamp is positive the sample is entered into an ordered_event + * | list, sort order is the timestamp. The event processing is deferred until + * | later (see perf_session__process_user_event()). + * | Other timestamps (0 or -1) are handled immediately by + * | perf_session__deliver_event(). These are events generated at start up + * | of command perf record. They create PERF_RECORD_COMM and PERF_RECORD_MMAP* + * | records. They are needed to create a list of running processes and its + * | memory mappings and layout. They are needed at the beginning to enable + * | command perf report to create process trees and memory mappings. + * | + * perf_session__deliver_event() + * | Delivers a PERF_RECORD_XXX entry for handling. + * | + * auxtrace__process_event() + * | The timestamp of the PERF_RECORD_XXX entry is taken to correlate with + * | time stamps from the auxiliary trace buffers. This enables + * | synchronization between auxiliary trace data and the events on the + * | perf.data file. + * | + * machine__deliver_event() + * | Handles the PERF_RECORD_XXX event. This depends on the record type. + * It might update the process tree, update a process memory map or enter + * a sample with IP and call back chain data into GUI data pool. + * + * + * Deferred processing determined by perf_session__process_user_event() is + * finally processed when a PERF_RECORD_FINISHED_ROUND is encountered. These + * are generated during command perf record. + * The timestamp of PERF_RECORD_FINISHED_ROUND event is taken to process all + * PERF_RECORD_XXX entries stored in the ordered_event list. This list was + * built up while reading the perf.data file. + * Each event is now processed by calling perf_session__deliver_event(). + * This enables time synchronization between the data in the perf.data file and + * the data in the auxiliary trace buffers. */ #include @@ -37,6 +169,14 @@ struct s390_cpumsf { u32 auxtrace_type; u32 pmu_type; u16 machine_type; + bool data_queued; +}; + +struct s390_cpumsf_queue { + struct s390_cpumsf *sf; + unsigned int queue_nr; + struct auxtrace_buffer *buffer; + int cpu; }; /* Display s390 CPU measurement facility basic-sampling data entry */ @@ -181,8 +321,8 @@ static void s390_cpumsf_dump(struct s390_cpumsf *sf, const char *color = PERF_COLOR_BLUE; struct hws_basic_entry *basic; struct hws_diag_entry *diag; - size_t pos = 0; unsigned short bsdes, dsdes; + size_t pos = 0; color_fprintf(stdout, color, ". ... s390 AUX data: size %zu bytes\n", @@ -243,15 +383,414 @@ static void s390_cpumsf_dump_event(struct s390_cpumsf *sf, unsigned char *buf, s390_cpumsf_dump(sf, buf, len); } +#define S390_LPP_PID_MASK 0xffffffff + +static bool s390_cpumsf_make_event(size_t pos, + struct hws_basic_entry *basic, + struct s390_cpumsf_queue *sfq) +{ + struct perf_sample sample = { + .ip = basic->ia, + .pid = basic->hpp & S390_LPP_PID_MASK, + .tid = basic->hpp & S390_LPP_PID_MASK, + .cpumode = PERF_RECORD_MISC_CPUMODE_UNKNOWN, + .cpu = sfq->cpu, + .period = 1 + }; + union perf_event event; + + memset(&event, 0, sizeof(event)); + if (basic->CL == 1) /* Native LPAR mode */ + sample.cpumode = basic->P ? PERF_RECORD_MISC_USER + : PERF_RECORD_MISC_KERNEL; + else if (basic->CL == 2) /* Guest kernel/user space */ + sample.cpumode = basic->P ? PERF_RECORD_MISC_GUEST_USER + : PERF_RECORD_MISC_GUEST_KERNEL; + else if (basic->gpp || basic->prim_asn != 0xffff) + /* Use heuristics on old hardware */ + sample.cpumode = basic->P ? PERF_RECORD_MISC_GUEST_USER + : PERF_RECORD_MISC_GUEST_KERNEL; + else + sample.cpumode = basic->P ? PERF_RECORD_MISC_USER + : PERF_RECORD_MISC_KERNEL; + + event.sample.header.type = PERF_RECORD_SAMPLE; + event.sample.header.misc = sample.cpumode; + event.sample.header.size = sizeof(struct perf_event_header); + + pr_debug4("%s pos:%#zx ip:%#" PRIx64 " P:%d CL:%d pid:%d.%d cpumode:%d cpu:%d\n", + __func__, pos, sample.ip, basic->P, basic->CL, sample.pid, + sample.tid, sample.cpumode, sample.cpu); + if (perf_session__deliver_synth_event(sfq->sf->session, &event, + &sample)) { + pr_err("s390 Auxiliary Trace: failed to deliver event\n"); + return false; + } + return true; +} + +static unsigned long long get_trailer_time(const unsigned char *buf) +{ + struct hws_trailer_entry *te; + unsigned long long aux_time; + + te = (struct hws_trailer_entry *)(buf + S390_CPUMSF_PAGESZ + - sizeof(*te)); + + if (!te->clock_base) /* TOD_CLOCK_BASE value missing */ + return 0; + + /* Correct calculation to convert time stamp in trailer entry to + * nano seconds (taken from arch/s390 function tod_to_ns()). + * TOD_CLOCK_BASE is stored in trailer entry member progusage2. + */ + aux_time = trailer_timestamp(te) - te->progusage2; + aux_time = (aux_time >> 9) * 125 + (((aux_time & 0x1ff) * 125) >> 9); + return aux_time; +} + +/* Process the data samples of a single queue. The first parameter is a + * pointer to the queue, the second parameter is the time stamp. This + * is the time stamp: + * - of the event that triggered this processing. + * - or the time stamp when the last proccesing of this queue stopped. + * In this case it stopped at a 4KB page boundary and record the + * position on where to continue processing on the next invocation + * (see buffer->use_data and buffer->use_size). + * + * When this function returns the second parameter is updated to + * reflect the time stamp of the last processed auxiliary data entry + * (taken from the trailer entry of that page). The caller uses this + * returned time stamp to record the last processed entry in this + * queue. + * + * The function returns: + * 0: Processing successful. The second parameter returns the + * time stamp from the trailer entry until which position + * processing took place. Subsequent calls resume from this + * position. + * <0: An error occurred during processing. The second parameter + * returns the maximum time stamp. + * >0: Done on this queue. The second parameter returns the + * maximum time stamp. + */ +static int s390_cpumsf_samples(struct s390_cpumsf_queue *sfq, u64 *ts) +{ + struct s390_cpumsf *sf = sfq->sf; + unsigned char *buf = sfq->buffer->use_data; + size_t len = sfq->buffer->use_size; + struct hws_basic_entry *basic; + unsigned short bsdes, dsdes; + size_t pos = 0; + int err = 1; + u64 aux_ts; + + if (!s390_cpumsf_validate(sf->machine_type, buf, len, &bsdes, + &dsdes)) { + *ts = ~0ULL; + return -1; + } + + /* Get trailer entry time stamp and check if entries in + * this auxiliary page are ready for processing. If the + * time stamp of the first entry is too high, whole buffer + * can be skipped. In this case return time stamp. + */ + aux_ts = get_trailer_time(buf); + if (!aux_ts) { + pr_err("[%#08" PRIx64 "] Invalid AUX trailer entry TOD clock base\n", + sfq->buffer->data_offset); + aux_ts = ~0ULL; + goto out; + } + if (aux_ts > *ts) { + *ts = aux_ts; + return 0; + } + + while (pos < len) { + /* Handle Basic entry */ + basic = (struct hws_basic_entry *)(buf + pos); + if (s390_cpumsf_make_event(pos, basic, sfq)) + pos += bsdes; + else { + err = -EBADF; + goto out; + } + + pos += dsdes; /* Skip diagnositic entry */ + + /* Check for trailer entry */ + if (!s390_cpumsf_reached_trailer(bsdes + dsdes, pos)) { + pos = (pos + S390_CPUMSF_PAGESZ) + & ~(S390_CPUMSF_PAGESZ - 1); + /* Check existence of next page */ + if (pos >= len) + break; + aux_ts = get_trailer_time(buf + pos); + if (!aux_ts) { + aux_ts = ~0ULL; + goto out; + } + if (aux_ts > *ts) { + *ts = aux_ts; + sfq->buffer->use_data += pos; + sfq->buffer->use_size -= pos; + return 0; + } + } + } +out: + *ts = aux_ts; + sfq->buffer->use_size = 0; + sfq->buffer->use_data = NULL; + return err; /* Buffer completely scanned or error */ +} + +/* Run the s390 auxiliary trace decoder. + * Select the queue buffer to operate on, the caller already selected + * the proper queue, depending on second parameter 'ts'. + * This is the time stamp until which the auxiliary entries should + * be processed. This value is updated by called functions and + * returned to the caller. + * + * Resume processing in the current buffer. If there is no buffer + * get a new buffer from the queue and setup start position for + * processing. + * When a buffer is completely processed remove it from the queue + * before returning. + * + * This function returns + * 1: When the queue is empty. Second parameter will be set to + * maximum time stamp. + * 0: Normal processing done. + * <0: Error during queue buffer setup. This causes the caller + * to stop processing completely. + */ +static int s390_cpumsf_run_decoder(struct s390_cpumsf_queue *sfq, + u64 *ts) +{ + + struct auxtrace_buffer *buffer; + struct auxtrace_queue *queue; + int err; + + queue = &sfq->sf->queues.queue_array[sfq->queue_nr]; + + /* Get buffer and last position in buffer to resume + * decoding the auxiliary entries. One buffer might be large + * and decoding might stop in between. This depends on the time + * stamp of the trailer entry in each page of the auxiliary + * data and the time stamp of the event triggering the decoding. + */ + if (sfq->buffer == NULL) { + sfq->buffer = buffer = auxtrace_buffer__next(queue, + sfq->buffer); + if (!buffer) { + *ts = ~0ULL; + return 1; /* Processing done on this queue */ + } + /* Start with a new buffer on this queue */ + if (buffer->data) { + buffer->use_size = buffer->size; + buffer->use_data = buffer->data; + } + } else + buffer = sfq->buffer; + + if (!buffer->data) { + int fd = perf_data__fd(sfq->sf->session->data); + + buffer->data = auxtrace_buffer__get_data(buffer, fd); + if (!buffer->data) + return -ENOMEM; + buffer->use_size = buffer->size; + buffer->use_data = buffer->data; + } + pr_debug4("%s queue_nr:%d buffer:%" PRId64 " offset:%#" PRIx64 " size:%#zx rest:%#zx\n", + __func__, sfq->queue_nr, buffer->buffer_nr, buffer->offset, + buffer->size, buffer->use_size); + err = s390_cpumsf_samples(sfq, ts); + + /* If non-zero, there is either an error (err < 0) or the buffer is + * completely done (err > 0). The error is unrecoverable, usually + * some descriptors could not be read successfully, so continue with + * the next buffer. + * In both cases the parameter 'ts' has been updated. + */ + if (err) { + sfq->buffer = NULL; + list_del(&buffer->list); + auxtrace_buffer__free(buffer); + if (err > 0) /* Buffer done, no error */ + err = 0; + } + return err; +} + +static struct s390_cpumsf_queue * +s390_cpumsf_alloc_queue(struct s390_cpumsf *sf, unsigned int queue_nr) +{ + struct s390_cpumsf_queue *sfq; + + sfq = zalloc(sizeof(struct s390_cpumsf_queue)); + if (sfq == NULL) + return NULL; + + sfq->sf = sf; + sfq->queue_nr = queue_nr; + sfq->cpu = -1; + return sfq; +} + +static int s390_cpumsf_setup_queue(struct s390_cpumsf *sf, + struct auxtrace_queue *queue, + unsigned int queue_nr, u64 ts) +{ + struct s390_cpumsf_queue *sfq = queue->priv; + + if (list_empty(&queue->head)) + return 0; + + if (sfq == NULL) { + sfq = s390_cpumsf_alloc_queue(sf, queue_nr); + if (!sfq) + return -ENOMEM; + queue->priv = sfq; + + if (queue->cpu != -1) + sfq->cpu = queue->cpu; + } + return auxtrace_heap__add(&sf->heap, queue_nr, ts); +} + +static int s390_cpumsf_setup_queues(struct s390_cpumsf *sf, u64 ts) +{ + unsigned int i; + int ret = 0; + + for (i = 0; i < sf->queues.nr_queues; i++) { + ret = s390_cpumsf_setup_queue(sf, &sf->queues.queue_array[i], + i, ts); + if (ret) + break; + } + return ret; +} + +static int s390_cpumsf_update_queues(struct s390_cpumsf *sf, u64 ts) +{ + if (!sf->queues.new_data) + return 0; + + sf->queues.new_data = false; + return s390_cpumsf_setup_queues(sf, ts); +} + +static int s390_cpumsf_process_queues(struct s390_cpumsf *sf, u64 timestamp) +{ + unsigned int queue_nr; + u64 ts; + int ret; + + while (1) { + struct auxtrace_queue *queue; + struct s390_cpumsf_queue *sfq; + + if (!sf->heap.heap_cnt) + return 0; + + if (sf->heap.heap_array[0].ordinal >= timestamp) + return 0; + + queue_nr = sf->heap.heap_array[0].queue_nr; + queue = &sf->queues.queue_array[queue_nr]; + sfq = queue->priv; + + auxtrace_heap__pop(&sf->heap); + if (sf->heap.heap_cnt) { + ts = sf->heap.heap_array[0].ordinal + 1; + if (ts > timestamp) + ts = timestamp; + } else { + ts = timestamp; + } + + ret = s390_cpumsf_run_decoder(sfq, &ts); + if (ret < 0) { + auxtrace_heap__add(&sf->heap, queue_nr, ts); + return ret; + } + if (!ret) { + ret = auxtrace_heap__add(&sf->heap, queue_nr, ts); + if (ret < 0) + return ret; + } + } + return 0; +} + +static int s390_cpumsf_synth_error(struct s390_cpumsf *sf, int code, int cpu, + pid_t pid, pid_t tid, u64 ip) +{ + char msg[MAX_AUXTRACE_ERROR_MSG]; + union perf_event event; + int err; + + strncpy(msg, "Lost Auxiliary Trace Buffer", sizeof(msg) - 1); + auxtrace_synth_error(&event.auxtrace_error, PERF_AUXTRACE_ERROR_ITRACE, + code, cpu, pid, tid, ip, msg); + + err = perf_session__deliver_synth_event(sf->session, &event, NULL); + if (err) + pr_err("s390 Auxiliary Trace: failed to deliver error event," + "error %d\n", err); + return err; +} + +static int s390_cpumsf_lost(struct s390_cpumsf *sf, struct perf_sample *sample) +{ + return s390_cpumsf_synth_error(sf, 1, sample->cpu, + sample->pid, sample->tid, 0); +} + static int s390_cpumsf_process_event(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + union perf_event *event, + struct perf_sample *sample, + struct perf_tool *tool) { - return 0; + struct s390_cpumsf *sf = container_of(session->auxtrace, + struct s390_cpumsf, + auxtrace); + u64 timestamp = sample->time; + int err = 0; + + if (dump_trace) + return 0; + + if (!tool->ordered_events) { + pr_err("s390 Auxiliary Trace requires ordered events\n"); + return -EINVAL; + } + + if (event->header.type == PERF_RECORD_AUX && + event->aux.flags & PERF_AUX_FLAG_TRUNCATED) + return s390_cpumsf_lost(sf, sample); + + if (timestamp) { + err = s390_cpumsf_update_queues(sf, timestamp); + if (!err) + err = s390_cpumsf_process_queues(sf, timestamp); + } + return err; } +struct s390_cpumsf_synth { + struct perf_tool cpumsf_tool; + struct perf_session *session; +}; + static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, @@ -266,6 +805,9 @@ s390_cpumsf_process_auxtrace_event(struct perf_session *session, off_t data_offset; int err; + if (sf->data_queued) + return 0; + if (perf_data__is_pipe(session->data)) { data_offset = 0; } else { @@ -290,17 +832,21 @@ s390_cpumsf_process_auxtrace_event(struct perf_session *session, return 0; } +static void s390_cpumsf_free_events(struct perf_session *session __maybe_unused) +{ +} + static int s390_cpumsf_flush(struct perf_session *session __maybe_unused, struct perf_tool *tool __maybe_unused) { return 0; } -static void s390_cpumsf_free_events(struct perf_session *session) +static void s390_cpumsf_free_queues(struct perf_session *session) { struct s390_cpumsf *sf = container_of(session->auxtrace, struct s390_cpumsf, - auxtrace); + auxtrace); struct auxtrace_queues *queues = &sf->queues; unsigned int i; @@ -316,7 +862,7 @@ static void s390_cpumsf_free(struct perf_session *session) auxtrace); auxtrace_heap__free(&sf->heap); - s390_cpumsf_free_events(session); + s390_cpumsf_free_queues(session); session->auxtrace = NULL; free(sf); } @@ -329,6 +875,19 @@ static int s390_cpumsf_get_type(const char *cpuid) return (ret == 1) ? family : 0; } +/* Check itrace options set on perf report command. + * Return true, if none are set or all options specified can be + * handled on s390. + * Return false otherwise. + */ +static bool check_auxtrace_itrace(struct itrace_synth_opts *itops) +{ + if (!itops || !itops->set) + return true; + pr_err("No --itrace options supported\n"); + return false; +} + int s390_cpumsf_process_auxtrace_info(union perf_event *event, struct perf_session *session) { @@ -343,6 +902,11 @@ int s390_cpumsf_process_auxtrace_info(union perf_event *event, if (sf == NULL) return -ENOMEM; + if (!check_auxtrace_itrace(session->itrace_synth_opts)) { + err = -EINVAL; + goto err_free; + } + err = auxtrace_queues__init(&sf->queues); if (err) goto err_free; @@ -360,8 +924,21 @@ int s390_cpumsf_process_auxtrace_info(union perf_event *event, sf->auxtrace.free = s390_cpumsf_free; session->auxtrace = &sf->auxtrace; + if (dump_trace) + return 0; + + err = auxtrace_queues__process_index(&sf->queues, session); + if (err) + goto err_free_queues; + + if (sf->queues.populated) + sf->data_queued = true; + return 0; +err_free_queues: + auxtrace_queues__free(&sf->queues); + session->auxtrace = NULL; err_free: free(sf); return err; -- cgit v1.2.3 From 704089e77acf74b17ed294683660937000ecb9ee Mon Sep 17 00:00:00 2001 From: Sean V Kelley Date: Thu, 2 Aug 2018 21:18:11 -0700 Subject: perf vendor events arm64: Enable JSON events for eMAG This patch adds the Ampere Computing eMAG file. This platform follows the ARMv8 recommended IMPLEMENTATION DEFINED events, where applicable. Signed-off-by: Sean V Kelley Reviewed-by: John Garry Cc: Alexander Shishkin Cc: Ganapatrao Kulkarni Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Will Deacon Cc: William Cohen Cc: linux-arm-kernel@lists.infradead.org LPU-Reference: 20180803041811.17065-1-seanvk.dev@oregontracks.org Signed-off-by: Arnaldo Carvalho de Melo --- .../arch/arm64/ampere/emag/core-imp-def.json | 32 ++++++++++++++++++++++ tools/perf/pmu-events/arch/arm64/mapfile.csv | 1 + 2 files changed, 33 insertions(+) create mode 100644 tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json new file mode 100644 index 000000000000..bc03c06c3918 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json @@ -0,0 +1,32 @@ +[ + { + "ArchStdEvent": "L1D_CACHE_RD", + }, + { + "ArchStdEvent": "L1D_CACHE_WR", + }, + { + "ArchStdEvent": "L1D_CACHE_REFILL_RD", + }, + { + "ArchStdEvent": "L1D_CACHE_REFILL_WR", + }, + { + "ArchStdEvent": "L1D_TLB_REFILL_RD", + }, + { + "ArchStdEvent": "L1D_TLB_REFILL_WR", + }, + { + "ArchStdEvent": "L1D_TLB_RD", + }, + { + "ArchStdEvent": "L1D_TLB_WR", + }, + { + "ArchStdEvent": "BUS_ACCESS_RD", + }, + { + "ArchStdEvent": "BUS_ACCESS_WR", + } +] diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv index f03e26ecb658..59cd8604b0bd 100644 --- a/tools/perf/pmu-events/arch/arm64/mapfile.csv +++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv @@ -16,3 +16,4 @@ 0x00000000420f5160,v1,cavium/thunderx2,core 0x00000000430f0af0,v1,cavium/thunderx2,core 0x00000000480fd010,v1,hisilicon/hip08,core +0x00000000500f0000,v1,ampere/emag,core -- cgit v1.2.3 From 3c8b81864080b710bdce446fd8401923f26fc4d4 Mon Sep 17 00:00:00 2001 From: Yury Norov Date: Sat, 23 Jun 2018 10:35:01 +0300 Subject: perf tools: Drop unneeded bitmap_zero() calls bitmap_zero() is called after bitmap_alloc() in perf code. But bitmap_alloc() internally uses calloc() which guarantees that allocated area is zeroed. So following bitmap_zero is unneeded. Drop it. This happened because of confusing name for bitmap allocator. It should has name bitmap_zalloc instead of bitmap_alloc. This series: https://lkml.org/lkml/2018/6/18/841 introduces a new API for bitmap allocations in kernel, and functions there are named correctly. Following patch propogates the API to tools, and fixes naming issue. Signed-off-by: Yury Norov Cc: Alexander Shishkin Cc: Andi Kleen Cc: Andrew Morton Cc: Andriy Shevchenko Cc: David Ahern Cc: David Carrillo-Cisneros Cc: Dmitry Torokhov Cc: Jin Yao Cc: Jiri Olsa Cc: Kate Stewart Cc: Matthew Wilcox Cc: Mike Snitzer Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Philippe Ombredanne Link: http://lkml.kernel.org/r/20180623073502.16321-1-ynorov@caviumnetworks.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/bitmap.c | 2 -- tools/perf/tests/mem2node.c | 2 -- tools/perf/util/header.c | 3 --- 3 files changed, 7 deletions(-) diff --git a/tools/perf/tests/bitmap.c b/tools/perf/tests/bitmap.c index 47bedf25ba69..96e7fc1ad3f9 100644 --- a/tools/perf/tests/bitmap.c +++ b/tools/perf/tests/bitmap.c @@ -16,8 +16,6 @@ static unsigned long *get_bitmap(const char *str, int nbits) bm = bitmap_alloc(nbits); if (map && bm) { - bitmap_zero(bm, nbits); - for (i = 0; i < map->nr; i++) set_bit(map->map[i], bm); } diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c index 0c3c87f86e03..9e9e4d37cc77 100644 --- a/tools/perf/tests/mem2node.c +++ b/tools/perf/tests/mem2node.c @@ -24,8 +24,6 @@ static unsigned long *get_bitmap(const char *str, int nbits) bm = bitmap_alloc(nbits); if (map && bm) { - bitmap_zero(bm, nbits); - for (i = 0; i < map->nr; i++) { set_bit(map->map[i], bm); } diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 5af58aac91ad..5f1af7b07b96 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -279,8 +279,6 @@ static int do_read_bitmap(struct feat_fd *ff, unsigned long **pset, u64 *psize) if (!set) return -ENOMEM; - bitmap_zero(set, size); - p = (u64 *) set; for (i = 0; (u64) i < BITS_TO_U64(size); i++) { @@ -1285,7 +1283,6 @@ static int memory_node__read(struct memory_node *n, unsigned long idx) return -ENOMEM; } - bitmap_zero(n->set, size); n->node = idx; n->size = size; -- cgit v1.2.3 From dda9ac966d39cec5a501b0b4d0210b3c2a167e6c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 3 Aug 2018 16:28:35 -0300 Subject: perf bpf: Add 'syscall_enter' probe helper for syscall enter tracepoints Allowing one to hook into the syscalls:sys_enter_NAME tracepoints, an example is provided that hooks into the 'openat' syscall. Using it with the probe:vfs_getname probe into getname_flags to get the filename args as it is copied from userspace: # perf probe -l probe:vfs_getname (on getname_flags:73@acme/git/linux/fs/namei.c with pathname) # perf trace -e probe:*getname,tools/perf/examples/bpf/sys_enter_openat.c cat /etc/passwd > /dev/null 0.000 probe:vfs_getname:(ffffffffbd2a8983) pathname="/etc/ld.so.preload" 0.022 syscalls:sys_enter_openat:dfd: CWD, filename: 0xafbe8da8, flags: CLOEXEC 0.027 probe:vfs_getname:(ffffffffbd2a8983) pathname="/etc/ld.so.cache" 0.054 syscalls:sys_enter_openat:dfd: CWD, filename: 0xafdf0ce0, flags: CLOEXEC 0.057 probe:vfs_getname:(ffffffffbd2a8983) pathname="/lib64/libc.so.6" 0.316 probe:vfs_getname:(ffffffffbd2a8983) pathname="/usr/lib/locale/locale-archive" 0.375 syscalls:sys_enter_openat:dfd: CWD, filename: 0xe2b2b0b4 0.379 probe:vfs_getname:(ffffffffbd2a8983) pathname="/etc/passwd" # Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-2po9jcqv1qgj0koxlg8kkg30@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/sys_enter_openat.c | 33 ++++++++++++++++++++++++++++++ tools/perf/include/bpf/bpf.h | 3 +++ 2 files changed, 36 insertions(+) create mode 100644 tools/perf/examples/bpf/sys_enter_openat.c diff --git a/tools/perf/examples/bpf/sys_enter_openat.c b/tools/perf/examples/bpf/sys_enter_openat.c new file mode 100644 index 000000000000..9cd124b09392 --- /dev/null +++ b/tools/perf/examples/bpf/sys_enter_openat.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Hook into 'openat' syscall entry tracepoint + * + * Test it with: + * + * perf trace -e tools/perf/examples/bpf/sys_enter_openat.c cat /etc/passwd > /dev/null + * + * It'll catch some openat syscalls related to the dynamic linked and + * the last one should be the one for '/etc/passwd'. + * + * The syscall_enter_openat_args can be used to get the syscall fields + * and use them for filtering calls, i.e. use in expressions for + * the return value. + */ + +#include + +struct syscall_enter_openat_args { + unsigned long long unused; + long syscall_nr; + long dfd; + char *filename_ptr; + long flags; + long mode; +}; + +int syscall_enter(openat)(struct syscall_enter_openat_args *args) +{ + return 1; +} + +license(GPL); diff --git a/tools/perf/include/bpf/bpf.h b/tools/perf/include/bpf/bpf.h index a63aa6241b7f..2873cdde293f 100644 --- a/tools/perf/include/bpf/bpf.h +++ b/tools/perf/include/bpf/bpf.h @@ -9,6 +9,9 @@ #define probe(function, vars) \ SEC(#function "=" #function " " #vars) function +#define syscall_enter(name) \ + SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name + #define license(name) \ char _license[] SEC("license") = #name; \ int _version SEC("version") = LINUX_VERSION_CODE; -- cgit v1.2.3 From 7a3e71e0d806070071f53271705b0c511c0359fc Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:02 +0200 Subject: perf annotate: Make symbol__annotate_fprintf2() local There's no outside user of it. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: https://lkml.kernel.org/r/20180804130521.11408-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 2 +- tools/perf/util/annotate.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index f91775b4bc3c..b6e7d0d56622 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2129,7 +2129,7 @@ static void FILE__write_graph(void *fp, int graph) fputs(s, fp); } -int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) +static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) { struct annotation *notes = symbol__annotation(sym); struct annotation_write_ops ops = { diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a4c0d91907e6..5f24fc9dcc7c 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -340,7 +340,6 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map, int symbol__annotate_printf(struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct annotation_options *options); -int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp); void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); void annotated_source__purge(struct annotated_source *as); -- cgit v1.2.3 From 5ecf7d30eb4f9c046f5284f20133d7b69729c315 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:03 +0200 Subject: perf annotate: Make annotation_line__max_percent static There's no outside user of it. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-3-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 3 ++- tools/perf/util/annotate.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index b6e7d0d56622..956c9b19d81c 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2441,7 +2441,8 @@ bool ui__has_annotation(void) } -double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes) +static double annotation_line__max_percent(struct annotation_line *al, + struct annotation *notes) { double percent_max = 0.0; int i; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 5f24fc9dcc7c..a93502d0c582 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -169,7 +169,6 @@ struct annotation_write_ops { void (*write_graph)(void *obj, int graph); }; -double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes); void annotation_line__write(struct annotation_line *al, struct annotation *notes, struct annotation_write_ops *ops); -- cgit v1.2.3 From 0683d13c1afbf5cca147b6f578d1463be132b11b Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:04 +0200 Subject: perf annotate: Get rid of annotation__scnprintf_samples_period() We have more current function tto get the title for annotation, which is hists__scnprintf_title. They both have same output as far as the annotation's header line goes. They differ in counting of the nr_samples, hists__scnprintf_title provides more accurate number based on the setup of the symbol_conf.filter_relative variable. Plus it also displays any uid/thread/dso/socket filters/zooms if there are set any, which annotation__scnprintf_samples_period does not. Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 3 +-- tools/perf/util/annotate.c | 44 ++------------------------------------- tools/perf/util/annotate.h | 7 ------- 3 files changed, 3 insertions(+), 51 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 3b4f1c10ff57..d264916d2648 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -624,8 +624,7 @@ static int annotate_browser__run(struct annotate_browser *browser, char title[256]; int key; - annotation__scnprintf_samples_period(notes, title, sizeof(title), evsel); - + hists__scnprintf_title(hists, title, sizeof(title)); if (annotate_browser__show(&browser->b, title, help) < 0) return -1; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 956c9b19d81c..0d40cee13f6b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2389,7 +2389,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, { struct dso *dso = map->dso; struct rb_root source_line = RB_ROOT; - struct annotation *notes = symbol__annotation(sym); + struct hists *hists = evsel__hists(evsel); char buf[1024]; if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0) @@ -2401,7 +2401,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, print_summary(&source_line, dso->long_name); } - annotation__scnprintf_samples_period(notes, buf, sizeof(buf), evsel); + hists__scnprintf_title(hists, buf, sizeof(buf)); fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name); symbol__annotate_fprintf2(sym, stdout); @@ -2689,46 +2689,6 @@ out_free_offsets: return -1; } -int __annotation__scnprintf_samples_period(struct annotation *notes, - char *bf, size_t size, - struct perf_evsel *evsel, - bool show_freq) -{ - const char *ev_name = perf_evsel__name(evsel); - char buf[1024], ref[30] = " show reference callgraph, "; - char sample_freq_str[64] = ""; - unsigned long nr_samples = 0; - int nr_members = 1; - bool enable_ref = false; - u64 nr_events = 0; - char unit; - int i; - - if (perf_evsel__is_group_event(evsel)) { - perf_evsel__group_desc(evsel, buf, sizeof(buf)); - ev_name = buf; - nr_members = evsel->nr_members; - } - - for (i = 0; i < nr_members; i++) { - struct sym_hist *ah = annotation__histogram(notes, evsel->idx + i); - - nr_samples += ah->nr_samples; - nr_events += ah->period; - } - - if (symbol_conf.show_ref_callgraph && strstr(ev_name, "call-graph=no")) - enable_ref = true; - - if (show_freq) - scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", evsel->attr.sample_freq); - - nr_samples = convert_unit(nr_samples, &unit); - return scnprintf(bf, size, "Samples: %lu%c of event%s '%s',%s%sEvent count (approx.): %" PRIu64, - nr_samples, unit, evsel->nr_members > 1 ? "s" : "", - ev_name, sample_freq_str, enable_ref ? ref : " ", nr_events); -} - #define ANNOTATION__CFG(n) \ { .name = #n, .value = &annotation__default_options.n, } diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a93502d0c582..d06f14c656c6 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -177,13 +177,6 @@ int __annotation__scnprintf_samples_period(struct annotation *notes, struct perf_evsel *evsel, bool show_freq); -static inline int annotation__scnprintf_samples_period(struct annotation *notes, - char *bf, size_t size, - struct perf_evsel *evsel) -{ - return __annotation__scnprintf_samples_period(notes, bf, size, evsel, true); -} - int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); size_t disasm__fprintf(struct list_head *head, FILE *fp); void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel); -- cgit v1.2.3 From c2f938ba5aa61ba60e9217848e666c783cbcce1c Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:05 +0200 Subject: perf annotate: Rename struct annotation_line::samples* to data* The name 'samples*' is little confusing because we have nested 'struct sym_hist_entry' under annotation_line struct, which holds 'nr_samples' as well. Also the holding struct name is 'annotation_data' so the 'data' name fits better. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-5-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 10 ++++---- tools/perf/util/annotate.c | 52 +++++++++++++++++++-------------------- tools/perf/util/annotate.h | 4 +-- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index d264916d2648..d648d1e153f3 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -227,10 +227,10 @@ static int disasm__cmp(struct annotation_line *a, struct annotation_line *b) { int i; - for (i = 0; i < a->samples_nr; i++) { - if (a->samples[i].percent == b->samples[i].percent) + for (i = 0; i < a->data_nr; i++) { + if (a->data[i].percent == b->data[i].percent) continue; - return a->samples[i].percent < b->samples[i].percent; + return a->data[i].percent < b->data[i].percent; } return 0; } @@ -314,8 +314,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, continue; } - for (i = 0; i < pos->al.samples_nr; i++) { - struct annotation_data *sample = &pos->al.samples[i]; + for (i = 0; i < pos->al.data_nr; i++) { + struct annotation_data *sample = &pos->al.data[i]; if (max_percent < sample->percent) max_percent = sample->percent; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0d40cee13f6b..e4cb8963db1a 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1108,7 +1108,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize) if (perf_evsel__is_group_event(evsel)) nr = evsel->nr_members; - size += sizeof(al->samples[0]) * nr; + size += sizeof(al->data[0]) * nr; al = zalloc(size); if (al) { @@ -1117,7 +1117,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize) al->offset = args->offset; al->line = strdup(args->line); al->line_nr = args->line_nr; - al->samples_nr = nr; + al->data_nr = nr; } return al; @@ -1309,15 +1309,15 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start const char *color; struct annotation *notes = symbol__annotation(sym); - for (i = 0; i < al->samples_nr; i++) { - struct annotation_data *sample = &al->samples[i]; + for (i = 0; i < al->data_nr; i++) { + struct annotation_data *sample = &al->data[i]; if (sample->percent > max_percent) max_percent = sample->percent; } - if (al->samples_nr > nr_percent) - nr_percent = al->samples_nr; + if (al->data_nr > nr_percent) + nr_percent = al->data_nr; if (max_percent < min_pcnt) return -1; @@ -1351,7 +1351,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start } for (i = 0; i < nr_percent; i++) { - struct annotation_data *sample = &al->samples[i]; + struct annotation_data *sample = &al->data[i]; color = get_percent_color(sample->percent); @@ -1788,12 +1788,12 @@ static void annotation__calc_percent(struct annotation *notes, next = annotation_line__next(al, ¬es->src->source); end = next ? next->offset : len; - for (i = 0; i < al->samples_nr; i++) { + for (i = 0; i < al->data_nr; i++) { struct annotation_data *sample; struct sym_hist *hist; hist = annotation__histogram(notes, evsel->idx + i); - sample = &al->samples[i]; + sample = &al->data[i]; calc_percent(hist, sample, al->offset, end); } @@ -1859,8 +1859,8 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) ret = strcmp(iter->path, al->path); if (ret == 0) { - for (i = 0; i < al->samples_nr; i++) - iter->samples[i].percent_sum += al->samples[i].percent; + for (i = 0; i < al->data_nr; i++) + iter->data[i].percent_sum += al->data[i].percent; return; } @@ -1870,8 +1870,8 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) p = &(*p)->rb_right; } - for (i = 0; i < al->samples_nr; i++) - al->samples[i].percent_sum = al->samples[i].percent; + for (i = 0; i < al->data_nr; i++) + al->data[i].percent_sum = al->data[i].percent; rb_link_node(&al->rb_node, parent, p); rb_insert_color(&al->rb_node, root); @@ -1881,10 +1881,10 @@ static int cmp_source_line(struct annotation_line *a, struct annotation_line *b) { int i; - for (i = 0; i < a->samples_nr; i++) { - if (a->samples[i].percent_sum == b->samples[i].percent_sum) + for (i = 0; i < a->data_nr; i++) { + if (a->data[i].percent_sum == b->data[i].percent_sum) continue; - return a->samples[i].percent_sum > b->samples[i].percent_sum; + return a->data[i].percent_sum > b->data[i].percent_sum; } return 0; @@ -1949,8 +1949,8 @@ static void print_summary(struct rb_root *root, const char *filename) int i; al = rb_entry(node, struct annotation_line, rb_node); - for (i = 0; i < al->samples_nr; i++) { - percent = al->samples[i].percent_sum; + for (i = 0; i < al->data_nr; i++) { + percent = al->data[i].percent_sum; color = get_percent_color(percent); color_fprintf(stdout, color, " %7.2f", percent); @@ -2355,10 +2355,10 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, double percent_max = 0.0; int i; - for (i = 0; i < al->samples_nr; i++) { + for (i = 0; i < al->data_nr; i++) { struct annotation_data *sample; - sample = &al->samples[i]; + sample = &al->data[i]; if (sample->percent > percent_max) percent_max = sample->percent; @@ -2448,8 +2448,8 @@ static double annotation_line__max_percent(struct annotation_line *al, int i; for (i = 0; i < notes->nr_events; i++) { - if (al->samples[i].percent > percent_max) - percent_max = al->samples[i].percent; + if (al->data[i].percent > percent_max) + percent_max = al->data[i].percent; } return percent_max; @@ -2515,15 +2515,15 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati int i; for (i = 0; i < notes->nr_events; i++) { - obj__set_percent_color(obj, al->samples[i].percent, current_entry); + obj__set_percent_color(obj, al->data[i].percent, current_entry); if (notes->options->show_total_period) { - obj__printf(obj, "%11" PRIu64 " ", al->samples[i].he.period); + obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period); } else if (notes->options->show_nr_samples) { obj__printf(obj, "%6" PRIu64 " ", - al->samples[i].he.nr_samples); + al->data[i].he.nr_samples); } else { obj__printf(obj, "%6.2f ", - al->samples[i].percent); + al->data[i].percent); } } } else { diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d06f14c656c6..58aa14c55bab 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -122,8 +122,8 @@ struct annotation_line { char *path; u32 idx; int idx_asm; - int samples_nr; - struct annotation_data samples[0]; + int data_nr; + struct annotation_data data[0]; }; struct disasm_line { -- cgit v1.2.3 From 0440af74dcd0f32b134b1c4d47dc25f0bb539ded Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:06 +0200 Subject: perf annotate: Rename local sample variables to data Based on previous rename, changing also the local variable names to fit properly. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-6-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e4cb8963db1a..8bd278a71004 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1310,10 +1310,10 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start struct annotation *notes = symbol__annotation(sym); for (i = 0; i < al->data_nr; i++) { - struct annotation_data *sample = &al->data[i]; + struct annotation_data *data = &al->data[i]; - if (sample->percent > max_percent) - max_percent = sample->percent; + if (data->percent > max_percent) + max_percent = data->percent; } if (al->data_nr > nr_percent) @@ -1351,18 +1351,18 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start } for (i = 0; i < nr_percent; i++) { - struct annotation_data *sample = &al->data[i]; + struct annotation_data *data = &al->data[i]; - color = get_percent_color(sample->percent); + color = get_percent_color(data->percent); if (symbol_conf.show_total_period) color_fprintf(stdout, color, " %11" PRIu64, - sample->he.period); + data->he.period); else if (symbol_conf.show_nr_samples) color_fprintf(stdout, color, " %7" PRIu64, - sample->he.nr_samples); + data->he.nr_samples); else - color_fprintf(stdout, color, " %7.2f", sample->percent); + color_fprintf(stdout, color, " %7.2f", data->percent); } printf(" : "); @@ -1754,7 +1754,7 @@ out_close_stdout: } static void calc_percent(struct sym_hist *hist, - struct annotation_data *sample, + struct annotation_data *data, s64 offset, s64 end) { unsigned int hits = 0; @@ -1767,9 +1767,9 @@ static void calc_percent(struct sym_hist *hist, } if (hist->nr_samples) { - sample->he.period = period; - sample->he.nr_samples = hits; - sample->percent = 100.0 * hits / hist->nr_samples; + data->he.period = period; + data->he.nr_samples = hits; + data->percent = 100.0 * hits / hist->nr_samples; } } @@ -1789,13 +1789,13 @@ static void annotation__calc_percent(struct annotation *notes, end = next ? next->offset : len; for (i = 0; i < al->data_nr; i++) { - struct annotation_data *sample; + struct annotation_data *data; struct sym_hist *hist; - hist = annotation__histogram(notes, evsel->idx + i); - sample = &al->data[i]; + hist = annotation__histogram(notes, evsel->idx + i); + data = &al->data[i]; - calc_percent(hist, sample, al->offset, end); + calc_percent(hist, data, al->offset, end); } } } @@ -2356,12 +2356,12 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, int i; for (i = 0; i < al->data_nr; i++) { - struct annotation_data *sample; + struct annotation_data *data; - sample = &al->data[i]; + data = &al->data[i]; - if (sample->percent > percent_max) - percent_max = sample->percent; + if (data->percent > percent_max) + percent_max = data->percent; } if (percent_max <= 0.5) -- cgit v1.2.3 From 48a1e4f2381387a097ea9f7897c5c32e9aaa708d Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:07 +0200 Subject: perf annotate: Rename hist to sym_hist in annotation__calc_percent We will need to bring in 'struct hists' variable in this scope, so it's better we do this rename first. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-7-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 8bd278a71004..728603636adc 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1753,7 +1753,7 @@ out_close_stdout: goto out_free_command; } -static void calc_percent(struct sym_hist *hist, +static void calc_percent(struct sym_hist *sym_hist, struct annotation_data *data, s64 offset, s64 end) { @@ -1761,15 +1761,15 @@ static void calc_percent(struct sym_hist *hist, u64 period = 0; while (offset < end) { - hits += hist->addr[offset].nr_samples; - period += hist->addr[offset].period; + hits += sym_hist->addr[offset].nr_samples; + period += sym_hist->addr[offset].period; ++offset; } - if (hist->nr_samples) { + if (sym_hist->nr_samples) { data->he.period = period; data->he.nr_samples = hits; - data->percent = 100.0 * hits / hist->nr_samples; + data->percent = 100.0 * hits / sym_hist->nr_samples; } } @@ -1790,12 +1790,12 @@ static void annotation__calc_percent(struct annotation *notes, for (i = 0; i < al->data_nr; i++) { struct annotation_data *data; - struct sym_hist *hist; + struct sym_hist *sym_hist; - hist = annotation__histogram(notes, evsel->idx + i); + sym_hist = annotation__histogram(notes, evsel->idx + i); data = &al->data[i]; - calc_percent(hist, data, al->offset, end); + calc_percent(sym_hist, data, al->offset, end); } } } -- cgit v1.2.3 From 2bcf73069b0722c92a84c0fd57df542890a74904 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:08 +0200 Subject: perf annotate: Loop group events directly in annotation__calc_percent() We need to bring in 'struct hists' object and for that we need 'struct perf_evsel' object in the scope. Switching the group data loop with the evsel group loop. It does the same thing, but it brings evsel object, that we can use later get the 'struct hists' object. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-8-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 13 ++++++++----- tools/perf/util/evsel.h | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 728603636adc..34d4bb73aa84 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1774,13 +1774,14 @@ static void calc_percent(struct sym_hist *sym_hist, } static void annotation__calc_percent(struct annotation *notes, - struct perf_evsel *evsel, s64 len) + struct perf_evsel *leader, s64 len) { struct annotation_line *al, *next; + struct perf_evsel *evsel; list_for_each_entry(al, ¬es->src->source, node) { s64 end; - int i; + int i = 0; if (al->offset == -1) continue; @@ -1788,12 +1789,14 @@ static void annotation__calc_percent(struct annotation *notes, next = annotation_line__next(al, ¬es->src->source); end = next ? next->offset : len; - for (i = 0; i < al->data_nr; i++) { + for_each_group_evsel(evsel, leader) { struct annotation_data *data; struct sym_hist *sym_hist; - sym_hist = annotation__histogram(notes, evsel->idx + i); - data = &al->data[i]; + BUG_ON(i >= al->data_nr); + + sym_hist = annotation__histogram(notes, evsel->idx); + data = &al->data[i++]; calc_percent(sym_hist, data, al->offset, end); } diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 973c03167947..163c960614d3 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -452,11 +452,18 @@ static inline int perf_evsel__group_idx(struct perf_evsel *evsel) return evsel->idx - evsel->leader->idx; } +/* Iterates group WITHOUT the leader. */ #define for_each_group_member(_evsel, _leader) \ for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \ (_evsel) && (_evsel)->leader == (_leader); \ (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node)) +/* Iterates group WITH the leader. */ +#define for_each_group_evsel(_evsel, _leader) \ +for ((_evsel) = _leader; \ + (_evsel) && (_evsel)->leader == (_leader); \ + (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node)) + static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel) { return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK; -- cgit v1.2.3 From 6d9f0c2d5ef7568c29fa5927748c4915a9c7760a Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:09 +0200 Subject: perf annotate: Switch struct annotation_data::percent to array So we can hold multiple percent values for annotation line. The first member of this array is current local hits percent value (PERCENT_HITS_LOCAL index), so no functional change is expected. Adding annotation_data__percent function to return requested percent value from struct annotation_data. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-9-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 9 ++++--- tools/perf/util/annotate.c | 57 ++++++++++++++++++++++++++------------- tools/perf/util/annotate.h | 13 ++++++++- 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index d648d1e153f3..81876c3923d2 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -315,10 +315,13 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, } for (i = 0; i < pos->al.data_nr; i++) { - struct annotation_data *sample = &pos->al.data[i]; + double percent; - if (max_percent < sample->percent) - max_percent = sample->percent; + percent = annotation_data__percent(&pos->al.data[i], + PERCENT_HITS_LOCAL); + + if (max_percent < percent) + max_percent = percent; } if (max_percent < 0.01 && pos->al.ipc == 0) { diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 34d4bb73aa84..074adb2a831e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1310,10 +1310,13 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start struct annotation *notes = symbol__annotation(sym); for (i = 0; i < al->data_nr; i++) { - struct annotation_data *data = &al->data[i]; + double percent; + + percent = annotation_data__percent(&al->data[i], + PERCENT_HITS_LOCAL); - if (data->percent > max_percent) - max_percent = data->percent; + if (percent > max_percent) + max_percent = percent; } if (al->data_nr > nr_percent) @@ -1352,8 +1355,10 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start for (i = 0; i < nr_percent; i++) { struct annotation_data *data = &al->data[i]; + double percent; - color = get_percent_color(data->percent); + percent = annotation_data__percent(data, PERCENT_HITS_LOCAL); + color = get_percent_color(percent); if (symbol_conf.show_total_period) color_fprintf(stdout, color, " %11" PRIu64, @@ -1362,7 +1367,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start color_fprintf(stdout, color, " %7" PRIu64, data->he.nr_samples); else - color_fprintf(stdout, color, " %7.2f", data->percent); + color_fprintf(stdout, color, " %7.2f", percent); } printf(" : "); @@ -1769,7 +1774,7 @@ static void calc_percent(struct sym_hist *sym_hist, if (sym_hist->nr_samples) { data->he.period = period; data->he.nr_samples = hits; - data->percent = 100.0 * hits / sym_hist->nr_samples; + data->percent[PERCENT_HITS_LOCAL] = 100.0 * hits / sym_hist->nr_samples; } } @@ -1862,8 +1867,10 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) ret = strcmp(iter->path, al->path); if (ret == 0) { - for (i = 0; i < al->data_nr; i++) - iter->data[i].percent_sum += al->data[i].percent; + for (i = 0; i < al->data_nr; i++) { + iter->data[i].percent_sum += annotation_data__percent(&al->data[i], + PERCENT_HITS_LOCAL); + } return; } @@ -1873,8 +1880,10 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) p = &(*p)->rb_right; } - for (i = 0; i < al->data_nr; i++) - al->data[i].percent_sum = al->data[i].percent; + for (i = 0; i < al->data_nr; i++) { + al->data[i].percent_sum = annotation_data__percent(&al->data[i], + PERCENT_HITS_LOCAL); + } rb_link_node(&al->rb_node, parent, p); rb_insert_color(&al->rb_node, root); @@ -2359,12 +2368,13 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, int i; for (i = 0; i < al->data_nr; i++) { - struct annotation_data *data; + double percent; - data = &al->data[i]; + percent = annotation_data__percent(&al->data[i], + PERCENT_HITS_LOCAL); - if (data->percent > percent_max) - percent_max = data->percent; + if (percent > percent_max) + percent_max = percent; } if (percent_max <= 0.5) @@ -2451,8 +2461,13 @@ static double annotation_line__max_percent(struct annotation_line *al, int i; for (i = 0; i < notes->nr_events; i++) { - if (al->data[i].percent > percent_max) - percent_max = al->data[i].percent; + double percent; + + percent = annotation_data__percent(&al->data[i], + PERCENT_HITS_LOCAL); + + if (percent > percent_max) + percent_max = percent; } return percent_max; @@ -2518,15 +2533,19 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati int i; for (i = 0; i < notes->nr_events; i++) { - obj__set_percent_color(obj, al->data[i].percent, current_entry); + double percent; + + percent = annotation_data__percent(&al->data[i], + PERCENT_HITS_LOCAL); + + obj__set_percent_color(obj, percent, current_entry); if (notes->options->show_total_period) { obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period); } else if (notes->options->show_nr_samples) { obj__printf(obj, "%6" PRIu64 " ", al->data[i].he.nr_samples); } else { - obj__printf(obj, "%6.2f ", - al->data[i].percent); + obj__printf(obj, "%6.2f ", percent); } } } else { diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 58aa14c55bab..0afbf8075fca 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -101,8 +101,13 @@ struct sym_hist_entry { u64 period; }; +enum { + PERCENT_HITS_LOCAL, + PERCENT_MAX, +}; + struct annotation_data { - double percent; + double percent[PERCENT_MAX]; double percent_sum; struct sym_hist_entry he; }; @@ -134,6 +139,12 @@ struct disasm_line { struct annotation_line al; }; +static inline double annotation_data__percent(struct annotation_data *data, + unsigned int which) +{ + return which < PERCENT_MAX ? data->percent[which] : -1; +} + static inline struct disasm_line *disasm_line(struct annotation_line *al) { return al ? container_of(al, struct disasm_line, al) : NULL; -- cgit v1.2.3 From 75a8c1ff287b2a949b50c1c1e58a6492e21a3ac5 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:10 +0200 Subject: perf annotate: Add PERCENT_HITS_GLOBAL percent value Adding and computing global hits percent value for annotation line. Storing it in struct annotation_data percent array under new PERCENT_HITS_GLOBAL index. At the moment it's not displayed, it's coming in following patches. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-10-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 8 +++++++- tools/perf/util/annotate.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 074adb2a831e..b7485a512da1 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1759,6 +1759,7 @@ out_close_stdout: } static void calc_percent(struct sym_hist *sym_hist, + struct hists *hists, struct annotation_data *data, s64 offset, s64 end) { @@ -1776,6 +1777,10 @@ static void calc_percent(struct sym_hist *sym_hist, data->he.nr_samples = hits; data->percent[PERCENT_HITS_LOCAL] = 100.0 * hits / sym_hist->nr_samples; } + + if (hists->stats.nr_non_filtered_samples) + data->percent[PERCENT_HITS_GLOBAL] = 100.0 * hits / hists->stats.nr_non_filtered_samples; + } static void annotation__calc_percent(struct annotation *notes, @@ -1795,6 +1800,7 @@ static void annotation__calc_percent(struct annotation *notes, end = next ? next->offset : len; for_each_group_evsel(evsel, leader) { + struct hists *hists = evsel__hists(evsel); struct annotation_data *data; struct sym_hist *sym_hist; @@ -1803,7 +1809,7 @@ static void annotation__calc_percent(struct annotation *notes, sym_hist = annotation__histogram(notes, evsel->idx); data = &al->data[i++]; - calc_percent(sym_hist, data, al->offset, end); + calc_percent(sym_hist, hists, data, al->offset, end); } } } diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 0afbf8075fca..3a06cb2b6e28 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -103,6 +103,7 @@ struct sym_hist_entry { enum { PERCENT_HITS_LOCAL, + PERCENT_HITS_GLOBAL, PERCENT_MAX, }; -- cgit v1.2.3 From ab371169fb7db9587f09137e93a49c6afeab16f7 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:11 +0200 Subject: perf annotate: Add PERCENT_PERIOD_LOCAL percent value Adding and computing local period percent value for annotation line. Storing it in struct annotation_data percent array under new PERCENT_PERIOD_LOCAL index. At the moment it's not displayed, it's coming in following patches. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-11-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 2 ++ tools/perf/util/annotate.h | 1 + 2 files changed, 3 insertions(+) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index b7485a512da1..b37e8cc18668 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1781,6 +1781,8 @@ static void calc_percent(struct sym_hist *sym_hist, if (hists->stats.nr_non_filtered_samples) data->percent[PERCENT_HITS_GLOBAL] = 100.0 * hits / hists->stats.nr_non_filtered_samples; + if (sym_hist->period) + data->percent[PERCENT_PERIOD_LOCAL] = 100.0 * period / sym_hist->period; } static void annotation__calc_percent(struct annotation *notes, diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 3a06cb2b6e28..890b6869caa9 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -104,6 +104,7 @@ struct sym_hist_entry { enum { PERCENT_HITS_LOCAL, PERCENT_HITS_GLOBAL, + PERCENT_PERIOD_LOCAL, PERCENT_MAX, }; -- cgit v1.2.3 From e58684df912906d944967e2ce0f3ed5d5140d1e5 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:12 +0200 Subject: perf annotate: Add PERCENT_PERIOD_GLOBAL percent value Adding and computing global period percent value for annotation line. Storing it in struct annotation_data percent array under new PERCENT_PERIOD_GLOBAL index. At the moment it's not displayed, it's coming in following patches. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-12-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 3 +++ tools/perf/util/annotate.h | 1 + 2 files changed, 4 insertions(+) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index b37e8cc18668..e890164592b0 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1783,6 +1783,9 @@ static void calc_percent(struct sym_hist *sym_hist, if (sym_hist->period) data->percent[PERCENT_PERIOD_LOCAL] = 100.0 * period / sym_hist->period; + + if (hists->stats.total_period) + data->percent[PERCENT_PERIOD_GLOBAL] = 100.0 * period / hists->stats.total_period; } static void annotation__calc_percent(struct annotation *notes, diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 890b6869caa9..48fe2aa6b5a8 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -105,6 +105,7 @@ enum { PERCENT_HITS_LOCAL, PERCENT_HITS_GLOBAL, PERCENT_PERIOD_LOCAL, + PERCENT_PERIOD_GLOBAL, PERCENT_MAX, }; -- cgit v1.2.3 From 796ca33d5ceb621f238021c34cff8cfaa1100623 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:13 +0200 Subject: perf annotate: Add percent_type to struct annotation_options It will be used to carry user selection of percent type for annotation output. Passing the percent_type to the annotation_line__print function as the first step and making it default to current percentage type (PERCENT_HITS_LOCAL) value. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-13-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 13 ++++++++----- tools/perf/util/annotate.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e890164592b0..91528a065768 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -49,6 +49,7 @@ struct annotation_options annotation__default_options = { .jump_arrows = true, .annotate_src = true, .offset_level = ANNOTATION__OFFSET_JUMP_TARGETS, + .percent_type = PERCENT_HITS_LOCAL, }; static regex_t file_lineno; @@ -1297,7 +1298,8 @@ static int disasm_line__print(struct disasm_line *dl, u64 start, int addr_fmt_wi static int annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start, struct perf_evsel *evsel, u64 len, int min_pcnt, int printed, - int max_lines, struct annotation_line *queue, int addr_fmt_width) + int max_lines, struct annotation_line *queue, int addr_fmt_width, + int percent_type) { struct disasm_line *dl = container_of(al, struct disasm_line, al); static const char *prev_line; @@ -1313,7 +1315,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start double percent; percent = annotation_data__percent(&al->data[i], - PERCENT_HITS_LOCAL); + percent_type); if (percent > max_percent) max_percent = percent; @@ -1333,7 +1335,8 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start if (queue == al) break; annotation_line__print(queue, sym, start, evsel, len, - 0, 0, 1, NULL, addr_fmt_width); + 0, 0, 1, NULL, addr_fmt_width, + percent_type); } } @@ -1357,7 +1360,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start struct annotation_data *data = &al->data[i]; double percent; - percent = annotation_data__percent(data, PERCENT_HITS_LOCAL); + percent = annotation_data__percent(data, percent_type); color = get_percent_color(percent); if (symbol_conf.show_total_period) @@ -2075,7 +2078,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, err = annotation_line__print(pos, sym, start, evsel, len, opts->min_pcnt, printed, opts->max_lines, - queue, addr_fmt_width); + queue, addr_fmt_width, opts->percent_type); switch (err) { case 0: diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 48fe2aa6b5a8..145dec845f33 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -82,6 +82,7 @@ struct annotation_options { int context; const char *objdump_path; const char *disassembler_style; + unsigned int percent_type; }; enum { -- cgit v1.2.3 From c849c12cf344e4b99dbf98df642b622b6c91bbfd Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:14 +0200 Subject: perf annotate: Pass struct annotation_options to symbol__calc_lines() Pass struct annotation_options to symbol__calc_lines(), to carry on and pass the percent_type value. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-14-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 91528a065768..2b06476c79c2 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1868,7 +1868,8 @@ int symbol__annotate(struct symbol *sym, struct map *map, return symbol__disassemble(sym, &args); } -static void insert_source_line(struct rb_root *root, struct annotation_line *al) +static void insert_source_line(struct rb_root *root, struct annotation_line *al, + struct annotation_options *opts) { struct annotation_line *iter; struct rb_node **p = &root->rb_node; @@ -1883,7 +1884,7 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) if (ret == 0) { for (i = 0; i < al->data_nr; i++) { iter->data[i].percent_sum += annotation_data__percent(&al->data[i], - PERCENT_HITS_LOCAL); + opts->percent_type); } return; } @@ -1896,7 +1897,7 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) for (i = 0; i < al->data_nr; i++) { al->data[i].percent_sum = annotation_data__percent(&al->data[i], - PERCENT_HITS_LOCAL); + opts->percent_type); } rb_link_node(&al->rb_node, parent, p); @@ -2372,7 +2373,8 @@ void annotation__update_column_widths(struct annotation *notes) } static void annotation__calc_lines(struct annotation *notes, struct map *map, - struct rb_root *root) + struct rb_root *root, + struct annotation_options *opts) { struct annotation_line *al; struct rb_root tmp_root = RB_ROOT; @@ -2385,7 +2387,7 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, double percent; percent = annotation_data__percent(&al->data[i], - PERCENT_HITS_LOCAL); + opts->percent_type); if (percent > percent_max) percent_max = percent; @@ -2396,18 +2398,19 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, al->path = get_srcline(map->dso, notes->start + al->offset, NULL, false, true, notes->start + al->offset); - insert_source_line(&tmp_root, al); + insert_source_line(&tmp_root, al, opts); } resort_source_line(root, &tmp_root); } static void symbol__calc_lines(struct symbol *sym, struct map *map, - struct rb_root *root) + struct rb_root *root, + struct annotation_options *opts) { struct annotation *notes = symbol__annotation(sym); - annotation__calc_lines(notes, map, root); + annotation__calc_lines(notes, map, root, opts); } int symbol__tty_annotate2(struct symbol *sym, struct map *map, @@ -2424,7 +2427,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, if (opts->print_lines) { srcline_full_filename = opts->full_path; - symbol__calc_lines(sym, map, &source_line); + symbol__calc_lines(sym, map, &source_line, opts); print_summary(&source_line, dso->long_name); } @@ -2451,7 +2454,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, if (opts->print_lines) { srcline_full_filename = opts->full_path; - symbol__calc_lines(sym, map, &source_line); + symbol__calc_lines(sym, map, &source_line, opts); print_summary(&source_line, dso->long_name); } -- cgit v1.2.3 From 4c650ddc2e9e8f1d8dc46f13b30b1b9a6017fb02 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:15 +0200 Subject: perf annotate: Pass 'struct annotation_options' to map_symbol__annotation_dump() Pass 'struct annotation_options' to map_symbol__annotation_dump(), to carry on and pass the percent_type value. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-15-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 4 ++-- tools/perf/util/annotate.c | 42 +++++++++++++++++++++------------------ tools/perf/util/annotate.h | 6 ++++-- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 81876c3923d2..cfe611c28987 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -115,7 +115,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int if (!browser->navkeypressed) ops.width += 1; - annotation_line__write(al, notes, &ops); + annotation_line__write(al, notes, &ops, ab->opts); if (ops.current_entry) ab->selection = al; @@ -783,7 +783,7 @@ show_sup_ins: continue; } case 'P': - map_symbol__annotation_dump(ms, evsel); + map_symbol__annotation_dump(ms, evsel, browser->opts); continue; case 't': if (notes->options->show_total_period) { diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 2b06476c79c2..850958bb613a 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2156,10 +2156,11 @@ static void FILE__write_graph(void *fp, int graph) fputs(s, fp); } -static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) +static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp, + struct annotation_options *opts) { struct annotation *notes = symbol__annotation(sym); - struct annotation_write_ops ops = { + struct annotation_write_ops wops = { .first_line = true, .obj = fp, .set_color = FILE__set_color, @@ -2173,15 +2174,16 @@ static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) list_for_each_entry(al, ¬es->src->source, node) { if (annotation_line__filter(al, notes)) continue; - annotation_line__write(al, notes, &ops); + annotation_line__write(al, notes, &wops, opts); fputc('\n', fp); - ops.first_line = false; + wops.first_line = false; } return 0; } -int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel) +int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel, + struct annotation_options *opts) { const char *ev_name = perf_evsel__name(evsel); char buf[1024]; @@ -2203,7 +2205,7 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel) fprintf(fp, "%s() %s\nEvent: %s\n\n", ms->sym->name, ms->map->dso->long_name, ev_name); - symbol__annotate_fprintf2(ms->sym, fp); + symbol__annotate_fprintf2(ms->sym, fp, opts); fclose(fp); err = 0; @@ -2433,7 +2435,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, hists__scnprintf_title(hists, buf, sizeof(buf)); fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name); - symbol__annotate_fprintf2(sym, stdout); + symbol__annotate_fprintf2(sym, stdout, opts); annotated_source__purge(symbol__annotation(sym)->src); @@ -2472,7 +2474,8 @@ bool ui__has_annotation(void) static double annotation_line__max_percent(struct annotation_line *al, - struct annotation *notes) + struct annotation *notes, + unsigned int percent_type) { double percent_max = 0.0; int i; @@ -2481,7 +2484,7 @@ static double annotation_line__max_percent(struct annotation_line *al, double percent; percent = annotation_data__percent(&al->data[i], - PERCENT_HITS_LOCAL); + percent_type); if (percent > percent_max) percent_max = percent; @@ -2523,7 +2526,7 @@ call_like: static void __annotation_line__write(struct annotation_line *al, struct annotation *notes, bool first_line, bool current_entry, bool change_color, int width, - void *obj, + void *obj, unsigned int percent_type, int (*obj__set_color)(void *obj, int color), void (*obj__set_percent_color)(void *obj, double percent, bool current), int (*obj__set_jumps_percent_color)(void *obj, int nr, bool current), @@ -2531,7 +2534,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati void (*obj__write_graph)(void *obj, int graph)) { - double percent_max = annotation_line__max_percent(al, notes); + double percent_max = annotation_line__max_percent(al, notes, percent_type); int pcnt_width = annotation__pcnt_width(notes), cycles_width = annotation__cycles_width(notes); bool show_title = false; @@ -2552,8 +2555,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati for (i = 0; i < notes->nr_events; i++) { double percent; - percent = annotation_data__percent(&al->data[i], - PERCENT_HITS_LOCAL); + percent = annotation_data__percent(&al->data[i], percent_type); obj__set_percent_color(obj, percent, current_entry); if (notes->options->show_total_period) { @@ -2680,13 +2682,15 @@ print_addr: } void annotation_line__write(struct annotation_line *al, struct annotation *notes, - struct annotation_write_ops *ops) + struct annotation_write_ops *wops, + struct annotation_options *opts) { - __annotation_line__write(al, notes, ops->first_line, ops->current_entry, - ops->change_color, ops->width, ops->obj, - ops->set_color, ops->set_percent_color, - ops->set_jumps_percent_color, ops->printf, - ops->write_graph); + __annotation_line__write(al, notes, wops->first_line, wops->current_entry, + wops->change_color, wops->width, wops->obj, + opts->percent_type, + wops->set_color, wops->set_percent_color, + wops->set_jumps_percent_color, wops->printf, + wops->write_graph); } int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel, diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 145dec845f33..3d4579e68d28 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -185,7 +185,8 @@ struct annotation_write_ops { }; void annotation_line__write(struct annotation_line *al, struct annotation *notes, - struct annotation_write_ops *ops); + struct annotation_write_ops *ops, + struct annotation_options *opts); int __annotation__scnprintf_samples_period(struct annotation *notes, char *bf, size_t size, @@ -351,7 +352,8 @@ void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); void annotated_source__purge(struct annotated_source *as); -int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel); +int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel, + struct annotation_options *opts); bool ui__has_annotation(void); -- cgit v1.2.3 From d4265b1a1b9b58df9c3bc0a3a7aa5b72c079c77a Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:16 +0200 Subject: perf annotate: Pass browser percent_type in annotate_browser__calc_percent() Pass browser percent_type in annotate_browser__calc_percent(). Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-16-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index cfe611c28987..2a3a34d450d5 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -318,7 +318,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, double percent; percent = annotation_data__percent(&pos->al.data[i], - PERCENT_HITS_LOCAL); + browser->opts->percent_type); if (max_percent < percent) max_percent = percent; -- cgit v1.2.3 From 3e0d79531984c731951d9a8a5be406df3a78ac97 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:17 +0200 Subject: perf annotate: Add support to toggle percent type Add new key bindings to toggle percent type/base in annotation UI browser: 'p' to switch between local and global percent type 'b' to switch between hits and perdio percent base Add the following help messages to the UI browser '?' window: ... p Toggle percent type [local/global] b Toggle percent base [period/hits] ... Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-17-jolsa@kernel.org [ Moved percent_type to be the last arg to sym_title(), its an arg to what is being formmated (buf, size) ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 52 ++++++++++++++++++++++++++++++++++++--- tools/perf/util/annotate.h | 16 ++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 2a3a34d450d5..1d00e5ec7906 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -15,6 +15,7 @@ #include #include #include +#include struct disasm_line_samples { double percent; @@ -383,9 +384,10 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser) #define SYM_TITLE_MAX_SIZE (PATH_MAX + 64) static int sym_title(struct symbol *sym, struct map *map, char *title, - size_t sz) + size_t sz, int percent_type) { - return snprintf(title, sz, "%s %s", sym->name, map->dso->long_name); + return snprintf(title, sz, "%s %s [Percent: %s]", sym->name, map->dso->long_name, + percent_type_str(percent_type)); } /* @@ -423,7 +425,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, pthread_mutex_unlock(¬es->lock); symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts); - sym_title(ms->sym, ms->map, title, sizeof(title)); + sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type); ui_browser__show_title(&browser->b, title); return true; } @@ -598,6 +600,7 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help) { + struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); struct map_symbol *ms = browser->priv; struct symbol *sym = ms->sym; char symbol_dso[SYM_TITLE_MAX_SIZE]; @@ -605,7 +608,7 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const if (ui_browser__show(browser, title, help) < 0) return -1; - sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso)); + sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type); ui_browser__gotorc_title(browser, 0, 0); ui_browser__set_color(browser, HE_COLORSET_ROOT); @@ -613,6 +616,39 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const return 0; } +static void +switch_percent_type(struct annotation_options *opts, bool base) +{ + switch (opts->percent_type) { + case PERCENT_HITS_LOCAL: + if (base) + opts->percent_type = PERCENT_PERIOD_LOCAL; + else + opts->percent_type = PERCENT_HITS_GLOBAL; + break; + case PERCENT_HITS_GLOBAL: + if (base) + opts->percent_type = PERCENT_PERIOD_GLOBAL; + else + opts->percent_type = PERCENT_HITS_LOCAL; + break; + case PERCENT_PERIOD_LOCAL: + if (base) + opts->percent_type = PERCENT_HITS_LOCAL; + else + opts->percent_type = PERCENT_PERIOD_GLOBAL; + break; + case PERCENT_PERIOD_GLOBAL: + if (base) + opts->percent_type = PERCENT_HITS_GLOBAL; + else + opts->percent_type = PERCENT_PERIOD_LOCAL; + break; + default: + WARN_ON(1); + } +} + static int annotate_browser__run(struct annotate_browser *browser, struct perf_evsel *evsel, struct hist_browser_timer *hbt) @@ -703,6 +739,8 @@ static int annotate_browser__run(struct annotate_browser *browser, "k Toggle line numbers\n" "P Print to [symbol_name].annotation file.\n" "r Run available scripts\n" + "p Toggle percent type [local/global]\n" + "b Toggle percent base [period/hits]\n" "? Search string backwards\n"); continue; case 'r': @@ -802,6 +840,12 @@ show_sup_ins: notes->options->show_minmax_cycle = true; annotation__update_column_widths(notes); continue; + case 'p': + case 'b': + switch_percent_type(browser->opts, key == 'b'); + hists__scnprintf_title(hists, title, sizeof(title)); + annotate_browser__show(&browser->b, title, help); + continue; case K_LEFT: case K_ESC: case 'q': diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 3d4579e68d28..760a6678edff 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -11,6 +11,7 @@ #include #include #include +#include struct ins_ops; @@ -149,6 +150,21 @@ static inline double annotation_data__percent(struct annotation_data *data, return which < PERCENT_MAX ? data->percent[which] : -1; } +static inline const char *percent_type_str(unsigned int type) +{ + static const char *str[PERCENT_MAX] = { + "local hits", + "global hits", + "local period", + "global period", + }; + + if (WARN_ON(type >= PERCENT_MAX)) + return "N/A"; + + return str[type]; +} + static inline struct disasm_line *disasm_line(struct annotation_line *al) { return al ? container_of(al, struct disasm_line, al) : NULL; -- cgit v1.2.3 From addba8b66f9101b0e55a151fc543ff35990bc8ef Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:18 +0200 Subject: perf annotate: Make local period the default percent type Currently we display the percentages in annotation output based on number of samples hits. Switching it to period based percentage by default, because it corresponds more to the time spent on the line. Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-18-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 850958bb613a..05d15629afd0 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -49,7 +49,7 @@ struct annotation_options annotation__default_options = { .jump_arrows = true, .annotate_src = true, .offset_level = ANNOTATION__OFFSET_JUMP_TARGETS, - .percent_type = PERCENT_HITS_LOCAL, + .percent_type = PERCENT_PERIOD_LOCAL, }; static regex_t file_lineno; -- cgit v1.2.3 From 4c04868fbe931ec315ad34bb7e28e5cf725f88e4 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:19 +0200 Subject: perf annotate: Display percent type in stdio output In following patches we will allow to switch percent type even for stdio annotation outputs. Adding the percent type value into the annotation outputs title. $ perf annotate --stdio Percent | Sou ... instructions:u } (2805 samples, percent: local period) --------------------------- ... ------------------------------------------------------ ... $ perf annotate --stdio2 Samples: 2K of events 'anon ... count (approx.): 156525487, [percent: local period] safe_write.c() /usr/bin/yes Percent ... Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-19-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 05d15629afd0..6316fa96d984 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2056,10 +2056,12 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, evsel_name = buf; } - graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n", + graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples, " + "percent: %s)\n", width, width, symbol_conf.show_total_period ? "Period" : symbol_conf.show_nr_samples ? "Samples" : "Percent", - d_filename, evsel_name, h->nr_samples); + d_filename, evsel_name, h->nr_samples, + percent_type_str(opts->percent_type)); printf("%-*.*s----\n", graph_dotted_len, graph_dotted_len, graph_dotted_line); @@ -2434,7 +2436,8 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, } hists__scnprintf_title(hists, buf, sizeof(buf)); - fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name); + fprintf(stdout, "%s, [percent: %s]\n%s() %s\n", + buf, percent_type_str(opts->percent_type), sym->name, dso->long_name); symbol__annotate_fprintf2(sym, stdout, opts); annotated_source__purge(symbol__annotation(sym)->src); -- cgit v1.2.3 From 88c211907720f9eb23308401305aefa25392417f Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:20 +0200 Subject: perf annotate: Add --percent-type option Add --percent-type option to set annotation percent type from following choices: global-period, local-period, global-hits, local-hits Examples: $ perf annotate --percent-type period-local --stdio | head -1 Percent | Source code ... es, percent: local period) $ perf annotate --percent-type hits-local --stdio | head -1 Percent | Source code ... es, percent: local hits) $ perf annotate --percent-type hits-global --stdio | head -1 Percent | Source code ... es, percent: global hits) $ perf annotate --percent-type period-global --stdio | head -1 Percent | Source code ... es, percent: global period) The local/global keywords set if the percentage is computed in the scope of the function (local) or the whole data (global). The period/hits keywords set the base the percentage is computed on - the samples period or the number of samples (hits). Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-20-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-annotate.txt | 9 ++++++ tools/perf/builtin-annotate.c | 4 +++ tools/perf/util/annotate.c | 52 ++++++++++++++++++++++++++++++ tools/perf/util/annotate.h | 2 ++ 4 files changed, 67 insertions(+) diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index 749cc6055dac..e8c972f89357 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -118,6 +118,15 @@ OPTIONS --group:: Show event group information together +--percent-type:: + Set annotation percent type from following choices: + global-period, local-period, global-hits, local-hits + + The local/global keywords set if the percentage is computed + in the scope of the function (local) or the whole data (global). + The period/hits keywords set the base the percentage is computed + on - the samples period or the number of samples (hits). + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1] diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 8180319285af..830481b8db26 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -542,6 +542,10 @@ int cmd_annotate(int argc, const char **argv) OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", "'always' (default), 'never' or 'auto' only applicable to --stdio mode", stdio__config_color, "always"), + OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period", + "Set percent type local/global-period/hits", + annotate_parse_percent_type), + OPT_END() }; int ret; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 6316fa96d984..e4268b948e0e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2799,3 +2799,55 @@ void annotation_config__init(void) annotation__default_options.show_total_period = symbol_conf.show_total_period; annotation__default_options.show_nr_samples = symbol_conf.show_nr_samples; } + +static unsigned int parse_percent_type(char *str1, char *str2) +{ + unsigned int type = (unsigned int) -1; + + if (!strcmp("period", str1)) { + if (!strcmp("local", str2)) + type = PERCENT_PERIOD_LOCAL; + else if (!strcmp("global", str2)) + type = PERCENT_PERIOD_GLOBAL; + } + + if (!strcmp("hits", str1)) { + if (!strcmp("local", str2)) + type = PERCENT_HITS_LOCAL; + else if (!strcmp("global", str2)) + type = PERCENT_HITS_GLOBAL; + } + + return type; +} + +int annotate_parse_percent_type(const struct option *opt, const char *_str, + int unset __maybe_unused) +{ + struct annotation_options *opts = opt->value; + unsigned int type; + char *str1, *str2; + int err = -1; + + str1 = strdup(_str); + if (!str1) + return -ENOMEM; + + str2 = strchr(str1, '-'); + if (!str2) + goto out; + + *str2++ = 0; + + type = parse_percent_type(str1, str2); + if (type == (unsigned int) -1) + type = parse_percent_type(str2, str1); + if (type != (unsigned int) -1) { + opts->percent_type = type; + err = 0; + } + +out: + free(str1); + return err; +} diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 760a6678edff..005a5fe8a8c6 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -397,4 +397,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, void annotation_config__init(void); +int annotate_parse_percent_type(const struct option *opt, const char *_str, + int unset); #endif /* __PERF_ANNOTATE_H */ -- cgit v1.2.3 From e6902d1b7326149952abf8e7f07513e254668e52 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 4 Aug 2018 15:05:21 +0200 Subject: perf report: Add --percent-type option Set annotation percent type from following choices: global-period, local-period, global-hits, local-hits With following report option setup the percent type will be passed to annotation browser: $ perf report --percent-type period-local The local/global keywords set if the percentage is computed in the scope of the function (local) or the whole data (global). The period/hits keywords set the base the percentage is computed on - the samples period or the number of samples (hits). Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-21-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-report.txt | 9 +++++++++ tools/perf/builtin-report.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 917e36fde6d8..474a4941f65d 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -477,6 +477,15 @@ include::itrace.txt[] Display monitored tasks stored in perf data. Displaying pid/tid/ppid plus the command string aligned to distinguish parent and child tasks. +--percent-type:: + Set annotation percent type from following choices: + global-period, local-period, global-hits, local-hits + + The local/global keywords set if the percentage is computed + in the scope of the function (local) or the whole data (global). + The period/hits keywords set the base the percentage is computed + on - the samples period or the number of samples (hits). + include::callchain-overhead-calculation.txt[] SEE ALSO diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 02f7a3c27761..143542ffac20 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1124,6 +1124,9 @@ int cmd_report(int argc, const char **argv) "Time span of interest (start,stop)"), OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name, "Show inline function"), + OPT_CALLBACK(0, "percent-type", &report.annotation_opts, "local-period", + "Set percent type local/global-period/hits", + annotate_parse_percent_type), OPT_END() }; struct perf_data data = { -- cgit v1.2.3 From 7402e543a74a08ae630234012356ff5cf947bd61 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 6 Aug 2018 09:02:26 -0300 Subject: perf bpf: Add struct bpf_map struct A helper structure used by eBPF C program to describe map attributes to elf_bpf loader, to be used initially by the special __bpf_stdout__ map used to print strings into the perf ring buffer in BPF scripts, e.g.: Using the upcoming stdio.h and puts() macros to use the __bpf_stdout__ map to add strings to the ring buffer: # cat tools/perf/examples/bpf/hello.c #include int syscall_enter(openat)(void *args) { puts("Hello, world\n"); return 0; } license(GPL); # # cat ~/.perfconfig [llvm] dump-obj = true # perf trace -e openat,tools/perf/examples/bpf/hello.c/call-graph=dwarf/ cat /etc/passwd > /dev/null LLVM: dumping tools/perf/examples/bpf/hello.o 0.016 ( ): __bpf_stdout__:Hello, world 0.018 ( 0.010 ms): cat/9079 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC ) = 3 0.057 ( ): __bpf_stdout__:Hello, world 0.059 ( 0.011 ms): cat/9079 openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC ) = 3 0.417 ( ): __bpf_stdout__:Hello, world 0.419 ( 0.009 ms): cat/9079 openat(dfd: CWD, filename: /etc/passwd ) = 3 # # file tools/perf/examples/bpf/hello.o tools/perf/examples/bpf/hello.o: ELF 64-bit LSB relocatable, *unknown arch 0xf7* version 1 (SYSV), not stripped # readelf -SW tools/perf/examples/bpf/hello.o There are 10 section headers, starting at offset 0x208: Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 [ 1] .strtab STRTAB 0000000000000000 000188 00007f 00 0 0 1 [ 2] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 4 [ 3] syscalls:sys_enter_openat PROGBITS 0000000000000000 000040 000088 00 AX 0 0 8 [ 4] .relsyscalls:sys_enter_openat REL 0000000000000000 000178 000010 10 9 3 8 [ 5] maps PROGBITS 0000000000000000 0000c8 00001c 00 WA 0 0 4 [ 6] .rodata.str1.1 PROGBITS 0000000000000000 0000e4 00000e 01 AMS 0 0 1 [ 7] license PROGBITS 0000000000000000 0000f2 000004 00 WA 0 0 1 [ 8] version PROGBITS 0000000000000000 0000f8 000004 00 WA 0 0 4 [ 9] .symtab SYMTAB 0000000000000000 000100 000078 18 1 1 8 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), p (processor specific) # readelf -s tools/perf/examples/bpf/hello.o Symbol table '.symtab' contains 5 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 5 __bpf_stdout__ 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 7 _license 3: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 8 _version 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 3 syscall_enter_openat # Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-81fg60om2ifnatsybzwmiga3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/include/bpf/bpf.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/perf/include/bpf/bpf.h b/tools/perf/include/bpf/bpf.h index 2873cdde293f..1f632b56bb34 100644 --- a/tools/perf/include/bpf/bpf.h +++ b/tools/perf/include/bpf/bpf.h @@ -4,6 +4,20 @@ #include +/* + * A helper structure used by eBPF C program to describe map attributes to + * elf_bpf loader, taken from tools/testing/selftests/bpf/bpf_helpers.h: + */ +struct bpf_map { + unsigned int type; + unsigned int key_size; + unsigned int value_size; + unsigned int max_entries; + unsigned int map_flags; + unsigned int inner_map_idx; + unsigned int numa_node; +}; + #define SEC(NAME) __attribute__((section(NAME), used)) #define probe(function, vars) \ -- cgit v1.2.3 From 53a5d7b80032fcf48cdc5a6c96c8dc8a120b64ef Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 6 Aug 2018 09:15:18 -0300 Subject: perf bpf: Add bpf/stdio.h wrapper to bpf_perf_event_output function That, together with the map __bpf_output__ that is already handled by 'perf trace' to print that event's contents as strings provides a debugging facility, to show it in use, print a simple string everytime the syscalls:sys_enter_openat() syscall tracepoint is hit: # cat tools/perf/examples/bpf/hello.c #include int syscall_enter(openat)(void *args) { puts("Hello, world\n"); return 0; } license(GPL); # # perf trace -e openat,tools/perf/examples/bpf/hello.c cat /etc/passwd > /dev/null 0.016 ( ): __bpf_stdout__:Hello, world 0.018 ( 0.010 ms): cat/9079 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC) = 3 0.057 ( ): __bpf_stdout__:Hello, world 0.059 ( 0.011 ms): cat/9079 openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC) = 3 0.417 ( ): __bpf_stdout__:Hello, world 0.419 ( 0.009 ms): cat/9079 openat(dfd: CWD, filename: /etc/passwd) = 3 # This is part of an ongoing experimentation on making eBPF scripts as consumed by perf to be as concise as possible and using familiar concepts such as stdio.h functions, that end up just wrapping the existing BPF functions, trying to hide as much boilerplate as possible while using just conventions and C preprocessor tricks. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-4tiaqlx5crf0fwpe7a6j84x7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/hello.c | 9 +++++++++ tools/perf/include/bpf/stdio.h | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tools/perf/examples/bpf/hello.c create mode 100644 tools/perf/include/bpf/stdio.h diff --git a/tools/perf/examples/bpf/hello.c b/tools/perf/examples/bpf/hello.c new file mode 100644 index 000000000000..cf3c2fdc7f79 --- /dev/null +++ b/tools/perf/examples/bpf/hello.c @@ -0,0 +1,9 @@ +#include + +int syscall_enter(openat)(void *args) +{ + puts("Hello, world\n"); + return 0; +} + +license(GPL); diff --git a/tools/perf/include/bpf/stdio.h b/tools/perf/include/bpf/stdio.h new file mode 100644 index 000000000000..2899cb7bfed8 --- /dev/null +++ b/tools/perf/include/bpf/stdio.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +struct bpf_map SEC("maps") __bpf_stdout__ = { + .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, + .key_size = sizeof(int), + .value_size = sizeof(u32), + .max_entries = __NR_CPUS__, +}; + +static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) = + (void *)BPF_FUNC_perf_event_output; + +#define puts(from) \ + ({ const int __len = sizeof(from); \ + char __from[__len] = from; \ + perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \ + &__from, __len & (sizeof(from) - 1)); }) -- cgit v1.2.3 From 5941d856a90435b32a3296c0b7df8f0075430b81 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 6 Aug 2018 09:46:33 -0300 Subject: perf bpf: Make bpf__for_each_stdout_map() generic By passing a 'name' arg, that will eventually be used to setup more "bpf-output" events, e.g. to create a event where to create raw_syscalls like events that in addition to the syscall arguments will also copy the pointer contents being passed from/to userspace. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-talrnxps9p3qozk3aeh91fgv@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 3d02ae38ec56..e864a7e0ff12 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1529,12 +1529,15 @@ int bpf__apply_obj_config(void) bpf_object__for_each_safe(obj, objtmp) \ bpf_map__for_each(pos, obj) -#define bpf__for_each_stdout_map(pos, obj, objtmp) \ +#define bpf__for_each_map_named(pos, obj, objtmp, name) \ bpf__for_each_map(pos, obj, objtmp) \ if (bpf_map__name(pos) && \ - (strcmp("__bpf_stdout__", \ + (strcmp(name, \ bpf_map__name(pos)) == 0)) +#define bpf__for_each_stdout_map(pos, obj, objtmp) \ + bpf__for_each_map_named(pos, obj, objtmp, "__bpf_stdout__") + int bpf__setup_stdout(struct perf_evlist *evlist) { struct bpf_map_priv *tmpl_priv = NULL; -- cgit v1.2.3 From 92bbe8d834d293c4db7a70fd53884ec1c95d61dc Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 6 Aug 2018 09:53:35 -0300 Subject: perf bpf: Generalize bpf__setup_stdout() We will use it to set up other bpf-output events, for instance to generate augmented syscall entry tracepoints with pointer contents. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-4r7kw0nsyi4vyz6xm1tzx6a3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 26 +++++++++++++++++--------- tools/perf/util/bpf-loader.h | 7 +++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index e864a7e0ff12..95a27bb6f1a1 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1535,10 +1535,7 @@ int bpf__apply_obj_config(void) (strcmp(name, \ bpf_map__name(pos)) == 0)) -#define bpf__for_each_stdout_map(pos, obj, objtmp) \ - bpf__for_each_map_named(pos, obj, objtmp, "__bpf_stdout__") - -int bpf__setup_stdout(struct perf_evlist *evlist) +int bpf__setup_output_event(struct perf_evlist *evlist, const char *name) { struct bpf_map_priv *tmpl_priv = NULL; struct bpf_object *obj, *tmp; @@ -1547,7 +1544,7 @@ int bpf__setup_stdout(struct perf_evlist *evlist) int err; bool need_init = false; - bpf__for_each_stdout_map(map, obj, tmp) { + bpf__for_each_map_named(map, obj, tmp, name) { struct bpf_map_priv *priv = bpf_map__priv(map); if (IS_ERR(priv)) @@ -1567,17 +1564,23 @@ int bpf__setup_stdout(struct perf_evlist *evlist) return 0; if (!tmpl_priv) { - err = parse_events(evlist, "bpf-output/no-inherit=1,name=__bpf_stdout__/", - NULL); + char *event_definition = NULL; + + if (asprintf(&event_definition, "bpf-output/no-inherit=1,name=%s/", name) < 0) + return -ENOMEM; + + err = parse_events(evlist, event_definition, NULL); + free(event_definition); + if (err) { - pr_debug("ERROR: failed to create bpf-output event\n"); + pr_debug("ERROR: failed to create the \"%s\" bpf-output event\n", name); return -err; } evsel = perf_evlist__last(evlist); } - bpf__for_each_stdout_map(map, obj, tmp) { + bpf__for_each_map_named(map, obj, tmp, name) { struct bpf_map_priv *priv = bpf_map__priv(map); if (IS_ERR(priv)) @@ -1609,6 +1612,11 @@ int bpf__setup_stdout(struct perf_evlist *evlist) return 0; } +int bpf__setup_stdout(struct perf_evlist *evlist) +{ + return bpf__setup_output_event(evlist, "__bpf_stdout__"); +} + #define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START) #define ERRCODE_OFFSET(c) ERRNO_OFFSET(BPF_LOADER_ERRNO__##c) #define NR_ERRNO (__BPF_LOADER_ERRNO__END - __BPF_LOADER_ERRNO__START) diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index 5d3aefd6fae7..6be0eec043c6 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -82,6 +82,7 @@ int bpf__apply_obj_config(void); int bpf__strerror_apply_obj_config(int err, char *buf, size_t size); int bpf__setup_stdout(struct perf_evlist *evlist); +int bpf__setup_output_event(struct perf_evlist *evlist, const char *name); int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, char *buf, size_t size); @@ -138,6 +139,12 @@ bpf__setup_stdout(struct perf_evlist *evlist __maybe_unused) return 0; } +static inline int +bpf__setup_output_event(struct perf_evlist *evlist __maybe_unused, const char *name __maybe_unused) +{ + return 0; +} + static inline int __bpf_strerror(char *buf, size_t size) { -- cgit v1.2.3 From aa31be3a4874d91fb40d872f1865805ab411035c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 6 Aug 2018 11:35:37 -0300 Subject: perf bpf: Add bpf__setup_output_event() strerror() counterpart That is just bpf__strerror_setup_stdout() renamed to the more general "setup_output_event" method, keep the existing stdout() as a wrapper. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-nwnveo428qn0b48axj50vkc7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 4 ++-- tools/perf/util/bpf-loader.h | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 95a27bb6f1a1..80dead642719 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1791,8 +1791,8 @@ int bpf__strerror_apply_obj_config(int err, char *buf, size_t size) return 0; } -int bpf__strerror_setup_stdout(struct perf_evlist *evlist __maybe_unused, - int err, char *buf, size_t size) +int bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused, + int err, char *buf, size_t size) { bpf__strerror_head(err, buf, size); bpf__strerror_end(buf, size); diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index 6be0eec043c6..8eca75145ac2 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -83,9 +83,7 @@ int bpf__strerror_apply_obj_config(int err, char *buf, size_t size); int bpf__setup_stdout(struct perf_evlist *evlist); int bpf__setup_output_event(struct perf_evlist *evlist, const char *name); -int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, - char *buf, size_t size); - +int bpf__strerror_setup_output_event(struct perf_evlist *evlist, int err, char *buf, size_t size); #else #include @@ -200,11 +198,16 @@ bpf__strerror_apply_obj_config(int err __maybe_unused, } static inline int -bpf__strerror_setup_stdout(struct perf_evlist *evlist __maybe_unused, - int err __maybe_unused, char *buf, - size_t size) +bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused, + int err __maybe_unused, char *buf, size_t size) { return __bpf_strerror(buf, size); } + #endif + +static inline int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, char *buf, size_t size) +{ + return bpf__strerror_setup_output_event(evlist, err, buf, size); +} #endif -- cgit v1.2.3 From 8fa25f303adfed6eab921db8e242e59dd0b3b004 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 7 Aug 2018 15:10:19 -0300 Subject: perf bpf: Add wrappers to BPF_FUNC_probe_read(_str) functions Will be used shortly in the augmented syscalls work together with a PERF_COUNT_SW_BPF_OUTPUT software event to insert syscalls + pointer contents in the perf ring buffer, to be consumed by 'perf trace' beautifiers. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-ajlkpz4cd688ulx1u30htkj3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/include/bpf/bpf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/include/bpf/bpf.h b/tools/perf/include/bpf/bpf.h index 1f632b56bb34..47897d65e799 100644 --- a/tools/perf/include/bpf/bpf.h +++ b/tools/perf/include/bpf/bpf.h @@ -30,4 +30,7 @@ struct bpf_map { char _license[] SEC("license") = #name; \ int _version SEC("version") = LINUX_VERSION_CODE; +static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read; +static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str; + #endif /* _PERF_BPF_H */ -- cgit v1.2.3 From e0b6d2ef329098bd9780ec00a75db3b11922031a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 7 Aug 2018 15:40:13 -0300 Subject: perf trace: Handle "bpf-output" events associated with "__augmented_syscalls__" BPF map Add an example BPF script that writes syscalls:sys_enter_openat raw tracepoint payloads augmented with the first 64 bytes of the "filename" syscall pointer arg. Then catch it and print it just like with things written to the "__bpf_stdout__" map associated with a PERF_COUNT_SW_BPF_OUTPUT software event, by just letting the default tracepoint handler in 'perf trace', trace__event_handler(), to use bpf_output__fprintf(trace, sample), just like it does with all other PERF_COUNT_SW_BPF_OUTPUT events, i.e. just do a dump on the payload, so that we can check if what is being printed has at least the first 64 bytes of the "filename" arg: The augmented_syscalls.c eBPF script: # cat tools/perf/examples/bpf/augmented_syscalls.c // SPDX-License-Identifier: GPL-2.0 #include struct bpf_map SEC("maps") __augmented_syscalls__ = { .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, .key_size = sizeof(int), .value_size = sizeof(u32), .max_entries = __NR_CPUS__, }; struct syscall_enter_openat_args { unsigned long long common_tp_fields; long syscall_nr; long dfd; char *filename_ptr; long flags; long mode; }; struct augmented_enter_openat_args { struct syscall_enter_openat_args args; char filename[64]; }; int syscall_enter(openat)(struct syscall_enter_openat_args *args) { struct augmented_enter_openat_args augmented_args; probe_read(&augmented_args.args, sizeof(augmented_args.args), args); probe_read_str(&augmented_args.filename, sizeof(augmented_args.filename), args->filename_ptr); perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, &augmented_args, sizeof(augmented_args)); return 1; } license(GPL); # So it will just prepare a raw_syscalls:sys_enter payload for the "openat" syscall. This will eventually be done for all syscalls with pointer args, globally or just when the user asks, using some spec, which args of which syscalls it wants "expanded" this way, we'll probably start with just all the syscalls that have char * pointers with familiar names, the ones we already handle with the probe:vfs_getname kprobe if it is in place hooking the kernel getname_flags() function used to copy from user the paths. Running it we get: # perf trace -e perf/tools/perf/examples/bpf/augmented_syscalls.c,openat cat /etc/passwd > /dev/null 0.000 ( ): __augmented_syscalls__:X?.C......................`\..................../etc/ld.so.cache..#......,....ao.k...............k......1."......... 0.006 ( ): syscalls:sys_enter_openat:dfd: CWD, filename: 0x5c600da8, flags: CLOEXEC 0.008 ( 0.005 ms): cat/31292 openat(dfd: CWD, filename: 0x5c600da8, flags: CLOEXEC ) = 3 0.036 ( ): __augmented_syscalls__:X?.C.......................\..................../lib64/libc.so.6......... .\....#........?.......=.C..../."......... 0.037 ( ): syscalls:sys_enter_openat:dfd: CWD, filename: 0x5c808ce0, flags: CLOEXEC 0.039 ( 0.007 ms): cat/31292 openat(dfd: CWD, filename: 0x5c808ce0, flags: CLOEXEC ) = 3 0.323 ( ): __augmented_syscalls__:X?.C.....................P....................../etc/passwd......>.C....@................>.C.....,....ao.>.C........ 0.325 ( ): syscalls:sys_enter_openat:dfd: CWD, filename: 0xe8be50d6 0.327 ( 0.004 ms): cat/31292 openat(dfd: CWD, filename: 0xe8be50d6 ) = 3 # We need to go on optimizing this to avoid seding trash or zeroes in the pointer content payload, using the return from bpf_probe_read_str(), but to keep things simple at this stage and make incremental progress, lets leave it at that for now. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-g360n1zbj6bkbk6q0qo11c28@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 7 ++++ tools/perf/examples/bpf/augmented_syscalls.c | 55 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tools/perf/examples/bpf/augmented_syscalls.c diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7232a7302580..9b4e24217c46 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3240,6 +3240,13 @@ int cmd_trace(int argc, const char **argv) "cgroup monitoring only available in system-wide mode"); } + err = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__"); + if (err) { + bpf__strerror_setup_output_event(trace.evlist, err, bf, sizeof(bf)); + pr_err("ERROR: Setup trace syscalls enter failed: %s\n", bf); + goto out; + } + err = bpf__setup_stdout(trace.evlist); if (err) { bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c new file mode 100644 index 000000000000..69a31386d8cd --- /dev/null +++ b/tools/perf/examples/bpf/augmented_syscalls.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Augment the openat syscall with the contents of the filename pointer argument. + * + * Test it with: + * + * perf trace -e tools/perf/examples/bpf/augmented_syscalls.c cat /etc/passwd > /dev/null + * + * It'll catch some openat syscalls related to the dynamic linked and + * the last one should be the one for '/etc/passwd'. + * + * This matches what is marshalled into the raw_syscall:sys_enter payload + * expected by the 'perf trace' beautifiers, and can be used by them unmodified, + * which will be done as that feature is implemented in the next csets, for now + * it will appear in a dump done by the default tracepoint handler in 'perf trace', + * that uses bpf_output__fprintf() to just dump those contents, as done with + * the bpf-output event associated with the __bpf_output__ map declared in + * tools/perf/include/bpf/stdio.h. + */ + +#include + +struct bpf_map SEC("maps") __augmented_syscalls__ = { + .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, + .key_size = sizeof(int), + .value_size = sizeof(u32), + .max_entries = __NR_CPUS__, +}; + +struct syscall_enter_openat_args { + unsigned long long common_tp_fields; + long syscall_nr; + long dfd; + char *filename_ptr; + long flags; + long mode; +}; + +struct augmented_enter_openat_args { + struct syscall_enter_openat_args args; + char filename[64]; +}; + +int syscall_enter(openat)(struct syscall_enter_openat_args *args) +{ + struct augmented_enter_openat_args augmented_args; + + probe_read(&augmented_args.args, sizeof(augmented_args.args), args); + probe_read_str(&augmented_args.filename, sizeof(augmented_args.filename), args->filename_ptr); + perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, + &augmented_args, sizeof(augmented_args)); + return 1; +} + +license(GPL); -- cgit v1.2.3 From 78e890ea8683f7d570f911637b23b23d27be4aed Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 7 Aug 2018 16:19:05 -0300 Subject: perf bpf: Make bpf__setup_output_event() return the bpf-output event We're calling it to setup that event, and we'll need it later to decide if the bpf-output event we're handling is the one setup for a specific purpose, return it using ERR_PTR, etc. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-zhachv7il2n1lopt9aonwhu7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 9 +++++---- tools/perf/util/bpf-loader.c | 23 ++++++++++++----------- tools/perf/util/bpf-loader.h | 7 ++++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 9b4e24217c46..43a699cfcadf 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3216,8 +3216,9 @@ int cmd_trace(int argc, const char **argv) }; bool __maybe_unused max_stack_user_set = true; bool mmap_pages_user_set = true; + struct perf_evsel *evsel; const char * const trace_subcommands[] = { "record", NULL }; - int err; + int err = -1; char bf[BUFSIZ]; signal(SIGSEGV, sighandler_dump_stack); @@ -3240,9 +3241,9 @@ int cmd_trace(int argc, const char **argv) "cgroup monitoring only available in system-wide mode"); } - err = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__"); - if (err) { - bpf__strerror_setup_output_event(trace.evlist, err, bf, sizeof(bf)); + evsel = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__"); + if (IS_ERR(evsel)) { + bpf__strerror_setup_output_event(trace.evlist, PTR_ERR(evsel), bf, sizeof(bf)); pr_err("ERROR: Setup trace syscalls enter failed: %s\n", bf); goto out; } diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 80dead642719..47aac41349a2 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1535,7 +1535,7 @@ int bpf__apply_obj_config(void) (strcmp(name, \ bpf_map__name(pos)) == 0)) -int bpf__setup_output_event(struct perf_evlist *evlist, const char *name) +struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name) { struct bpf_map_priv *tmpl_priv = NULL; struct bpf_object *obj, *tmp; @@ -1548,7 +1548,7 @@ int bpf__setup_output_event(struct perf_evlist *evlist, const char *name) struct bpf_map_priv *priv = bpf_map__priv(map); if (IS_ERR(priv)) - return -BPF_LOADER_ERRNO__INTERNAL; + return ERR_PTR(-BPF_LOADER_ERRNO__INTERNAL); /* * No need to check map type: type should have been @@ -1561,20 +1561,20 @@ int bpf__setup_output_event(struct perf_evlist *evlist, const char *name) } if (!need_init) - return 0; + return NULL; if (!tmpl_priv) { char *event_definition = NULL; if (asprintf(&event_definition, "bpf-output/no-inherit=1,name=%s/", name) < 0) - return -ENOMEM; + return ERR_PTR(-ENOMEM); err = parse_events(evlist, event_definition, NULL); free(event_definition); if (err) { pr_debug("ERROR: failed to create the \"%s\" bpf-output event\n", name); - return -err; + return ERR_PTR(-err); } evsel = perf_evlist__last(evlist); @@ -1584,37 +1584,38 @@ int bpf__setup_output_event(struct perf_evlist *evlist, const char *name) struct bpf_map_priv *priv = bpf_map__priv(map); if (IS_ERR(priv)) - return -BPF_LOADER_ERRNO__INTERNAL; + return ERR_PTR(-BPF_LOADER_ERRNO__INTERNAL); if (priv) continue; if (tmpl_priv) { priv = bpf_map_priv__clone(tmpl_priv); if (!priv) - return -ENOMEM; + return ERR_PTR(-ENOMEM); err = bpf_map__set_priv(map, priv, bpf_map_priv__clear); if (err) { bpf_map_priv__clear(map, priv); - return err; + return ERR_PTR(err); } } else if (evsel) { struct bpf_map_op *op; op = bpf_map__add_newop(map, NULL); if (IS_ERR(op)) - return PTR_ERR(op); + return ERR_PTR(PTR_ERR(op)); op->op_type = BPF_MAP_OP_SET_EVSEL; op->v.evsel = evsel; } } - return 0; + return evsel; } int bpf__setup_stdout(struct perf_evlist *evlist) { - return bpf__setup_output_event(evlist, "__bpf_stdout__"); + struct perf_evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__"); + return IS_ERR(evsel) ? PTR_ERR(evsel) : 0; } #define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START) diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index 8eca75145ac2..62d245a90e1d 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -43,6 +43,7 @@ enum bpf_loader_errno { __BPF_LOADER_ERRNO__END, }; +struct perf_evsel; struct bpf_object; struct parse_events_term; #define PERF_BPF_PROBE_GROUP "perf_bpf_probe" @@ -82,7 +83,7 @@ int bpf__apply_obj_config(void); int bpf__strerror_apply_obj_config(int err, char *buf, size_t size); int bpf__setup_stdout(struct perf_evlist *evlist); -int bpf__setup_output_event(struct perf_evlist *evlist, const char *name); +struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name); int bpf__strerror_setup_output_event(struct perf_evlist *evlist, int err, char *buf, size_t size); #else #include @@ -137,10 +138,10 @@ bpf__setup_stdout(struct perf_evlist *evlist __maybe_unused) return 0; } -static inline int +static inline struct perf_evsel * bpf__setup_output_event(struct perf_evlist *evlist __maybe_unused, const char *name __maybe_unused) { - return 0; + return NULL; } static inline int -- cgit v1.2.3 From d3d1c4bdf5a793ab10c448f9cf5aa5b19ce026d3 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 7 Aug 2018 16:21:44 -0300 Subject: perf trace: Setup the augmented syscalls bpf-output event fields The payload that is put in place by the eBPF script attached to syscalls:sys_enter_openat (and other syscalls with pointers, in the future) can be consumed by the existing sys_enter beautifiers if evsel->priv is setup with a struct syscall_tp with struct tp_fields for the 'syscall_id' and 'args' fields expected by the beautifiers, this patch does just that. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-xfjyog8oveg2fjys9r1yy1es@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 43a699cfcadf..06215acb1481 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -77,7 +77,8 @@ struct trace { struct syscall *table; struct { struct perf_evsel *sys_enter, - *sys_exit; + *sys_exit, + *augmented; } events; } syscalls; struct record_opts opts; @@ -263,6 +264,30 @@ out_delete: return -ENOENT; } +static int perf_evsel__init_augmented_syscall_tp(struct perf_evsel *evsel) +{ + struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp)); + + if (evsel->priv != NULL) { /* field, sizeof_field, offsetof_field */ + if (__tp_field__init_uint(&sc->id, sizeof(long), sizeof(long long), evsel->needs_swap)) + goto out_delete; + + return 0; + } + + return -ENOMEM; +out_delete: + zfree(&evsel->priv); + return -EINVAL; +} + +static int perf_evsel__init_augmented_syscall_tp_args(struct perf_evsel *evsel) +{ + struct syscall_tp *sc = evsel->priv; + + return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64)); +} + static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) { evsel->priv = malloc(sizeof(struct syscall_tp)); @@ -3248,6 +3273,13 @@ int cmd_trace(int argc, const char **argv) goto out; } + if (evsel) { + if (perf_evsel__init_augmented_syscall_tp(evsel) || + perf_evsel__init_augmented_syscall_tp_args(evsel)) + goto out; + trace.syscalls.events.augmented = evsel; + } + err = bpf__setup_stdout(trace.evlist); if (err) { bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); -- cgit v1.2.3 From 88cf7084f9b4b3744294b438884c2b7999b0200a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 7 Aug 2018 16:26:35 -0300 Subject: perf trace: Wire up the augmented syscalls with the syscalls:sys_enter_FOO beautifier We just check that the evsel is the one we associated with the bpf-output event associated with the "__augmented_syscalls__" eBPF map, to show that the formatting is done properly: # perf trace -e perf/tools/perf/examples/bpf/augmented_syscalls.c,openat cat /etc/passwd > /dev/null 0.000 ( ): __augmented_syscalls__:dfd: CWD, filename: 0x43e06da8, flags: CLOEXEC 0.006 ( ): syscalls:sys_enter_openat:dfd: CWD, filename: 0x43e06da8, flags: CLOEXEC 0.007 ( 0.004 ms): cat/11486 openat(dfd: CWD, filename: 0x43e06da8, flags: CLOEXEC ) = 3 0.029 ( ): __augmented_syscalls__:dfd: CWD, filename: 0x4400ece0, flags: CLOEXEC 0.030 ( ): syscalls:sys_enter_openat:dfd: CWD, filename: 0x4400ece0, flags: CLOEXEC 0.031 ( 0.004 ms): cat/11486 openat(dfd: CWD, filename: 0x4400ece0, flags: CLOEXEC ) = 3 0.249 ( ): __augmented_syscalls__:dfd: CWD, filename: 0xc3700d6 0.250 ( ): syscalls:sys_enter_openat:dfd: CWD, filename: 0xc3700d6 0.252 ( 0.003 ms): cat/11486 openat(dfd: CWD, filename: 0xc3700d6 ) = 3 # Now we just need to get the full blown enter/exit handlers to check if the evsel being processed is the augmented_syscalls one to go pick the pointer payloads from the end of the payload. We also need to state somehow what is the layout for multi pointer arg syscalls. Also handy would be to have a BTF file with the struct definitions used in syscalls, compact, generated at kernel built time and available for use in eBPF programs. Till we get there we can go on doing some manual coupling of the most relevant syscalls with some hand built beautifiers. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-r6ba5izrml82nwfmwcp7jpkm@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 06215acb1481..22ab8e67c760 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2042,7 +2042,10 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, fprintf(trace->output, "%s:", evsel->name); if (perf_evsel__is_bpf_output(evsel)) { - bpf_output__fprintf(trace, sample); + if (evsel == trace->syscalls.events.augmented) + trace__fprintf_sys_enter(trace, evsel, sample); + else + bpf_output__fprintf(trace, sample); } else if (evsel->tp_format) { if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || trace__fprintf_sys_enter(trace, evsel, sample)) { -- cgit v1.2.3 From e5adfc3e7e774ba86f7bb725c6eef5f32df8630e Mon Sep 17 00:00:00 2001 From: Konstantin Khlebnikov Date: Tue, 7 Aug 2018 12:09:01 +0300 Subject: perf map: Synthesize maps only for thread group leader Threads share map_groups, all map events are merged into it. Thus we could send mmaps only for thread group leader. Otherwise it took ages to attach and record something from processes with many vmas and threads. Thread group leader could be already dead, but it seems perf cannot handle this case anyway. Testing dummy: #include #include #include #include #include void *thread(void *arg) { pause(); } int main(int argc, char **argv) { int threads = 10000; int vmas = 50000; pthread_t th; for (int i = 0; i < threads; i++) pthread_create(&th, NULL, thread, NULL); for (int i = 0; i < vmas; i++) mmap(NULL, 4096, (i & 1) ? PROT_READ : PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); sleep(60); return 0; } Comment by Jiri Olsa: We actualy synthesize the group leader (if we found one) for the thread even if it's not present in the thread_map, so the process maps are always in data. Signed-off-by: Konstantin Khlebnikov Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/153363294102.396323.6277944760215058174.stgit@buzz Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0c8ecf0c78a4..0cd42150f712 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -541,10 +541,17 @@ static int __event__synthesize_thread(union perf_event *comm_event, tgid, process, machine) < 0) return -1; + /* + * send mmap only for thread group leader + * see thread__init_map_groups + */ + if (pid == tgid && + perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, + process, machine, mmap_data, + proc_map_timeout)) + return -1; - return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, - process, machine, mmap_data, - proc_map_timeout); + return 0; } if (machine__is_default_guest(machine)) -- cgit v1.2.3 From 6a9405b56c274024564f9014bba97b92c91b34d6 Mon Sep 17 00:00:00 2001 From: Konstantin Khlebnikov Date: Tue, 7 Aug 2018 17:24:54 +0300 Subject: perf map: Optimize maps__fixup_overlappings() This function splits and removes overlapping areas. Maps in tree are ordered by start address thus we could find first overlap and stop if next map does not overlap. Signed-off-by: Konstantin Khlebnikov Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/153365189407.435244.7234821822450484712.stgit@buzz Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/map.c | 44 ++++++++++++++++++++++++++------------------ tools/perf/util/map.h | 1 - 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 89ac5b5dc218..36d0763311ef 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -381,20 +381,6 @@ struct map *map__clone(struct map *from) return map; } -int map__overlap(struct map *l, struct map *r) -{ - if (l->start > r->start) { - struct map *t = l; - l = r; - r = t; - } - - if (l->end > r->start) - return 1; - - return 0; -} - size_t map__fprintf(struct map *map, FILE *fp) { return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n", @@ -675,20 +661,42 @@ static void __map_groups__insert(struct map_groups *mg, struct map *map) static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) { struct rb_root *root; - struct rb_node *next; + struct rb_node *next, *first; int err = 0; down_write(&maps->lock); root = &maps->entries; - next = rb_first(root); + /* + * Find first map where end > map->start. + * Same as find_vma() in kernel. + */ + next = root->rb_node; + first = NULL; + while (next) { + struct map *pos = rb_entry(next, struct map, rb_node); + + if (pos->end > map->start) { + first = next; + if (pos->start <= map->start) + break; + next = next->rb_left; + } else + next = next->rb_right; + } + + next = first; while (next) { struct map *pos = rb_entry(next, struct map, rb_node); next = rb_next(&pos->rb_node); - if (!map__overlap(pos, map)) - continue; + /* + * Stop if current map starts after map->end. + * Maps are ordered by start: next will not overlap for sure. + */ + if (pos->start >= map->end) + break; if (verbose >= 2) { diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 4cb90f242bed..e0f327b51e66 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h @@ -166,7 +166,6 @@ static inline void __map__zput(struct map **map) #define map__zput(map) __map__zput(&map) -int map__overlap(struct map *l, struct map *r); size_t map__fprintf(struct map *map, FILE *fp); size_t map__fprintf_dsoname(struct map *map, FILE *fp); char *map__srcline(struct map *map, u64 addr, struct symbol *sym); -- cgit v1.2.3 From 354b064b8ebc1e1ede58550ca9e08bfa81e6af43 Mon Sep 17 00:00:00 2001 From: Sandipan Das Date: Thu, 9 Aug 2018 21:49:29 +0530 Subject: perf probe powerpc: Fix trace event post-processing In some cases, a symbol may have multiple aliases. Attempting to add an entry probe for such symbols results in a probe being added at an incorrect location while it fails altogether for return probes. This is only applicable for binaries with debug information. During the arch-dependent post-processing, the offset from the start of the symbol at which the probe is to be attached is determined and added to the start address of the symbol to get the probe's location. In case there are multiple aliases, this offset gets added multiple times for each alias of the symbol and we end up with an incorrect probe location. This can be verified on a powerpc64le system as shown below. $ nm /lib/modules/$(uname -r)/build/vmlinux | grep "sys_open$" ... c000000000414290 T __se_sys_open c000000000414290 T sys_open $ objdump -d /lib/modules/$(uname -r)/build/vmlinux | grep -A 10 "<__se_sys_open>:" c000000000414290 <__se_sys_open>: c000000000414290: 19 01 4c 3c addis r2,r12,281 c000000000414294: 70 c4 42 38 addi r2,r2,-15248 c000000000414298: a6 02 08 7c mflr r0 c00000000041429c: e8 ff a1 fb std r29,-24(r1) c0000000004142a0: f0 ff c1 fb std r30,-16(r1) c0000000004142a4: f8 ff e1 fb std r31,-8(r1) c0000000004142a8: 10 00 01 f8 std r0,16(r1) c0000000004142ac: c1 ff 21 f8 stdu r1,-64(r1) c0000000004142b0: 78 23 9f 7c mr r31,r4 c0000000004142b4: 78 1b 7e 7c mr r30,r3 For both the entry probe and the return probe, the probe location should be _text+4276888 (0xc000000000414298). Since another alias exists for 'sys_open', the post-processing code will end up adding the offset (8 for powerpc64le) twice and perf will attempt to add the probe at _text+4276896 (0xc0000000004142a0) instead. Before: # perf probe -v -a sys_open probe-definition(0): sys_open symbol:sys_open file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Looking at the vmlinux_path (8 entries long) Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux Try to find probe point from debuginfo. Symbol sys_open address found : c000000000414290 Matched function: __se_sys_open [2ad03a0] Probe point found: __se_sys_open+0 Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing/kprobe_events write=1 Writing event: p:probe/sys_open _text+4276896 Added new event: probe:sys_open (on sys_open) ... # perf probe -v -a sys_open%return $retval probe-definition(0): sys_open%return symbol:sys_open file:(null) line:0 offset:0 return:1 lazy:(null) 0 arguments Looking at the vmlinux_path (8 entries long) Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux Try to find probe point from debuginfo. Symbol sys_open address found : c000000000414290 Matched function: __se_sys_open [2ad03a0] Probe point found: __se_sys_open+0 Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing/README write=0 Opening /sys/kernel/debug/tracing/kprobe_events write=1 Parsing probe_events: p:probe/sys_open _text+4276896 Group:probe Event:sys_open probe:p Writing event: r:probe/sys_open__return _text+4276896 Failed to write event: Invalid argument Error: Failed to add events. Reason: Invalid argument (Code: -22) After: # perf probe -v -a sys_open probe-definition(0): sys_open symbol:sys_open file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Looking at the vmlinux_path (8 entries long) Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux Try to find probe point from debuginfo. Symbol sys_open address found : c000000000414290 Matched function: __se_sys_open [2ad03a0] Probe point found: __se_sys_open+0 Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing/kprobe_events write=1 Writing event: p:probe/sys_open _text+4276888 Added new event: probe:sys_open (on sys_open) ... # perf probe -v -a sys_open%return $retval probe-definition(0): sys_open%return symbol:sys_open file:(null) line:0 offset:0 return:1 lazy:(null) 0 arguments Looking at the vmlinux_path (8 entries long) Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux Try to find probe point from debuginfo. Symbol sys_open address found : c000000000414290 Matched function: __se_sys_open [2ad03a0] Probe point found: __se_sys_open+0 Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing/README write=0 Opening /sys/kernel/debug/tracing/kprobe_events write=1 Parsing probe_events: p:probe/sys_open _text+4276888 Group:probe Event:sys_open probe:p Writing event: r:probe/sys_open__return _text+4276888 Added new event: probe:sys_open__return (on sys_open%return) ... Reported-by: Aneesh Kumar Signed-off-by: Sandipan Das Acked-by: Naveen N. Rao Cc: Aneesh Kumar Cc: Jiri Olsa Cc: Ravi Bangoria Fixes: 99e608b5954c ("perf probe ppc64le: Fix probe location when using DWARF") Link: http://lkml.kernel.org/r/20180809161929.35058-1-sandipan@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/powerpc/util/sym-handling.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c index 53d83d7e6a09..20e7d74d86cd 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c @@ -141,8 +141,10 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev, for (i = 0; i < ntevs; i++) { tev = &pev->tevs[i]; map__for_each_symbol(map, sym, tmp) { - if (map->unmap_ip(map, sym->start) == tev->point.address) + if (map->unmap_ip(map, sym->start) == tev->point.address) { arch__fix_tev_from_maps(pev, tev, map, sym); + break; + } } } } -- cgit v1.2.3 From 096177a8b51937ba3004164f0366ef20656bb17a Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:46 -0400 Subject: tools lib traceevent, perf tools: Rename struct pevent to struct tep_handle In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes the struct pevent to struct tep_handle. Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180659.706175783@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 148 ++++++++++----------- tools/lib/traceevent/event-parse.h | 136 +++++++++---------- tools/lib/traceevent/event-plugin.c | 14 +- tools/lib/traceevent/parse-filter.c | 14 +- tools/lib/traceevent/plugin_cfg80211.c | 4 +- tools/lib/traceevent/plugin_function.c | 6 +- tools/lib/traceevent/plugin_hrtimer.c | 4 +- tools/lib/traceevent/plugin_jbd2.c | 4 +- tools/lib/traceevent/plugin_kmem.c | 4 +- tools/lib/traceevent/plugin_kvm.c | 4 +- tools/lib/traceevent/plugin_mac80211.c | 4 +- tools/lib/traceevent/plugin_sched_switch.c | 4 +- tools/lib/traceevent/plugin_scsi.c | 4 +- tools/lib/traceevent/plugin_xen.c | 4 +- tools/perf/util/header.c | 4 +- tools/perf/util/python.c | 2 +- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- .../util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/sort.h | 2 +- tools/perf/util/trace-event-parse.c | 12 +- tools/perf/util/trace-event-read.c | 24 ++-- tools/perf/util/trace-event-scripting.c | 4 +- tools/perf/util/trace-event.c | 6 +- tools/perf/util/trace-event.h | 18 +-- 24 files changed, 215 insertions(+), 215 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index e5f2acbb70cc..1eec313cc447 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -160,7 +160,7 @@ struct cmdline_list { int pid; }; -static int cmdline_init(struct pevent *pevent) +static int cmdline_init(struct tep_handle *pevent) { struct cmdline_list *cmdlist = pevent->cmdlist; struct cmdline_list *item; @@ -189,7 +189,7 @@ static int cmdline_init(struct pevent *pevent) return 0; } -static const char *find_cmdline(struct pevent *pevent, int pid) +static const char *find_cmdline(struct tep_handle *pevent, int pid) { const struct cmdline *comm; struct cmdline key; @@ -218,7 +218,7 @@ static const char *find_cmdline(struct pevent *pevent, int pid) * Returns 1 if the pid has a cmdline mapped to it * 0 otherwise. */ -int pevent_pid_is_registered(struct pevent *pevent, int pid) +int pevent_pid_is_registered(struct tep_handle *pevent, int pid) { const struct cmdline *comm; struct cmdline key; @@ -244,7 +244,7 @@ int pevent_pid_is_registered(struct pevent *pevent, int pid) * we must add this pid. This is much slower than when cmdlines * are added before the array is initialized. */ -static int add_new_comm(struct pevent *pevent, const char *comm, int pid) +static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) { struct cmdline *cmdlines = pevent->cmdlines; const struct cmdline *cmdline; @@ -296,7 +296,7 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid) * This adds a mapping to search for command line names with * a given pid. The comm is duplicated. */ -int pevent_register_comm(struct pevent *pevent, const char *comm, int pid) +int pevent_register_comm(struct tep_handle *pevent, const char *comm, int pid) { struct cmdline_list *item; @@ -324,7 +324,7 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid) return 0; } -int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock) +int pevent_register_trace_clock(struct tep_handle *pevent, const char *trace_clock) { pevent->trace_clock = strdup(trace_clock); if (!pevent->trace_clock) { @@ -381,7 +381,7 @@ static int func_bcmp(const void *a, const void *b) return 1; } -static int func_map_init(struct pevent *pevent) +static int func_map_init(struct tep_handle *pevent) { struct func_list *funclist; struct func_list *item; @@ -421,7 +421,7 @@ static int func_map_init(struct pevent *pevent) } static struct func_map * -__find_func(struct pevent *pevent, unsigned long long addr) +__find_func(struct tep_handle *pevent, unsigned long long addr) { struct func_map *func; struct func_map key; @@ -453,7 +453,7 @@ struct func_resolver { * keep using it instead of duplicating all the entries inside * pevent->funclist. */ -int pevent_set_function_resolver(struct pevent *pevent, +int pevent_set_function_resolver(struct tep_handle *pevent, pevent_func_resolver_t *func, void *priv) { struct func_resolver *resolver = malloc(sizeof(*resolver)); @@ -477,14 +477,14 @@ int pevent_set_function_resolver(struct pevent *pevent, * Stop using whatever alternative resolver was set, use the default * one instead. */ -void pevent_reset_function_resolver(struct pevent *pevent) +void pevent_reset_function_resolver(struct tep_handle *pevent) { free(pevent->func_resolver); pevent->func_resolver = NULL; } static struct func_map * -find_func(struct pevent *pevent, unsigned long long addr) +find_func(struct tep_handle *pevent, unsigned long long addr) { struct func_map *map; @@ -511,7 +511,7 @@ find_func(struct pevent *pevent, unsigned long long addr) * address. Note, the address does not have to be exact, it * will select the function that would contain the address. */ -const char *pevent_find_function(struct pevent *pevent, unsigned long long addr) +const char *pevent_find_function(struct tep_handle *pevent, unsigned long long addr) { struct func_map *map; @@ -532,7 +532,7 @@ const char *pevent_find_function(struct pevent *pevent, unsigned long long addr) * name and the function offset. */ unsigned long long -pevent_find_function_address(struct pevent *pevent, unsigned long long addr) +pevent_find_function_address(struct tep_handle *pevent, unsigned long long addr) { struct func_map *map; @@ -553,7 +553,7 @@ pevent_find_function_address(struct pevent *pevent, unsigned long long addr) * This registers a function name with an address and module. * The @func passed in is duplicated. */ -int pevent_register_function(struct pevent *pevent, char *func, +int pevent_register_function(struct tep_handle *pevent, char *func, unsigned long long addr, char *mod) { struct func_list *item = malloc(sizeof(*item)); @@ -594,7 +594,7 @@ out_free: * * This prints out the stored functions. */ -void pevent_print_funcs(struct pevent *pevent) +void pevent_print_funcs(struct tep_handle *pevent) { int i; @@ -636,7 +636,7 @@ static int printk_cmp(const void *a, const void *b) return 0; } -static int printk_map_init(struct pevent *pevent) +static int printk_map_init(struct tep_handle *pevent) { struct printk_list *printklist; struct printk_list *item; @@ -668,7 +668,7 @@ static int printk_map_init(struct pevent *pevent) } static struct printk_map * -find_printk(struct pevent *pevent, unsigned long long addr) +find_printk(struct tep_handle *pevent, unsigned long long addr) { struct printk_map *printk; struct printk_map key; @@ -693,7 +693,7 @@ find_printk(struct pevent *pevent, unsigned long long addr) * This registers a string by the address it was stored in the kernel. * The @fmt passed in is duplicated. */ -int pevent_register_print_string(struct pevent *pevent, const char *fmt, +int pevent_register_print_string(struct tep_handle *pevent, const char *fmt, unsigned long long addr) { struct printk_list *item = malloc(sizeof(*item)); @@ -737,7 +737,7 @@ out_free: * * This prints the string formats that were stored. */ -void pevent_print_printk(struct pevent *pevent) +void pevent_print_printk(struct tep_handle *pevent) { int i; @@ -756,7 +756,7 @@ static struct event_format *alloc_event(void) return calloc(1, sizeof(struct event_format)); } -static int add_event(struct pevent *pevent, struct event_format *event) +static int add_event(struct tep_handle *pevent, struct event_format *event) { int i; struct event_format **events = realloc(pevent->events, sizeof(event) * @@ -2915,7 +2915,7 @@ process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg } static struct pevent_function_handler * -find_func_handler(struct pevent *pevent, char *func_name) +find_func_handler(struct tep_handle *pevent, char *func_name) { struct pevent_function_handler *func; @@ -2930,7 +2930,7 @@ find_func_handler(struct pevent *pevent, char *func_name) return func; } -static void remove_func_handler(struct pevent *pevent, char *func_name) +static void remove_func_handler(struct tep_handle *pevent, char *func_name) { struct pevent_function_handler *func; struct pevent_function_handler **next; @@ -3337,7 +3337,7 @@ pevent_find_any_field(struct event_format *event, const char *name) * Returns the number (converted to host) from the * raw data. */ -unsigned long long pevent_read_number(struct pevent *pevent, +unsigned long long pevent_read_number(struct tep_handle *pevent, const void *ptr, int size) { switch (size) { @@ -3384,7 +3384,7 @@ int pevent_read_number_field(struct format_field *field, const void *data, } } -static int get_common_info(struct pevent *pevent, +static int get_common_info(struct tep_handle *pevent, const char *type, int *offset, int *size) { struct event_format *event; @@ -3410,7 +3410,7 @@ static int get_common_info(struct pevent *pevent, return 0; } -static int __parse_common(struct pevent *pevent, void *data, +static int __parse_common(struct tep_handle *pevent, void *data, int *size, int *offset, const char *name) { int ret; @@ -3423,42 +3423,42 @@ static int __parse_common(struct pevent *pevent, void *data, return pevent_read_number(pevent, data + *offset, *size); } -static int trace_parse_common_type(struct pevent *pevent, void *data) +static int trace_parse_common_type(struct tep_handle *pevent, void *data) { return __parse_common(pevent, data, &pevent->type_size, &pevent->type_offset, "common_type"); } -static int parse_common_pid(struct pevent *pevent, void *data) +static int parse_common_pid(struct tep_handle *pevent, void *data) { return __parse_common(pevent, data, &pevent->pid_size, &pevent->pid_offset, "common_pid"); } -static int parse_common_pc(struct pevent *pevent, void *data) +static int parse_common_pc(struct tep_handle *pevent, void *data) { return __parse_common(pevent, data, &pevent->pc_size, &pevent->pc_offset, "common_preempt_count"); } -static int parse_common_flags(struct pevent *pevent, void *data) +static int parse_common_flags(struct tep_handle *pevent, void *data) { return __parse_common(pevent, data, &pevent->flags_size, &pevent->flags_offset, "common_flags"); } -static int parse_common_lock_depth(struct pevent *pevent, void *data) +static int parse_common_lock_depth(struct tep_handle *pevent, void *data) { return __parse_common(pevent, data, &pevent->ld_size, &pevent->ld_offset, "common_lock_depth"); } -static int parse_common_migrate_disable(struct pevent *pevent, void *data) +static int parse_common_migrate_disable(struct tep_handle *pevent, void *data) { return __parse_common(pevent, data, &pevent->ld_size, &pevent->ld_offset, @@ -3474,7 +3474,7 @@ static int events_id_cmp(const void *a, const void *b); * * Returns an event that has a given @id. */ -struct event_format *pevent_find_event(struct pevent *pevent, int id) +struct event_format *pevent_find_event(struct tep_handle *pevent, int id) { struct event_format **eventptr; struct event_format key; @@ -3507,7 +3507,7 @@ struct event_format *pevent_find_event(struct pevent *pevent, int id) * @sys. If @sys is NULL the first event with @name is returned. */ struct event_format * -pevent_find_event_by_name(struct pevent *pevent, +pevent_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name) { struct event_format *event; @@ -3537,7 +3537,7 @@ pevent_find_event_by_name(struct pevent *pevent, static unsigned long long eval_num_arg(void *data, int size, struct event_format *event, struct print_arg *arg) { - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; unsigned long long val = 0; unsigned long long left, right; struct print_arg *typearg = NULL; @@ -3820,7 +3820,7 @@ static void print_str_to_seq(struct trace_seq *s, const char *format, trace_seq_printf(s, format, str); } -static void print_bitmask_to_seq(struct pevent *pevent, +static void print_bitmask_to_seq(struct tep_handle *pevent, struct trace_seq *s, const char *format, int len_arg, const void *data, int size) { @@ -3878,7 +3878,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, struct event_format *event, const char *format, int len_arg, struct print_arg *arg) { - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; struct print_flag_sym *flag; struct format_field *field; struct printk_map *printk; @@ -4227,7 +4227,7 @@ static void free_args(struct print_arg *args) static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struct event_format *event) { - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; struct format_field *field, *ip_field; struct print_arg *args, *arg, **next; unsigned long long ip, val; @@ -4404,7 +4404,7 @@ static char * get_bprint_format(void *data, int size __maybe_unused, struct event_format *event) { - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; unsigned long long addr; struct format_field *field; struct printk_map *printk; @@ -4805,7 +4805,7 @@ void pevent_print_field(struct trace_seq *s, void *data, { unsigned long long val; unsigned int offset, len, i; - struct pevent *pevent = field->event->pevent; + struct tep_handle *pevent = field->event->pevent; if (field->flags & FIELD_IS_ARRAY) { offset = field->offset; @@ -4880,7 +4880,7 @@ void pevent_print_fields(struct trace_seq *s, void *data, static void pretty_print(struct trace_seq *s, void *data, int size, struct event_format *event) { - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; struct print_fmt *print_fmt = &event->print_fmt; struct print_arg *arg = print_fmt->args; struct print_arg *args = NULL; @@ -5149,7 +5149,7 @@ out_failed: * need rescheduling, in hard/soft interrupt, preempt count * and lock depth) and places it into the trace_seq. */ -void pevent_data_lat_fmt(struct pevent *pevent, +void pevent_data_lat_fmt(struct tep_handle *pevent, struct trace_seq *s, struct pevent_record *record) { static int check_lock_depth = 1; @@ -5229,7 +5229,7 @@ void pevent_data_lat_fmt(struct pevent *pevent, * * This returns the event id from the @rec. */ -int pevent_data_type(struct pevent *pevent, struct pevent_record *rec) +int pevent_data_type(struct tep_handle *pevent, struct pevent_record *rec) { return trace_parse_common_type(pevent, rec->data); } @@ -5241,7 +5241,7 @@ int pevent_data_type(struct pevent *pevent, struct pevent_record *rec) * * This returns the event form a given @type; */ -struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type) +struct event_format *pevent_data_event_from_type(struct tep_handle *pevent, int type) { return pevent_find_event(pevent, type); } @@ -5253,7 +5253,7 @@ struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type * * This returns the PID from a record. */ -int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec) +int pevent_data_pid(struct tep_handle *pevent, struct pevent_record *rec) { return parse_common_pid(pevent, rec->data); } @@ -5265,7 +5265,7 @@ int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec) * * This returns the preempt count from a record. */ -int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec) +int pevent_data_preempt_count(struct tep_handle *pevent, struct pevent_record *rec) { return parse_common_pc(pevent, rec->data); } @@ -5279,7 +5279,7 @@ int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec) * * Use trace_flag_type enum for the flags (see event-parse.h). */ -int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec) +int pevent_data_flags(struct tep_handle *pevent, struct pevent_record *rec) { return parse_common_flags(pevent, rec->data); } @@ -5292,7 +5292,7 @@ int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec) * This returns a pointer to the command line that has the given * @pid. */ -const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid) +const char *pevent_data_comm_from_pid(struct tep_handle *pevent, int pid) { const char *comm; @@ -5301,7 +5301,7 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid) } static struct cmdline * -pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next) +pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next) { struct cmdline_list *cmdlist = (struct cmdline_list *)next; @@ -5329,7 +5329,7 @@ pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next) * next pid. * Also, it does a linear seach, so it may be slow. */ -struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm, +struct cmdline *pevent_data_pid_from_comm(struct tep_handle *pevent, const char *comm, struct cmdline *next) { struct cmdline *cmdline; @@ -5371,7 +5371,7 @@ struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *com * Returns the pid for a give cmdline. If @cmdline is NULL, then * -1 is returned. */ -int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline) +int pevent_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) { struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; @@ -5441,7 +5441,7 @@ static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) * is found. */ struct event_format * -pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record) +pevent_find_event_by_record(struct tep_handle *pevent, struct pevent_record *record) { int type; @@ -5464,7 +5464,7 @@ pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record) * * Writes the tasks comm, pid and CPU to @s. */ -void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, struct pevent_record *record) { @@ -5492,7 +5492,7 @@ void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, * * Writes the timestamp of the record into @s. */ -void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, struct pevent_record *record, bool use_trace_clock) @@ -5542,7 +5542,7 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, * * Writes the parsing of the record's data to @s. */ -void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, struct pevent_record *record) { @@ -5559,7 +5559,7 @@ void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s, pevent_event_info(s, event, record); } -void pevent_print_event(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, struct pevent_record *record, bool use_trace_clock) { struct event_format *event; @@ -5630,7 +5630,7 @@ static int events_system_cmp(const void *a, const void *b) return events_id_cmp(a, b); } -struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type sort_type) +struct event_format **pevent_list_events(struct tep_handle *pevent, enum event_sort_type sort_type) { struct event_format **events; int (*sort)(const void *a, const void *b); @@ -5941,7 +5941,7 @@ static void parse_header_field(const char *field, * * /sys/kernel/debug/tracing/events/header_page */ -int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size, +int pevent_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, int long_size) { int ignore; @@ -5994,7 +5994,7 @@ static void free_handler(struct event_handler *handle) free(handle); } -static int find_event_handle(struct pevent *pevent, struct event_format *event) +static int find_event_handle(struct tep_handle *pevent, struct event_format *event) { struct event_handler *handle, **next; @@ -6036,7 +6036,7 @@ static int find_event_handle(struct pevent *pevent, struct event_format *event) * /sys/kernel/debug/tracing/events/.../.../format */ enum pevent_errno __pevent_parse_format(struct event_format **eventp, - struct pevent *pevent, const char *buf, + struct tep_handle *pevent, const char *buf, unsigned long size, const char *sys) { struct event_format *event; @@ -6143,7 +6143,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, } static enum pevent_errno -__pevent_parse_event(struct pevent *pevent, +__pevent_parse_event(struct tep_handle *pevent, struct event_format **eventp, const char *buf, unsigned long size, const char *sys) @@ -6185,7 +6185,7 @@ event_add_failed: * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno pevent_parse_format(struct pevent *pevent, +enum pevent_errno pevent_parse_format(struct tep_handle *pevent, struct event_format **eventp, const char *buf, unsigned long size, const char *sys) @@ -6207,7 +6207,7 @@ enum pevent_errno pevent_parse_format(struct pevent *pevent, * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, +enum pevent_errno pevent_parse_event(struct tep_handle *pevent, const char *buf, unsigned long size, const char *sys) { struct event_format *event = NULL; @@ -6221,7 +6221,7 @@ static const char * const pevent_error_str[] = { }; #undef _PE -int pevent_strerror(struct pevent *pevent __maybe_unused, +int pevent_strerror(struct tep_handle *pevent __maybe_unused, enum pevent_errno errnum, char *buf, size_t buflen) { int idx; @@ -6435,7 +6435,7 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, struct pevent_record *record, int err) { struct format_field *field = pevent_find_field(event, name); - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; unsigned long long val; struct func_map *func; char tmp[128]; @@ -6491,7 +6491,7 @@ static void free_func_handle(struct pevent_function_handler *func) * The @parameters is a variable list of pevent_func_arg_type enums that * must end with PEVENT_FUNC_ARG_VOID. */ -int pevent_register_print_function(struct pevent *pevent, +int pevent_register_print_function(struct tep_handle *pevent, pevent_func_handler func, enum pevent_func_arg_type ret_type, char *name, ...) @@ -6578,7 +6578,7 @@ int pevent_register_print_function(struct pevent *pevent, * * Returns 0 if the handler was removed successully, -1 otherwise. */ -int pevent_unregister_print_function(struct pevent *pevent, +int pevent_unregister_print_function(struct tep_handle *pevent, pevent_func_handler func, char *name) { struct pevent_function_handler *func_handle; @@ -6591,7 +6591,7 @@ int pevent_unregister_print_function(struct pevent *pevent, return -1; } -static struct event_format *pevent_search_event(struct pevent *pevent, int id, +static struct event_format *pevent_search_event(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name) { @@ -6631,7 +6631,7 @@ static struct event_format *pevent_search_event(struct pevent *pevent, int id, * If @id is >= 0, then it is used to find the event. * else @sys_name and @event_name are used. */ -int pevent_register_event_handler(struct pevent *pevent, int id, +int pevent_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, pevent_event_handler_func func, void *context) { @@ -6715,7 +6715,7 @@ static int handle_matches(struct event_handler *handler, int id, * * Returns 0 if handler was removed successfully, -1 if event was not found. */ -int pevent_unregister_event_handler(struct pevent *pevent, int id, +int pevent_unregister_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, pevent_event_handler_func func, void *context) { @@ -6756,9 +6756,9 @@ not_found: /** * pevent_alloc - create a pevent handle */ -struct pevent *pevent_alloc(void) +struct tep_handle *pevent_alloc(void) { - struct pevent *pevent = calloc(1, sizeof(*pevent)); + struct tep_handle *pevent = calloc(1, sizeof(*pevent)); if (pevent) pevent->ref_count = 1; @@ -6766,7 +6766,7 @@ struct pevent *pevent_alloc(void) return pevent; } -void pevent_ref(struct pevent *pevent) +void pevent_ref(struct tep_handle *pevent) { pevent->ref_count++; } @@ -6814,7 +6814,7 @@ void pevent_free_format(struct event_format *event) * pevent_free - free a pevent handle * @pevent: the pevent handle to free */ -void pevent_free(struct pevent *pevent) +void pevent_free(struct tep_handle *pevent) { struct cmdline_list *cmdlist, *cmdnext; struct func_list *funclist, *funcnext; @@ -6899,7 +6899,7 @@ void pevent_free(struct pevent *pevent) free(pevent); } -void pevent_unref(struct pevent *pevent) +void pevent_unref(struct tep_handle *pevent) { pevent_free(pevent); } diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 0c03538df74c..b7f4c8393abd 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -98,7 +98,7 @@ extern int trace_seq_do_printf(struct trace_seq *s); /* ----------------------- pevent ----------------------- */ -struct pevent; +struct tep_handle; struct event_format; typedef int (*pevent_event_handler_func)(struct trace_seq *s, @@ -106,8 +106,8 @@ typedef int (*pevent_event_handler_func)(struct trace_seq *s, struct event_format *event, void *context); -typedef int (*pevent_plugin_load_func)(struct pevent *pevent); -typedef int (*pevent_plugin_unload_func)(struct pevent *pevent); +typedef int (*pevent_plugin_load_func)(struct tep_handle *pevent); +typedef int (*pevent_plugin_unload_func)(struct tep_handle *pevent); struct pevent_plugin_option { struct pevent_plugin_option *next; @@ -127,12 +127,12 @@ struct pevent_plugin_option { * PEVENT_PLUGIN_LOADER: (required) * The function name to initialized the plugin. * - * int PEVENT_PLUGIN_LOADER(struct pevent *pevent) + * int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) * * PEVENT_PLUGIN_UNLOADER: (optional) * The function called just before unloading * - * int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) + * int PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) * * PEVENT_PLUGIN_OPTIONS: (optional) * Plugin options that can be set before loading @@ -320,7 +320,7 @@ struct print_fmt { }; struct event_format { - struct pevent *pevent; + struct tep_handle *pevent; char *name; int id; int flags; @@ -435,9 +435,9 @@ struct plugin_list; #define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) -struct plugin_list *traceevent_load_plugins(struct pevent *pevent); +struct plugin_list *traceevent_load_plugins(struct tep_handle *pevent); void traceevent_unload_plugins(struct plugin_list *plugin_list, - struct pevent *pevent); + struct tep_handle *pevent); char **traceevent_plugin_list_options(void); void traceevent_plugin_free_options_list(char **list); int traceevent_plugin_add_options(const char *name, @@ -457,7 +457,7 @@ struct func_resolver; typedef char *(pevent_func_resolver_t)(void *priv, unsigned long long *addrp, char **modp); -struct pevent { +struct tep_handle { int ref_count; int header_page_ts_offset; @@ -532,13 +532,13 @@ struct pevent { char *trace_clock; }; -static inline void pevent_set_flag(struct pevent *pevent, int flag) +static inline void pevent_set_flag(struct tep_handle *pevent, int flag) { pevent->flags |= flag; } static inline unsigned short -__data2host2(struct pevent *pevent, unsigned short data) +__data2host2(struct tep_handle *pevent, unsigned short data) { unsigned short swap; @@ -552,7 +552,7 @@ __data2host2(struct pevent *pevent, unsigned short data) } static inline unsigned int -__data2host4(struct pevent *pevent, unsigned int data) +__data2host4(struct tep_handle *pevent, unsigned int data) { unsigned int swap; @@ -568,7 +568,7 @@ __data2host4(struct pevent *pevent, unsigned int data) } static inline unsigned long long -__data2host8(struct pevent *pevent, unsigned long long data) +__data2host8(struct tep_handle *pevent, unsigned long long data) { unsigned long long swap; @@ -615,36 +615,36 @@ enum trace_flag_type { TRACE_FLAG_SOFTIRQ = 0x10, }; -int pevent_set_function_resolver(struct pevent *pevent, +int pevent_set_function_resolver(struct tep_handle *pevent, pevent_func_resolver_t *func, void *priv); -void pevent_reset_function_resolver(struct pevent *pevent); -int pevent_register_comm(struct pevent *pevent, const char *comm, int pid); -int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock); -int pevent_register_function(struct pevent *pevent, char *name, +void pevent_reset_function_resolver(struct tep_handle *pevent); +int pevent_register_comm(struct tep_handle *pevent, const char *comm, int pid); +int pevent_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); +int pevent_register_function(struct tep_handle *pevent, char *name, unsigned long long addr, char *mod); -int pevent_register_print_string(struct pevent *pevent, const char *fmt, +int pevent_register_print_string(struct tep_handle *pevent, const char *fmt, unsigned long long addr); -int pevent_pid_is_registered(struct pevent *pevent, int pid); +int pevent_pid_is_registered(struct tep_handle *pevent, int pid); -void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, struct pevent_record *record); -void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, struct pevent_record *record, bool use_trace_clock); -void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, struct pevent_record *record); -void pevent_print_event(struct pevent *pevent, struct trace_seq *s, +void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, struct pevent_record *record, bool use_trace_clock); -int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size, +int pevent_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, int long_size); -enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, +enum pevent_errno pevent_parse_event(struct tep_handle *pevent, const char *buf, unsigned long size, const char *sys); -enum pevent_errno pevent_parse_format(struct pevent *pevent, +enum pevent_errno pevent_parse_format(struct tep_handle *pevent, struct event_format **eventp, const char *buf, unsigned long size, const char *sys); @@ -673,50 +673,50 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, struct pevent_record *record, int err); -int pevent_register_event_handler(struct pevent *pevent, int id, +int pevent_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, pevent_event_handler_func func, void *context); -int pevent_unregister_event_handler(struct pevent *pevent, int id, +int pevent_unregister_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, pevent_event_handler_func func, void *context); -int pevent_register_print_function(struct pevent *pevent, +int pevent_register_print_function(struct tep_handle *pevent, pevent_func_handler func, enum pevent_func_arg_type ret_type, char *name, ...); -int pevent_unregister_print_function(struct pevent *pevent, +int pevent_unregister_print_function(struct tep_handle *pevent, pevent_func_handler func, char *name); struct format_field *pevent_find_common_field(struct event_format *event, const char *name); struct format_field *pevent_find_field(struct event_format *event, const char *name); struct format_field *pevent_find_any_field(struct event_format *event, const char *name); -const char *pevent_find_function(struct pevent *pevent, unsigned long long addr); +const char *pevent_find_function(struct tep_handle *pevent, unsigned long long addr); unsigned long long -pevent_find_function_address(struct pevent *pevent, unsigned long long addr); -unsigned long long pevent_read_number(struct pevent *pevent, const void *ptr, int size); +pevent_find_function_address(struct tep_handle *pevent, unsigned long long addr); +unsigned long long pevent_read_number(struct tep_handle *pevent, const void *ptr, int size); int pevent_read_number_field(struct format_field *field, const void *data, unsigned long long *value); -struct event_format *pevent_find_event(struct pevent *pevent, int id); +struct event_format *pevent_find_event(struct tep_handle *pevent, int id); struct event_format * -pevent_find_event_by_name(struct pevent *pevent, const char *sys, const char *name); +pevent_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name); struct event_format * -pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record); +pevent_find_event_by_record(struct tep_handle *pevent, struct pevent_record *record); -void pevent_data_lat_fmt(struct pevent *pevent, +void pevent_data_lat_fmt(struct tep_handle *pevent, struct trace_seq *s, struct pevent_record *record); -int pevent_data_type(struct pevent *pevent, struct pevent_record *rec); -struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type); -int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec); -int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec); -int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec); -const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid); +int pevent_data_type(struct tep_handle *pevent, struct pevent_record *rec); +struct event_format *pevent_data_event_from_type(struct tep_handle *pevent, int type); +int pevent_data_pid(struct tep_handle *pevent, struct pevent_record *rec); +int pevent_data_preempt_count(struct tep_handle *pevent, struct pevent_record *rec); +int pevent_data_flags(struct tep_handle *pevent, struct pevent_record *rec); +const char *pevent_data_comm_from_pid(struct tep_handle *pevent, int pid); struct cmdline; -struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm, +struct cmdline *pevent_data_pid_from_comm(struct tep_handle *pevent, const char *comm, struct cmdline *next); -int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline); +int pevent_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); void pevent_print_field(struct trace_seq *s, void *data, struct format_field *field); @@ -724,77 +724,77 @@ void pevent_print_fields(struct trace_seq *s, void *data, int size __maybe_unused, struct event_format *event); void pevent_event_info(struct trace_seq *s, struct event_format *event, struct pevent_record *record); -int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, +int pevent_strerror(struct tep_handle *pevent, enum pevent_errno errnum, char *buf, size_t buflen); -struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type); +struct event_format **pevent_list_events(struct tep_handle *pevent, enum event_sort_type); struct format_field **pevent_event_common_fields(struct event_format *event); struct format_field **pevent_event_fields(struct event_format *event); -static inline int pevent_get_cpus(struct pevent *pevent) +static inline int pevent_get_cpus(struct tep_handle *pevent) { return pevent->cpus; } -static inline void pevent_set_cpus(struct pevent *pevent, int cpus) +static inline void pevent_set_cpus(struct tep_handle *pevent, int cpus) { pevent->cpus = cpus; } -static inline int pevent_get_long_size(struct pevent *pevent) +static inline int pevent_get_long_size(struct tep_handle *pevent) { return pevent->long_size; } -static inline void pevent_set_long_size(struct pevent *pevent, int long_size) +static inline void pevent_set_long_size(struct tep_handle *pevent, int long_size) { pevent->long_size = long_size; } -static inline int pevent_get_page_size(struct pevent *pevent) +static inline int pevent_get_page_size(struct tep_handle *pevent) { return pevent->page_size; } -static inline void pevent_set_page_size(struct pevent *pevent, int _page_size) +static inline void pevent_set_page_size(struct tep_handle *pevent, int _page_size) { pevent->page_size = _page_size; } -static inline int pevent_is_file_bigendian(struct pevent *pevent) +static inline int pevent_is_file_bigendian(struct tep_handle *pevent) { return pevent->file_bigendian; } -static inline void pevent_set_file_bigendian(struct pevent *pevent, int endian) +static inline void pevent_set_file_bigendian(struct tep_handle *pevent, int endian) { pevent->file_bigendian = endian; } -static inline int pevent_is_host_bigendian(struct pevent *pevent) +static inline int pevent_is_host_bigendian(struct tep_handle *pevent) { return pevent->host_bigendian; } -static inline void pevent_set_host_bigendian(struct pevent *pevent, int endian) +static inline void pevent_set_host_bigendian(struct tep_handle *pevent, int endian) { pevent->host_bigendian = endian; } -static inline int pevent_is_latency_format(struct pevent *pevent) +static inline int pevent_is_latency_format(struct tep_handle *pevent) { return pevent->latency_format; } -static inline void pevent_set_latency_format(struct pevent *pevent, int lat) +static inline void pevent_set_latency_format(struct tep_handle *pevent, int lat) { pevent->latency_format = lat; } -struct pevent *pevent_alloc(void); -void pevent_free(struct pevent *pevent); -void pevent_ref(struct pevent *pevent); -void pevent_unref(struct pevent *pevent); +struct tep_handle *pevent_alloc(void); +void pevent_free(struct tep_handle *pevent); +void pevent_ref(struct tep_handle *pevent); +void pevent_unref(struct tep_handle *pevent); /* access to the internal parser */ void pevent_buffer_init(const char *buf, unsigned long long size); @@ -805,8 +805,8 @@ const char *pevent_get_input_buf(void); unsigned long long pevent_get_input_buf_ptr(void); /* for debugging */ -void pevent_print_funcs(struct pevent *pevent); -void pevent_print_printk(struct pevent *pevent); +void pevent_print_funcs(struct tep_handle *pevent); +void pevent_print_printk(struct tep_handle *pevent); /* ----------------------- filtering ----------------------- */ @@ -933,13 +933,13 @@ struct filter_type { #define PEVENT_FILTER_ERROR_BUFSZ 1024 struct event_filter { - struct pevent *pevent; + struct tep_handle *pevent; int filters; struct filter_type *event_filters; char error_buffer[PEVENT_FILTER_ERROR_BUFSZ]; }; -struct event_filter *pevent_filter_alloc(struct pevent *pevent); +struct event_filter *pevent_filter_alloc(struct tep_handle *pevent); /* for backward compatibility */ #define FILTER_NONE PEVENT_ERRNO__NO_FILTER diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index d542cb60ca1a..62b011ae18c1 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -281,7 +281,7 @@ void traceevent_print_plugins(struct trace_seq *s, } static void -load_plugin(struct pevent *pevent, const char *path, +load_plugin(struct tep_handle *pevent, const char *path, const char *file, void *data) { struct plugin_list **plugin_list = data; @@ -336,9 +336,9 @@ load_plugin(struct pevent *pevent, const char *path, } static void -load_plugins_dir(struct pevent *pevent, const char *suffix, +load_plugins_dir(struct tep_handle *pevent, const char *suffix, const char *path, - void (*load_plugin)(struct pevent *pevent, + void (*load_plugin)(struct tep_handle *pevent, const char *path, const char *name, void *data), @@ -378,8 +378,8 @@ load_plugins_dir(struct pevent *pevent, const char *suffix, } static void -load_plugins(struct pevent *pevent, const char *suffix, - void (*load_plugin)(struct pevent *pevent, +load_plugins(struct tep_handle *pevent, const char *suffix, + void (*load_plugin)(struct tep_handle *pevent, const char *path, const char *name, void *data), @@ -431,7 +431,7 @@ load_plugins(struct pevent *pevent, const char *suffix, } struct plugin_list* -traceevent_load_plugins(struct pevent *pevent) +traceevent_load_plugins(struct tep_handle *pevent) { struct plugin_list *list = NULL; @@ -440,7 +440,7 @@ traceevent_load_plugins(struct pevent *pevent) } void -traceevent_unload_plugins(struct plugin_list *plugin_list, struct pevent *pevent) +traceevent_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent) { pevent_plugin_unload_func func; struct plugin_list *list; diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 431e8b309f6e..a97b84aece3a 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -179,7 +179,7 @@ add_filter_type(struct event_filter *filter, int id) * pevent_filter_alloc - create a new event filter * @pevent: The pevent that this filter is associated with */ -struct event_filter *pevent_filter_alloc(struct pevent *pevent) +struct event_filter *pevent_filter_alloc(struct tep_handle *pevent) { struct event_filter *filter; @@ -269,7 +269,7 @@ static int event_match(struct event_format *event, } static enum pevent_errno -find_event(struct pevent *pevent, struct event_list **events, +find_event(struct tep_handle *pevent, struct event_list **events, char *sys_name, char *event_name) { struct event_format *event; @@ -1270,7 +1270,7 @@ static void filter_init_error_buf(struct event_filter *filter) enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, const char *filter_str) { - struct pevent *pevent = filter->pevent; + struct tep_handle *pevent = filter->pevent; struct event_list *event; struct event_list *events = NULL; const char *filter_start; @@ -1550,8 +1550,8 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, enum filter_trivial_type type) { - struct pevent *src_pevent; - struct pevent *dest_pevent; + struct tep_handle *src_pevent; + struct tep_handle *dest_pevent; struct event_format *event; struct filter_type *filter_type; struct filter_arg *arg; @@ -1874,7 +1874,7 @@ static int test_num(struct event_format *event, struct filter_arg *arg, static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record) { struct event_format *event; - struct pevent *pevent; + struct tep_handle *pevent; unsigned long long addr; const char *val = NULL; unsigned int size; @@ -2049,7 +2049,7 @@ int pevent_event_filtered(struct event_filter *filter, int event_id) enum pevent_errno pevent_filter_match(struct event_filter *filter, struct pevent_record *record) { - struct pevent *pevent = filter->pevent; + struct tep_handle *pevent = filter->pevent; struct filter_type *filter_type; int event_id; int ret; diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c index 8f8586912da7..959d94f1d7f5 100644 --- a/tools/lib/traceevent/plugin_cfg80211.c +++ b/tools/lib/traceevent/plugin_cfg80211.c @@ -25,7 +25,7 @@ process___le16_to_cpup(struct trace_seq *s, unsigned long long *args) return val ? (long long) le16toh(*val) : 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process___le16_to_cpup, @@ -36,7 +36,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process___le16_to_cpup, "__le16_to_cpup"); diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 42dbf73758f3..3ed965a8b5f0 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c @@ -125,7 +125,7 @@ static int add_and_get_index(const char *parent, const char *child, int cpu) static int function_handler(struct trace_seq *s, struct pevent_record *record, struct event_format *event, void *context) { - struct pevent *pevent = event->pevent; + struct tep_handle *pevent = event->pevent; unsigned long long function; unsigned long long pfunction; const char *func; @@ -163,7 +163,7 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record, return 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "ftrace", "function", function_handler, NULL); @@ -173,7 +173,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { int i, x; diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c index 12bf14cc1152..746e7d464802 100644 --- a/tools/lib/traceevent/plugin_hrtimer.c +++ b/tools/lib/traceevent/plugin_hrtimer.c @@ -66,7 +66,7 @@ static int timer_start_handler(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "timer", "hrtimer_expire_entry", @@ -77,7 +77,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_expire_entry", diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c index 5c23d5bd27ce..3909db7043c9 100644 --- a/tools/lib/traceevent/plugin_jbd2.c +++ b/tools/lib/traceevent/plugin_jbd2.c @@ -47,7 +47,7 @@ process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args) return jiffies; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_jbd2_dev_to_name, @@ -65,7 +65,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process_jbd2_dev_to_name, "jbd2_dev_to_name"); diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index 70650ff48d78..e342edadf03d 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c @@ -48,7 +48,7 @@ static int call_site_handler(struct trace_seq *s, struct pevent_record *record, return 1; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "kmem", "kfree", call_site_handler, NULL); @@ -71,7 +71,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "kmem", "kfree", call_site_handler, NULL); diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 18536f756577..a6e96ba4d776 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -444,7 +444,7 @@ process_is_writable_pte(struct trace_seq *s, unsigned long long *args) return pte & PT_WRITABLE_MASK; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { init_disassembler(); @@ -486,7 +486,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit", kvm_exit_handler, NULL); diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index 7e15a0f1c2fd..9ac1141f351a 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -86,7 +86,7 @@ static int drv_bss_info_changed(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "mac80211", "drv_bss_info_changed", @@ -94,7 +94,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "mac80211", "drv_bss_info_changed", diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index ec30c2fcbac0..de90fb82b83f 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c @@ -134,7 +134,7 @@ static int sched_switch_handler(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "sched", "sched_switch", sched_switch_handler, NULL); @@ -147,7 +147,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch", sched_switch_handler, NULL); diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index 5e750af2b461..e430a49e4995 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c @@ -413,7 +413,7 @@ unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_scsi_trace_parse_cdb, @@ -426,7 +426,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb, "scsi_trace_parse_cdb"); diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c index 690173bfa13e..11dbddde2e6a 100644 --- a/tools/lib/traceevent/plugin_xen.c +++ b/tools/lib/traceevent/plugin_xen.c @@ -119,7 +119,7 @@ unsigned long long process_xen_hypercall_name(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_xen_hypercall_name, @@ -130,7 +130,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) +void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process_xen_hypercall_name, "xen_hypercall_name"); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 5f1af7b07b96..c669896de98a 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3204,7 +3204,7 @@ static int read_attr(int fd, struct perf_header *ph, } static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, - struct pevent *pevent) + struct tep_handle *pevent) { struct event_format *event; char bf[128]; @@ -3236,7 +3236,7 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, } static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist, - struct pevent *pevent) + struct tep_handle *pevent) { struct perf_evsel *pos; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 863b61478edd..fd72cce6599c 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -341,7 +341,7 @@ static bool is_tracepoint(struct pyrf_event *pevent) static PyObject* tracepoint_field(struct pyrf_event *pe, struct format_field *field) { - struct pevent *pevent = field->event->pevent; + struct tep_handle *pevent = field->event->pevent; void *data = pe->sample.raw_data; PyObject *ret = NULL; unsigned long long val; diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 7b79c413486b..45484f0f7292 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -535,7 +535,7 @@ static int perl_stop_script(void) return 0; } -static int perl_generate_script(struct pevent *pevent, const char *outfile) +static int perl_generate_script(struct tep_handle *pevent, const char *outfile) { struct event_format *event = NULL; struct format_field *f; diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index bc32e57d17be..77bddd50e705 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -1588,7 +1588,7 @@ static int python_stop_script(void) return 0; } -static int python_generate_script(struct pevent *pevent, const char *outfile) +static int python_generate_script(struct tep_handle *pevent, const char *outfile) { struct event_format *event = NULL; struct format_field *f; diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 8bf302cafcec..a97cf8e6be86 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -276,7 +276,7 @@ extern struct sort_entry sort_thread; extern struct list_head hist_entry__sort_list; struct perf_evlist; -struct pevent; +struct tep_handle; int setup_sorting(struct perf_evlist *evlist); int setup_output_field(void); void reset_output_field(void); diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index e0a6e9a6a053..0ef1c5042bc6 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -32,7 +32,7 @@ static int get_common_field(struct scripting_context *context, int *offset, int *size, const char *type) { - struct pevent *pevent = context->pevent; + struct tep_handle *pevent = context->pevent; struct event_format *event; struct format_field *field; @@ -136,7 +136,7 @@ void event_format__print(struct event_format *event, return event_format__fprintf(event, cpu, data, size, stdout); } -void parse_ftrace_printk(struct pevent *pevent, +void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size __maybe_unused) { unsigned long long addr; @@ -161,7 +161,7 @@ void parse_ftrace_printk(struct pevent *pevent, } } -void parse_saved_cmdline(struct pevent *pevent, +void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size __maybe_unused) { char *comm; @@ -178,18 +178,18 @@ void parse_saved_cmdline(struct pevent *pevent, } } -int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size) +int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size) { return pevent_parse_event(pevent, buf, size, "ftrace"); } -int parse_event_file(struct pevent *pevent, +int parse_event_file(struct tep_handle *pevent, char *buf, unsigned long size, char *sys) { return pevent_parse_event(pevent, buf, size, sys); } -struct event_format *trace_find_next_event(struct pevent *pevent, +struct event_format *trace_find_next_event(struct tep_handle *pevent, struct event_format *event) { static int idx; diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index 40b425949aa3..cbd4970415ef 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -96,7 +96,7 @@ static void skip(int size) }; } -static unsigned int read4(struct pevent *pevent) +static unsigned int read4(struct tep_handle *pevent) { unsigned int data; @@ -105,7 +105,7 @@ static unsigned int read4(struct pevent *pevent) return __data2host4(pevent, data); } -static unsigned long long read8(struct pevent *pevent) +static unsigned long long read8(struct tep_handle *pevent) { unsigned long long data; @@ -158,7 +158,7 @@ out: return str; } -static int read_proc_kallsyms(struct pevent *pevent) +static int read_proc_kallsyms(struct tep_handle *pevent) { unsigned int size; @@ -181,7 +181,7 @@ static int read_proc_kallsyms(struct pevent *pevent) return 0; } -static int read_ftrace_printk(struct pevent *pevent) +static int read_ftrace_printk(struct tep_handle *pevent) { unsigned int size; char *buf; @@ -208,7 +208,7 @@ static int read_ftrace_printk(struct pevent *pevent) return 0; } -static int read_header_files(struct pevent *pevent) +static int read_header_files(struct tep_handle *pevent) { unsigned long long size; char *header_page; @@ -259,7 +259,7 @@ static int read_header_files(struct pevent *pevent) return ret; } -static int read_ftrace_file(struct pevent *pevent, unsigned long long size) +static int read_ftrace_file(struct tep_handle *pevent, unsigned long long size) { int ret; char *buf; @@ -284,8 +284,8 @@ out: return ret; } -static int read_event_file(struct pevent *pevent, char *sys, - unsigned long long size) +static int read_event_file(struct tep_handle *pevent, char *sys, + unsigned long long size) { int ret; char *buf; @@ -310,7 +310,7 @@ out: return ret; } -static int read_ftrace_files(struct pevent *pevent) +static int read_ftrace_files(struct tep_handle *pevent) { unsigned long long size; int count; @@ -328,7 +328,7 @@ static int read_ftrace_files(struct pevent *pevent) return 0; } -static int read_event_files(struct pevent *pevent) +static int read_event_files(struct tep_handle *pevent) { unsigned long long size; char *sys; @@ -356,7 +356,7 @@ static int read_event_files(struct pevent *pevent) return 0; } -static int read_saved_cmdline(struct pevent *pevent) +static int read_saved_cmdline(struct tep_handle *pevent) { unsigned long long size; char *buf; @@ -399,7 +399,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) int host_bigendian; int file_long_size; int file_page_size; - struct pevent *pevent = NULL; + struct tep_handle *pevent = NULL; int err; repipe = __repipe; diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c index b1e5c3a2b8e3..b749f812ac70 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c @@ -66,7 +66,7 @@ static int python_start_script_unsupported(const char *script __maybe_unused, return -1; } -static int python_generate_script_unsupported(struct pevent *pevent +static int python_generate_script_unsupported(struct tep_handle *pevent __maybe_unused, const char *outfile __maybe_unused) @@ -130,7 +130,7 @@ static int perl_start_script_unsupported(const char *script __maybe_unused, return -1; } -static int perl_generate_script_unsupported(struct pevent *pevent +static int perl_generate_script_unsupported(struct tep_handle *pevent __maybe_unused, const char *outfile __maybe_unused) { diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 1aa368603268..7c0cd9a0f575 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -28,7 +28,7 @@ static bool tevent_initialized; int trace_event__init(struct trace_event *t) { - struct pevent *pevent = pevent_alloc(); + struct tep_handle *pevent = pevent_alloc(); if (pevent) { t->plugin_list = traceevent_load_plugins(pevent); @@ -41,7 +41,7 @@ int trace_event__init(struct trace_event *t) static int trace_event__init2(void) { int be = traceevent_host_bigendian(); - struct pevent *pevent; + struct tep_handle *pevent; if (trace_event__init(&tevent)) return -1; @@ -76,7 +76,7 @@ static struct event_format* tp_format(const char *sys, const char *name) { char *tp_dir = get_events_file(sys); - struct pevent *pevent = tevent.pevent; + struct tep_handle *pevent = tevent.pevent; struct event_format *event = NULL; char path[PATH_MAX]; size_t size; diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index dcbdb53dc702..b8f2516e9a65 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -13,7 +13,7 @@ struct thread; struct plugin_list; struct trace_event { - struct pevent *pevent; + struct tep_handle *pevent; struct plugin_list *plugin_list; }; @@ -34,20 +34,20 @@ void event_format__fprintf(struct event_format *event, void event_format__print(struct event_format *event, int cpu, void *data, int size); -int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size); -int parse_event_file(struct pevent *pevent, +int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); +int parse_event_file(struct tep_handle *pevent, char *buf, unsigned long size, char *sys); unsigned long long raw_field_value(struct event_format *event, const char *name, void *data); -void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size); -void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size); -void parse_saved_cmdline(struct pevent *pevent, char *file, unsigned int size); +void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); +void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); +void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size); ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); -struct event_format *trace_find_next_event(struct pevent *pevent, +struct event_format *trace_find_next_event(struct tep_handle *pevent, struct event_format *event); unsigned long long read_size(struct event_format *event, void *ptr, int size); unsigned long long eval_flag(const char *flag); @@ -83,7 +83,7 @@ struct scripting_ops { void (*process_stat)(struct perf_stat_config *config, struct perf_evsel *evsel, u64 tstamp); void (*process_stat_interval)(u64 tstamp); - int (*generate_script) (struct pevent *pevent, const char *outfile); + int (*generate_script) (struct tep_handle *pevent, const char *outfile); }; extern unsigned int scripting_max_stack; @@ -94,7 +94,7 @@ void setup_perl_scripting(void); void setup_python_scripting(void); struct scripting_context { - struct pevent *pevent; + struct tep_handle *pevent; void *event_data; }; -- cgit v1.2.3 From cbc49b25b9cf26bf8c91169085be27382d945dd7 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:47 -0400 Subject: tools lib traceevent, perf tools: Rename 'struct pevent_record' to 'struct tep_record' In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes the 'struct pevent_record' to 'struct tep_record'. Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180659.866021298@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 36 ++++++++++++------------ tools/lib/traceevent/event-parse.h | 44 +++++++++++++++--------------- tools/lib/traceevent/parse-filter.c | 24 ++++++++-------- tools/lib/traceevent/plugin_function.c | 2 +- tools/lib/traceevent/plugin_hrtimer.c | 4 +-- tools/lib/traceevent/plugin_kmem.c | 2 +- tools/lib/traceevent/plugin_kvm.c | 14 +++++----- tools/lib/traceevent/plugin_mac80211.c | 2 +- tools/lib/traceevent/plugin_sched_switch.c | 6 ++-- tools/perf/builtin-kmem.c | 2 +- tools/perf/util/sort.c | 2 +- tools/perf/util/trace-event-parse.c | 2 +- 12 files changed, 70 insertions(+), 70 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 1eec313cc447..90f30f9dde14 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5150,7 +5150,7 @@ out_failed: * and lock depth) and places it into the trace_seq. */ void pevent_data_lat_fmt(struct tep_handle *pevent, - struct trace_seq *s, struct pevent_record *record) + struct trace_seq *s, struct tep_record *record) { static int check_lock_depth = 1; static int check_migrate_disable = 1; @@ -5229,7 +5229,7 @@ void pevent_data_lat_fmt(struct tep_handle *pevent, * * This returns the event id from the @rec. */ -int pevent_data_type(struct tep_handle *pevent, struct pevent_record *rec) +int pevent_data_type(struct tep_handle *pevent, struct tep_record *rec) { return trace_parse_common_type(pevent, rec->data); } @@ -5253,7 +5253,7 @@ struct event_format *pevent_data_event_from_type(struct tep_handle *pevent, int * * This returns the PID from a record. */ -int pevent_data_pid(struct tep_handle *pevent, struct pevent_record *rec) +int pevent_data_pid(struct tep_handle *pevent, struct tep_record *rec) { return parse_common_pid(pevent, rec->data); } @@ -5265,7 +5265,7 @@ int pevent_data_pid(struct tep_handle *pevent, struct pevent_record *rec) * * This returns the preempt count from a record. */ -int pevent_data_preempt_count(struct tep_handle *pevent, struct pevent_record *rec) +int pevent_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec) { return parse_common_pc(pevent, rec->data); } @@ -5279,7 +5279,7 @@ int pevent_data_preempt_count(struct tep_handle *pevent, struct pevent_record *r * * Use trace_flag_type enum for the flags (see event-parse.h). */ -int pevent_data_flags(struct tep_handle *pevent, struct pevent_record *rec) +int pevent_data_flags(struct tep_handle *pevent, struct tep_record *rec) { return parse_common_flags(pevent, rec->data); } @@ -5400,7 +5400,7 @@ int pevent_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) * writes the print format into the trace_seq. */ void pevent_event_info(struct trace_seq *s, struct event_format *event, - struct pevent_record *record) + struct tep_record *record) { int print_pretty = 1; @@ -5441,7 +5441,7 @@ static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) * is found. */ struct event_format * -pevent_find_event_by_record(struct tep_handle *pevent, struct pevent_record *record) +pevent_find_event_by_record(struct tep_handle *pevent, struct tep_record *record) { int type; @@ -5466,7 +5466,7 @@ pevent_find_event_by_record(struct tep_handle *pevent, struct pevent_record *rec */ void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, - struct pevent_record *record) + struct tep_record *record) { void *data = record->data; const char *comm; @@ -5494,7 +5494,7 @@ void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, */ void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, - struct pevent_record *record, + struct tep_record *record, bool use_trace_clock) { unsigned long secs; @@ -5544,7 +5544,7 @@ void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, */ void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, - struct pevent_record *record) + struct tep_record *record) { static const char *spaces = " "; /* 20 spaces */ int len; @@ -5560,7 +5560,7 @@ void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, } void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, - struct pevent_record *record, bool use_trace_clock) + struct tep_record *record, bool use_trace_clock) { struct event_format *event; @@ -6244,7 +6244,7 @@ int pevent_strerror(struct tep_handle *pevent __maybe_unused, } int get_field_val(struct trace_seq *s, struct format_field *field, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err) { if (!field) { @@ -6277,7 +6277,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field, * On failure, it returns NULL. */ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, int *len, int err) { struct format_field *field; @@ -6324,7 +6324,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, * Returns 0 on success -1 on field not found. */ int pevent_get_field_val(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err) { struct format_field *field; @@ -6349,7 +6349,7 @@ int pevent_get_field_val(struct trace_seq *s, struct event_format *event, * Returns 0 on success -1 on field not found. */ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err) { struct format_field *field; @@ -6374,7 +6374,7 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, * Returns 0 on success -1 on field not found. */ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err) { struct format_field *field; @@ -6400,7 +6400,7 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, */ int pevent_print_num_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, - struct pevent_record *record, int err) + struct tep_record *record, int err) { struct format_field *field = pevent_find_field(event, name); unsigned long long val; @@ -6432,7 +6432,7 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt, */ int pevent_print_func_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, - struct pevent_record *record, int err) + struct tep_record *record, int err) { struct format_field *field = pevent_find_field(event, name); struct tep_handle *pevent = event->pevent; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index b7f4c8393abd..b1e4d37bedd8 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -41,7 +41,7 @@ #define DEBUG_RECORD 0 #endif -struct pevent_record { +struct tep_record { unsigned long long ts; unsigned long long offset; long long missed_events; /* buffer dropped events before */ @@ -53,8 +53,8 @@ struct pevent_record { int locked; /* Do not free, even if ref_count is zero */ void *priv; #if DEBUG_RECORD - struct pevent_record *prev; - struct pevent_record *next; + struct tep_record *prev; + struct tep_record *next; long alloc_addr; #endif }; @@ -102,7 +102,7 @@ struct tep_handle; struct event_format; typedef int (*pevent_event_handler_func)(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context); @@ -628,16 +628,16 @@ int pevent_pid_is_registered(struct tep_handle *pevent, int pid); void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, - struct pevent_record *record); + struct tep_record *record); void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, - struct pevent_record *record, + struct tep_record *record, bool use_trace_clock); void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, struct event_format *event, - struct pevent_record *record); + struct tep_record *record); void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, - struct pevent_record *record, bool use_trace_clock); + struct tep_record *record, bool use_trace_clock); int pevent_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, int long_size); @@ -652,26 +652,26 @@ void pevent_free_format(struct event_format *event); void pevent_free_format_field(struct format_field *field); void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, int *len, int err); int pevent_get_field_val(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err); int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err); int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, - const char *name, struct pevent_record *record, + const char *name, struct tep_record *record, unsigned long long *val, int err); int pevent_print_num_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, - struct pevent_record *record, int err); + struct tep_record *record, int err); int pevent_print_func_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, - struct pevent_record *record, int err); + struct tep_record *record, int err); int pevent_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, @@ -703,15 +703,15 @@ struct event_format * pevent_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name); struct event_format * -pevent_find_event_by_record(struct tep_handle *pevent, struct pevent_record *record); +pevent_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); void pevent_data_lat_fmt(struct tep_handle *pevent, - struct trace_seq *s, struct pevent_record *record); -int pevent_data_type(struct tep_handle *pevent, struct pevent_record *rec); + struct trace_seq *s, struct tep_record *record); +int pevent_data_type(struct tep_handle *pevent, struct tep_record *rec); struct event_format *pevent_data_event_from_type(struct tep_handle *pevent, int type); -int pevent_data_pid(struct tep_handle *pevent, struct pevent_record *rec); -int pevent_data_preempt_count(struct tep_handle *pevent, struct pevent_record *rec); -int pevent_data_flags(struct tep_handle *pevent, struct pevent_record *rec); +int pevent_data_pid(struct tep_handle *pevent, struct tep_record *rec); +int pevent_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); +int pevent_data_flags(struct tep_handle *pevent, struct tep_record *rec); const char *pevent_data_comm_from_pid(struct tep_handle *pevent, int pid); struct cmdline; struct cmdline *pevent_data_pid_from_comm(struct tep_handle *pevent, const char *comm, @@ -723,7 +723,7 @@ void pevent_print_field(struct trace_seq *s, void *data, void pevent_print_fields(struct trace_seq *s, void *data, int size __maybe_unused, struct event_format *event); void pevent_event_info(struct trace_seq *s, struct event_format *event, - struct pevent_record *record); + struct tep_record *record); int pevent_strerror(struct tep_handle *pevent, enum pevent_errno errnum, char *buf, size_t buflen); @@ -957,7 +957,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, const char *filter_str); enum pevent_errno pevent_filter_match(struct event_filter *filter, - struct pevent_record *record); + struct tep_record *record); int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, char *buf, size_t buflen); diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index a97b84aece3a..784ccac90999 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -1697,10 +1697,10 @@ int pevent_filter_event_has_trivial(struct event_filter *filter, } static int test_filter(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err); + struct tep_record *record, enum pevent_errno *err); static const char * -get_comm(struct event_format *event, struct pevent_record *record) +get_comm(struct event_format *event, struct tep_record *record) { const char *comm; int pid; @@ -1712,7 +1712,7 @@ get_comm(struct event_format *event, struct pevent_record *record) static unsigned long long get_value(struct event_format *event, - struct format_field *field, struct pevent_record *record) + struct format_field *field, struct tep_record *record) { unsigned long long val; @@ -1748,11 +1748,11 @@ get_value(struct event_format *event, static unsigned long long get_arg_value(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err); + struct tep_record *record, enum pevent_errno *err); static unsigned long long get_exp_value(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err) + struct tep_record *record, enum pevent_errno *err) { unsigned long long lval, rval; @@ -1807,7 +1807,7 @@ get_exp_value(struct event_format *event, struct filter_arg *arg, static unsigned long long get_arg_value(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err) + struct tep_record *record, enum pevent_errno *err) { switch (arg->type) { case FILTER_ARG_FIELD: @@ -1831,7 +1831,7 @@ get_arg_value(struct event_format *event, struct filter_arg *arg, } static int test_num(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err) + struct tep_record *record, enum pevent_errno *err) { unsigned long long lval, rval; @@ -1871,7 +1871,7 @@ static int test_num(struct event_format *event, struct filter_arg *arg, } } -static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record) +static const char *get_field_str(struct filter_arg *arg, struct tep_record *record) { struct event_format *event; struct tep_handle *pevent; @@ -1922,7 +1922,7 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r } static int test_str(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err) + struct tep_record *record, enum pevent_errno *err) { const char *val; @@ -1953,7 +1953,7 @@ static int test_str(struct event_format *event, struct filter_arg *arg, } static int test_op(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err) + struct tep_record *record, enum pevent_errno *err) { switch (arg->op.type) { case FILTER_OP_AND: @@ -1975,7 +1975,7 @@ static int test_op(struct event_format *event, struct filter_arg *arg, } static int test_filter(struct event_format *event, struct filter_arg *arg, - struct pevent_record *record, enum pevent_errno *err) + struct tep_record *record, enum pevent_errno *err) { if (*err) { /* @@ -2047,7 +2047,7 @@ int pevent_event_filtered(struct event_filter *filter, int event_id) * otherwise - error occurred during test */ enum pevent_errno pevent_filter_match(struct event_filter *filter, - struct pevent_record *record) + struct tep_record *record) { struct tep_handle *pevent = filter->pevent; struct filter_type *filter_type; diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 3ed965a8b5f0..86b5bb9bf22c 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c @@ -122,7 +122,7 @@ static int add_and_get_index(const char *parent, const char *child, int cpu) return 0; } -static int function_handler(struct trace_seq *s, struct pevent_record *record, +static int function_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { struct tep_handle *pevent = event->pevent; diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c index 746e7d464802..695e8e1b90e6 100644 --- a/tools/lib/traceevent/plugin_hrtimer.c +++ b/tools/lib/traceevent/plugin_hrtimer.c @@ -25,7 +25,7 @@ #include "event-parse.h" static int timer_expire_handler(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { trace_seq_printf(s, "hrtimer="); @@ -45,7 +45,7 @@ static int timer_expire_handler(struct trace_seq *s, } static int timer_start_handler(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { trace_seq_printf(s, "hrtimer="); diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index e342edadf03d..46e8e959539e 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c @@ -23,7 +23,7 @@ #include "event-parse.h" -static int call_site_handler(struct trace_seq *s, struct pevent_record *record, +static int call_site_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { struct format_field *field; diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index a6e96ba4d776..63420e3a340c 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -247,7 +247,7 @@ static const char *find_exit_reason(unsigned isa, int val) return strings[i].str; } -static int print_exit_reason(struct trace_seq *s, struct pevent_record *record, +static int print_exit_reason(struct trace_seq *s, struct tep_record *record, struct event_format *event, const char *field) { unsigned long long isa; @@ -268,7 +268,7 @@ static int print_exit_reason(struct trace_seq *s, struct pevent_record *record, return 0; } -static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, +static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { unsigned long long info1 = 0, info2 = 0; @@ -291,7 +291,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, #define KVM_EMUL_INSN_F_CS_L (1 << 3) static int kvm_emulate_insn_handler(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { unsigned long long rip, csbase, len, flags, failed; @@ -330,7 +330,7 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, } -static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_record *record, +static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { if (print_exit_reason(s, record, event, "exit_code") < 0) @@ -344,7 +344,7 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_r return 0; } -static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record, +static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { pevent_print_num_field(s, "rip %llx ", event, "rip", record, 1); @@ -370,7 +370,7 @@ union kvm_mmu_page_role { }; }; -static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, +static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { unsigned long long val; @@ -417,7 +417,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, } static int kvm_mmu_get_page_handler(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { unsigned long long val; diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index 9ac1141f351a..83d002753251 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -58,7 +58,7 @@ static void print_string(struct trace_seq *s, struct event_format *event, #define SP() trace_seq_putc(s, ' ') static int drv_bss_info_changed(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { void *data = record->data; diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index de90fb82b83f..b72a52d2fd1d 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c @@ -45,7 +45,7 @@ static void write_state(struct trace_seq *s, int val) } static void write_and_save_comm(struct format_field *field, - struct pevent_record *record, + struct tep_record *record, struct trace_seq *s, int pid) { const char *comm; @@ -65,7 +65,7 @@ static void write_and_save_comm(struct format_field *field, } static int sched_wakeup_handler(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { struct format_field *field; @@ -94,7 +94,7 @@ static int sched_wakeup_handler(struct trace_seq *s, } static int sched_switch_handler(struct trace_seq *s, - struct pevent_record *record, + struct tep_record *record, struct event_format *event, void *context) { struct format_field *field; diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 54d3f21b0e62..b23e861fa6ae 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -729,7 +729,7 @@ static char *compact_gfp_string(unsigned long gfp_flags) static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample, unsigned int gfp_flags) { - struct pevent_record record = { + struct tep_record record = { .cpu = sample->cpu, .data = sample->raw_data, .size = sample->raw_size, diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index fed2952ab45a..2c9924ab872d 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -601,7 +601,7 @@ static char *get_trace_output(struct hist_entry *he) { struct trace_seq seq; struct perf_evsel *evsel; - struct pevent_record rec = { + struct tep_record rec = { .data = he->raw_data, .size = he->raw_size, }; diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 0ef1c5042bc6..29af1fb0b888 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -116,7 +116,7 @@ unsigned long long read_size(struct event_format *event, void *ptr, int size) void event_format__fprintf(struct event_format *event, int cpu, void *data, int size, FILE *fp) { - struct pevent_record record; + struct tep_record record; struct trace_seq s; memset(&record, 0, sizeof(record)); -- cgit v1.2.3 From c32d52b4641d3c7b2569b3fe148bf687e5c61888 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:48 -0400 Subject: tools lib traceevent, perf tools: Rename pevent plugin related APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes the pevent plugin related API. Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.005287044@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 8 ++--- tools/lib/traceevent/event-parse.h | 56 +++++++++++++++--------------- tools/lib/traceevent/event-plugin.c | 24 ++++++------- tools/lib/traceevent/plugin_cfg80211.c | 4 +-- tools/lib/traceevent/plugin_function.c | 10 +++--- tools/lib/traceevent/plugin_hrtimer.c | 4 +-- tools/lib/traceevent/plugin_jbd2.c | 4 +-- tools/lib/traceevent/plugin_kmem.c | 4 +-- tools/lib/traceevent/plugin_kvm.c | 4 +-- tools/lib/traceevent/plugin_mac80211.c | 4 +-- tools/lib/traceevent/plugin_sched_switch.c | 4 +-- tools/lib/traceevent/plugin_scsi.c | 4 +-- tools/lib/traceevent/plugin_xen.c | 4 +-- 13 files changed, 67 insertions(+), 67 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 90f30f9dde14..57ed9348d1aa 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -88,7 +88,7 @@ struct event_handler { int id; const char *sys_name; const char *event_name; - pevent_event_handler_func func; + tep_event_handler_func func; void *context; }; @@ -6633,7 +6633,7 @@ static struct event_format *pevent_search_event(struct tep_handle *pevent, int i */ int pevent_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, - pevent_event_handler_func func, void *context) + tep_event_handler_func func, void *context) { struct event_format *event; struct event_handler *handle; @@ -6682,7 +6682,7 @@ int pevent_register_event_handler(struct tep_handle *pevent, int id, static int handle_matches(struct event_handler *handler, int id, const char *sys_name, const char *event_name, - pevent_event_handler_func func, void *context) + tep_event_handler_func func, void *context) { if (id >= 0 && id != handler->id) return 0; @@ -6717,7 +6717,7 @@ static int handle_matches(struct event_handler *handler, int id, */ int pevent_unregister_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, - pevent_event_handler_func func, void *context) + tep_event_handler_func func, void *context) { struct event_format *event; struct event_handler *handle; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index b1e4d37bedd8..b4b698c3833e 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -101,16 +101,16 @@ extern int trace_seq_do_printf(struct trace_seq *s); struct tep_handle; struct event_format; -typedef int (*pevent_event_handler_func)(struct trace_seq *s, - struct tep_record *record, - struct event_format *event, - void *context); +typedef int (*tep_event_handler_func)(struct trace_seq *s, + struct tep_record *record, + struct event_format *event, + void *context); -typedef int (*pevent_plugin_load_func)(struct tep_handle *pevent); -typedef int (*pevent_plugin_unload_func)(struct tep_handle *pevent); +typedef int (*tep_plugin_load_func)(struct tep_handle *pevent); +typedef int (*tep_plugin_unload_func)(struct tep_handle *pevent); -struct pevent_plugin_option { - struct pevent_plugin_option *next; +struct tep_plugin_option { + struct tep_plugin_option *next; void *handle; char *file; char *name; @@ -124,20 +124,20 @@ struct pevent_plugin_option { /* * Plugin hooks that can be called: * - * PEVENT_PLUGIN_LOADER: (required) + * TEP_PLUGIN_LOADER: (required) * The function name to initialized the plugin. * - * int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) + * int TEP_PLUGIN_LOADER(struct tep_handle *pevent) * - * PEVENT_PLUGIN_UNLOADER: (optional) + * TEP_PLUGIN_UNLOADER: (optional) * The function called just before unloading * - * int PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) + * int TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) * - * PEVENT_PLUGIN_OPTIONS: (optional) + * TEP_PLUGIN_OPTIONS: (optional) * Plugin options that can be set before loading * - * struct pevent_plugin_option PEVENT_PLUGIN_OPTIONS[] = { + * struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = { * { * .name = "option-name", * .plugin_alias = "override-file-name", (optional) @@ -158,19 +158,19 @@ struct pevent_plugin_option { * .set will be processed. If .value is defined, then it is considered * a string option and .set will be ignored. * - * PEVENT_PLUGIN_ALIAS: (optional) + * TEP_PLUGIN_ALIAS: (optional) * The name to use for finding options (uses filename if not defined) */ -#define PEVENT_PLUGIN_LOADER pevent_plugin_loader -#define PEVENT_PLUGIN_UNLOADER pevent_plugin_unloader -#define PEVENT_PLUGIN_OPTIONS pevent_plugin_options -#define PEVENT_PLUGIN_ALIAS pevent_plugin_alias +#define TEP_PLUGIN_LOADER tep_plugin_loader +#define TEP_PLUGIN_UNLOADER tep_plugin_unloader +#define TEP_PLUGIN_OPTIONS tep_plugin_options +#define TEP_PLUGIN_ALIAS tep_plugin_alias #define _MAKE_STR(x) #x #define MAKE_STR(x) _MAKE_STR(x) -#define PEVENT_PLUGIN_LOADER_NAME MAKE_STR(PEVENT_PLUGIN_LOADER) -#define PEVENT_PLUGIN_UNLOADER_NAME MAKE_STR(PEVENT_PLUGIN_UNLOADER) -#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS) -#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS) +#define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER) +#define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER) +#define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS) +#define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS) enum format_flags { FIELD_IS_ARRAY = 1, @@ -327,7 +327,7 @@ struct event_format { struct format format; struct print_fmt print_fmt; char *system; - pevent_event_handler_func handler; + tep_event_handler_func handler; void *context; }; @@ -441,8 +441,8 @@ void traceevent_unload_plugins(struct plugin_list *plugin_list, char **traceevent_plugin_list_options(void); void traceevent_plugin_free_options_list(char **list); int traceevent_plugin_add_options(const char *name, - struct pevent_plugin_option *options); -void traceevent_plugin_remove_options(struct pevent_plugin_option *options); + struct tep_plugin_option *options); +void traceevent_plugin_remove_options(struct tep_plugin_option *options); void traceevent_print_plugins(struct trace_seq *s, const char *prefix, const char *suffix, const struct plugin_list *list); @@ -675,10 +675,10 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, int pevent_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, - pevent_event_handler_func func, void *context); + tep_event_handler_func func, void *context); int pevent_unregister_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, - pevent_event_handler_func func, void *context); + tep_event_handler_func func, void *context); int pevent_register_print_function(struct tep_handle *pevent, pevent_func_handler func, enum pevent_func_arg_type ret_type, diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index 62b011ae18c1..8c91c8f0abd9 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -34,7 +34,7 @@ static struct registered_plugin_options { struct registered_plugin_options *next; - struct pevent_plugin_option *options; + struct tep_plugin_option *options; } *registered_options; static struct trace_plugin_options { @@ -58,7 +58,7 @@ static void lower_case(char *str) *str = tolower(*str); } -static int update_option_value(struct pevent_plugin_option *op, const char *val) +static int update_option_value(struct tep_plugin_option *op, const char *val) { char *op_val; @@ -111,7 +111,7 @@ static int update_option_value(struct pevent_plugin_option *op, const char *val) char **traceevent_plugin_list_options(void) { struct registered_plugin_options *reg; - struct pevent_plugin_option *op; + struct tep_plugin_option *op; char **list = NULL; char *name; int count = 0; @@ -163,7 +163,7 @@ void traceevent_plugin_free_options_list(char **list) } static int -update_option(const char *file, struct pevent_plugin_option *option) +update_option(const char *file, struct tep_plugin_option *option) { struct trace_plugin_options *op; char *plugin; @@ -222,7 +222,7 @@ update_option(const char *file, struct pevent_plugin_option *option) * Sets the options with the values that have been added by user. */ int traceevent_plugin_add_options(const char *name, - struct pevent_plugin_option *options) + struct tep_plugin_option *options) { struct registered_plugin_options *reg; @@ -244,7 +244,7 @@ int traceevent_plugin_add_options(const char *name, * traceevent_plugin_remove_options - remove plugin options that were registered * @options: Options to removed that were registered with traceevent_plugin_add_options */ -void traceevent_plugin_remove_options(struct pevent_plugin_option *options) +void traceevent_plugin_remove_options(struct tep_plugin_option *options) { struct registered_plugin_options **last; struct registered_plugin_options *reg; @@ -285,7 +285,7 @@ load_plugin(struct tep_handle *pevent, const char *path, const char *file, void *data) { struct plugin_list **plugin_list = data; - pevent_plugin_load_func func; + tep_plugin_load_func func; struct plugin_list *list; const char *alias; char *plugin; @@ -305,14 +305,14 @@ load_plugin(struct tep_handle *pevent, const char *path, goto out_free; } - alias = dlsym(handle, PEVENT_PLUGIN_ALIAS_NAME); + alias = dlsym(handle, TEP_PLUGIN_ALIAS_NAME); if (!alias) alias = file; - func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME); + func = dlsym(handle, TEP_PLUGIN_LOADER_NAME); if (!func) { warning("could not find func '%s' in plugin '%s'\n%s\n", - PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror()); + TEP_PLUGIN_LOADER_NAME, plugin, dlerror()); goto out_free; } @@ -442,13 +442,13 @@ traceevent_load_plugins(struct tep_handle *pevent) void traceevent_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent) { - pevent_plugin_unload_func func; + tep_plugin_unload_func func; struct plugin_list *list; while (plugin_list) { list = plugin_list; plugin_list = list->next; - func = dlsym(list->handle, PEVENT_PLUGIN_UNLOADER_NAME); + func = dlsym(list->handle, TEP_PLUGIN_UNLOADER_NAME); if (func) func(pevent); dlclose(list->handle); diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c index 959d94f1d7f5..c189bbc9fa18 100644 --- a/tools/lib/traceevent/plugin_cfg80211.c +++ b/tools/lib/traceevent/plugin_cfg80211.c @@ -25,7 +25,7 @@ process___le16_to_cpup(struct trace_seq *s, unsigned long long *args) return val ? (long long) le16toh(*val) : 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process___le16_to_cpup, @@ -36,7 +36,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process___le16_to_cpup, "__le16_to_cpup"); diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 86b5bb9bf22c..342be570ee8c 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c @@ -33,7 +33,7 @@ static int cpus = -1; #define STK_BLK 10 -struct pevent_plugin_option plugin_options[] = +struct tep_plugin_option plugin_options[] = { { .name = "parent", @@ -53,8 +53,8 @@ struct pevent_plugin_option plugin_options[] = } }; -static struct pevent_plugin_option *ftrace_parent = &plugin_options[0]; -static struct pevent_plugin_option *ftrace_indent = &plugin_options[1]; +static struct tep_plugin_option *ftrace_parent = &plugin_options[0]; +static struct tep_plugin_option *ftrace_indent = &plugin_options[1]; static void add_child(struct func_stack *stack, const char *child, int pos) { @@ -163,7 +163,7 @@ static int function_handler(struct trace_seq *s, struct tep_record *record, return 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "ftrace", "function", function_handler, NULL); @@ -173,7 +173,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { int i, x; diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c index 695e8e1b90e6..5704d56c6f6f 100644 --- a/tools/lib/traceevent/plugin_hrtimer.c +++ b/tools/lib/traceevent/plugin_hrtimer.c @@ -66,7 +66,7 @@ static int timer_start_handler(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "timer", "hrtimer_expire_entry", @@ -77,7 +77,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_expire_entry", diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c index 3909db7043c9..9b88aebb48a9 100644 --- a/tools/lib/traceevent/plugin_jbd2.c +++ b/tools/lib/traceevent/plugin_jbd2.c @@ -47,7 +47,7 @@ process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args) return jiffies; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_jbd2_dev_to_name, @@ -65,7 +65,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process_jbd2_dev_to_name, "jbd2_dev_to_name"); diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index 46e8e959539e..0a56562d0645 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c @@ -48,7 +48,7 @@ static int call_site_handler(struct trace_seq *s, struct tep_record *record, return 1; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "kmem", "kfree", call_site_handler, NULL); @@ -71,7 +71,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "kmem", "kfree", call_site_handler, NULL); diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 63420e3a340c..ab5439e0ad87 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -444,7 +444,7 @@ process_is_writable_pte(struct trace_seq *s, unsigned long long *args) return pte & PT_WRITABLE_MASK; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { init_disassembler(); @@ -486,7 +486,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit", kvm_exit_handler, NULL); diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index 83d002753251..61eea3543cf1 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -86,7 +86,7 @@ static int drv_bss_info_changed(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "mac80211", "drv_bss_info_changed", @@ -94,7 +94,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "mac80211", "drv_bss_info_changed", diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index b72a52d2fd1d..24dc2bca8e67 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c @@ -134,7 +134,7 @@ static int sched_switch_handler(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_event_handler(pevent, -1, "sched", "sched_switch", sched_switch_handler, NULL); @@ -147,7 +147,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch", sched_switch_handler, NULL); diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index e430a49e4995..bb9aea6fb000 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c @@ -413,7 +413,7 @@ unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_scsi_trace_parse_cdb, @@ -426,7 +426,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb, "scsi_trace_parse_cdb"); diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c index 11dbddde2e6a..1973dd8abbfd 100644 --- a/tools/lib/traceevent/plugin_xen.c +++ b/tools/lib/traceevent/plugin_xen.c @@ -119,7 +119,7 @@ unsigned long long process_xen_hypercall_name(struct trace_seq *s, return 0; } -int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) +int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_xen_hypercall_name, @@ -130,7 +130,7 @@ int PEVENT_PLUGIN_LOADER(struct tep_handle *pevent) return 0; } -void PEVENT_PLUGIN_UNLOADER(struct tep_handle *pevent) +void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent) { pevent_unregister_print_function(pevent, process_xen_hypercall_name, "xen_hypercall_name"); -- cgit v1.2.3 From 4d5c58b15c4363219e19380848eb74ca60143187 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:49 -0400 Subject: tools lib traceevent, perf tools: Rename pevent alloc / free APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_alloc, pevent_free, pevent_event_info and pevent_func_resolver_t Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.152609945@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 24 ++++++++++++------------ tools/lib/traceevent/event-parse.h | 12 ++++++------ tools/perf/builtin-kmem.c | 2 +- tools/perf/util/sort.c | 2 +- tools/perf/util/trace-event-parse.c | 2 +- tools/perf/util/trace-event.c | 6 +++--- tools/perf/util/trace-event.h | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 57ed9348d1aa..040180f6ed74 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -438,9 +438,9 @@ __find_func(struct tep_handle *pevent, unsigned long long addr) } struct func_resolver { - pevent_func_resolver_t *func; - void *priv; - struct func_map map; + tep_func_resolver_t *func; + void *priv; + struct func_map map; }; /** @@ -454,7 +454,7 @@ struct func_resolver { * pevent->funclist. */ int pevent_set_function_resolver(struct tep_handle *pevent, - pevent_func_resolver_t *func, void *priv) + tep_func_resolver_t *func, void *priv) { struct func_resolver *resolver = malloc(sizeof(*resolver)); @@ -5399,8 +5399,8 @@ int pevent_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) * This parses the raw @data using the given @event information and * writes the print format into the trace_seq. */ -void pevent_event_info(struct trace_seq *s, struct event_format *event, - struct tep_record *record) +void tep_event_info(struct trace_seq *s, struct event_format *event, + struct tep_record *record) { int print_pretty = 1; @@ -5556,7 +5556,7 @@ void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, if (len < 20) trace_seq_printf(s, "%.*s", 20 - len, spaces); - pevent_event_info(s, event, record); + tep_event_info(s, event, record); } void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, @@ -6754,9 +6754,9 @@ not_found: } /** - * pevent_alloc - create a pevent handle + * tep_alloc - create a pevent handle */ -struct tep_handle *pevent_alloc(void) +struct tep_handle *tep_alloc(void) { struct tep_handle *pevent = calloc(1, sizeof(*pevent)); @@ -6811,10 +6811,10 @@ void pevent_free_format(struct event_format *event) } /** - * pevent_free - free a pevent handle + * tep_free - free a pevent handle * @pevent: the pevent handle to free */ -void pevent_free(struct tep_handle *pevent) +void tep_free(struct tep_handle *pevent) { struct cmdline_list *cmdlist, *cmdnext; struct func_list *funclist, *funcnext; @@ -6901,5 +6901,5 @@ void pevent_free(struct tep_handle *pevent) void pevent_unref(struct tep_handle *pevent) { - pevent_free(pevent); + tep_free(pevent); } diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index b4b698c3833e..c229240666b7 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -454,8 +454,8 @@ struct func_list; struct event_handler; struct func_resolver; -typedef char *(pevent_func_resolver_t)(void *priv, - unsigned long long *addrp, char **modp); +typedef char *(tep_func_resolver_t)(void *priv, + unsigned long long *addrp, char **modp); struct tep_handle { int ref_count; @@ -616,7 +616,7 @@ enum trace_flag_type { }; int pevent_set_function_resolver(struct tep_handle *pevent, - pevent_func_resolver_t *func, void *priv); + tep_func_resolver_t *func, void *priv); void pevent_reset_function_resolver(struct tep_handle *pevent); int pevent_register_comm(struct tep_handle *pevent, const char *comm, int pid); int pevent_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); @@ -722,7 +722,7 @@ void pevent_print_field(struct trace_seq *s, void *data, struct format_field *field); void pevent_print_fields(struct trace_seq *s, void *data, int size __maybe_unused, struct event_format *event); -void pevent_event_info(struct trace_seq *s, struct event_format *event, +void tep_event_info(struct trace_seq *s, struct event_format *event, struct tep_record *record); int pevent_strerror(struct tep_handle *pevent, enum pevent_errno errnum, char *buf, size_t buflen); @@ -791,8 +791,8 @@ static inline void pevent_set_latency_format(struct tep_handle *pevent, int lat) pevent->latency_format = lat; } -struct tep_handle *pevent_alloc(void); -void pevent_free(struct tep_handle *pevent); +struct tep_handle *tep_alloc(void); +void tep_free(struct tep_handle *pevent); void pevent_ref(struct tep_handle *pevent); void pevent_unref(struct tep_handle *pevent); diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index b23e861fa6ae..73c073ade71c 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -747,7 +747,7 @@ static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample, } trace_seq_init(&seq); - pevent_event_info(&seq, evsel->tp_format, &record); + tep_event_info(&seq, evsel->tp_format, &record); str = strtok_r(seq.buffer, " ", &pos); while (str) { diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 2c9924ab872d..08cdaf2be1af 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -613,7 +613,7 @@ static char *get_trace_output(struct hist_entry *he) pevent_print_fields(&seq, he->raw_data, he->raw_size, evsel->tp_format); } else { - pevent_event_info(&seq, evsel->tp_format, &rec); + tep_event_info(&seq, evsel->tp_format, &rec); } /* * Trim the buffer, it starts at 4KB and we're not going to diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 29af1fb0b888..630d0e81fe87 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -125,7 +125,7 @@ void event_format__fprintf(struct event_format *event, record.data = data; trace_seq_init(&s); - pevent_event_info(&s, event, &record); + tep_event_info(&s, event, &record); trace_seq_do_fprintf(&s, fp); trace_seq_destroy(&s); } diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 7c0cd9a0f575..11066ed43ca4 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -28,7 +28,7 @@ static bool tevent_initialized; int trace_event__init(struct trace_event *t) { - struct tep_handle *pevent = pevent_alloc(); + struct tep_handle *pevent = tep_alloc(); if (pevent) { t->plugin_list = traceevent_load_plugins(pevent); @@ -55,7 +55,7 @@ static int trace_event__init2(void) } int trace_event__register_resolver(struct machine *machine, - pevent_func_resolver_t *func) + tep_func_resolver_t *func) { if (!tevent_initialized && trace_event__init2()) return -1; @@ -66,7 +66,7 @@ int trace_event__register_resolver(struct machine *machine, void trace_event__cleanup(struct trace_event *t) { traceevent_unload_plugins(t->plugin_list, t->pevent); - pevent_free(t->pevent); + tep_free(t->pevent); } /* diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index b8f2516e9a65..40204ec3a7a2 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -20,7 +20,7 @@ struct trace_event { int trace_event__init(struct trace_event *t); void trace_event__cleanup(struct trace_event *t); int trace_event__register_resolver(struct machine *machine, - pevent_func_resolver_t *func); + tep_func_resolver_t *func); struct event_format* trace_event__tp_format(const char *sys, const char *name); -- cgit v1.2.3 From af85cd19521fe956eeb2cc8b9e41b9b5bbb8e3ae Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:50 -0400 Subject: tools lib traceevent, perf tools: Rename pevent find APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_find_any_field, pevent_find_common_field, pevent_find_event, pevent_find_field Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.316995920@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 76 +++++++++++++++--------------- tools/lib/traceevent/event-parse.h | 8 ++-- tools/lib/traceevent/parse-filter.c | 4 +- tools/lib/traceevent/plugin_kmem.c | 2 +- tools/lib/traceevent/plugin_mac80211.c | 2 +- tools/lib/traceevent/plugin_sched_switch.c | 6 +-- tools/perf/util/evsel.c | 2 +- tools/perf/util/header.c | 2 +- tools/perf/util/python.c | 2 +- tools/perf/util/sort.c | 4 +- tools/perf/util/trace-event-parse.c | 4 +- tools/perf/util/trace-event.c | 2 +- 12 files changed, 57 insertions(+), 57 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 040180f6ed74..29f22e432084 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -2101,11 +2101,11 @@ process_entry(struct event_format *event __maybe_unused, struct print_arg *arg, arg->field.name = field; if (is_flag_field) { - arg->field.field = pevent_find_any_field(event, arg->field.name); + arg->field.field = tep_find_any_field(event, arg->field.name); arg->field.field->flags |= FIELD_IS_FLAG; is_flag_field = 0; } else if (is_symbolic_field) { - arg->field.field = pevent_find_any_field(event, arg->field.name); + arg->field.field = tep_find_any_field(event, arg->field.name); arg->field.field->flags |= FIELD_IS_SYMBOLIC; is_symbolic_field = 0; } @@ -2714,7 +2714,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** /* Find the field */ - field = pevent_find_field(event, token); + field = tep_find_field(event, token); if (!field) goto out_free; @@ -2771,7 +2771,7 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg, arg->type = PRINT_DYNAMIC_ARRAY_LEN; /* Find the field */ - field = pevent_find_field(event, token); + field = tep_find_field(event, token); if (!field) goto out_free; @@ -3265,7 +3265,7 @@ static int event_read_print(struct event_format *event) } /** - * pevent_find_common_field - return a common field by event + * tep_find_common_field - return a common field by event * @event: handle for the event * @name: the name of the common field to return * @@ -3273,7 +3273,7 @@ static int event_read_print(struct event_format *event) * This only searchs the common fields and not all field. */ struct format_field * -pevent_find_common_field(struct event_format *event, const char *name) +tep_find_common_field(struct event_format *event, const char *name) { struct format_field *format; @@ -3287,7 +3287,7 @@ pevent_find_common_field(struct event_format *event, const char *name) } /** - * pevent_find_field - find a non-common field + * tep_find_field - find a non-common field * @event: handle for the event * @name: the name of the non-common field * @@ -3295,7 +3295,7 @@ pevent_find_common_field(struct event_format *event, const char *name) * This does not search common fields. */ struct format_field * -pevent_find_field(struct event_format *event, const char *name) +tep_find_field(struct event_format *event, const char *name) { struct format_field *format; @@ -3309,7 +3309,7 @@ pevent_find_field(struct event_format *event, const char *name) } /** - * pevent_find_any_field - find any field by name + * tep_find_any_field - find any field by name * @event: handle for the event * @name: the name of the field * @@ -3318,14 +3318,14 @@ pevent_find_field(struct event_format *event, const char *name) * the non-common ones if a common one was not found. */ struct format_field * -pevent_find_any_field(struct event_format *event, const char *name) +tep_find_any_field(struct event_format *event, const char *name) { struct format_field *format; - format = pevent_find_common_field(event, name); + format = tep_find_common_field(event, name); if (format) return format; - return pevent_find_field(event, name); + return tep_find_field(event, name); } /** @@ -3400,7 +3400,7 @@ static int get_common_info(struct tep_handle *pevent, } event = pevent->events[0]; - field = pevent_find_common_field(event, type); + field = tep_find_common_field(event, type); if (!field) return -1; @@ -3468,13 +3468,13 @@ static int parse_common_migrate_disable(struct tep_handle *pevent, void *data) static int events_id_cmp(const void *a, const void *b); /** - * pevent_find_event - find an event by given id + * tep_find_event - find an event by given id * @pevent: a handle to the pevent * @id: the id of the event * * Returns an event that has a given @id. */ -struct event_format *pevent_find_event(struct tep_handle *pevent, int id) +struct event_format *tep_find_event(struct tep_handle *pevent, int id) { struct event_format **eventptr; struct event_format key; @@ -3553,7 +3553,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg return strtoull(arg->atom.atom, NULL, 0); case PRINT_FIELD: if (!arg->field.field) { - arg->field.field = pevent_find_any_field(event, arg->field.name); + arg->field.field = tep_find_any_field(event, arg->field.name); if (!arg->field.field) goto out_warning_field; @@ -3619,7 +3619,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg case PRINT_FIELD: if (!larg->field.field) { larg->field.field = - pevent_find_any_field(event, larg->field.name); + tep_find_any_field(event, larg->field.name); if (!larg->field.field) { arg = larg; goto out_warning_field; @@ -3899,7 +3899,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, case PRINT_FIELD: field = arg->field.field; if (!field) { - field = pevent_find_any_field(event, arg->field.name); + field = tep_find_any_field(event, arg->field.name); if (!field) { str = arg->field.name; goto out_warning_field; @@ -4000,7 +4000,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, field = arg->hex.field->field.field; if (!field) { str = arg->hex.field->field.name; - field = pevent_find_any_field(event, str); + field = tep_find_any_field(event, str); if (!field) goto out_warning_field; arg->hex.field->field.field = field; @@ -4031,7 +4031,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, field = arg->int_array.field->field.field; if (!field) { str = arg->int_array.field->field.name; - field = pevent_find_any_field(event, str); + field = tep_find_any_field(event, str); if (!field) goto out_warning_field; arg->int_array.field->field.field = field; @@ -4071,7 +4071,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, if (arg->string.offset == -1) { struct format_field *f; - f = pevent_find_any_field(event, arg->string.string); + f = tep_find_any_field(event, arg->string.string); arg->string.offset = f->offset; } str_offset = data2host4(pevent, data + arg->string.offset); @@ -4089,7 +4089,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, if (arg->bitmask.offset == -1) { struct format_field *f; - f = pevent_find_any_field(event, arg->bitmask.bitmask); + f = tep_find_any_field(event, arg->bitmask.bitmask); arg->bitmask.offset = f->offset; } bitmask_offset = data2host4(pevent, data + arg->bitmask.offset); @@ -4239,12 +4239,12 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc ip_field = pevent->bprint_ip_field; if (!field) { - field = pevent_find_field(event, "buf"); + field = tep_find_field(event, "buf"); if (!field) { do_warning_event(event, "can't find buffer field for binary printk"); return NULL; } - ip_field = pevent_find_field(event, "ip"); + ip_field = tep_find_field(event, "ip"); if (!ip_field) { do_warning_event(event, "can't find ip field for binary printk"); return NULL; @@ -4413,7 +4413,7 @@ get_bprint_format(void *data, int size __maybe_unused, field = pevent->bprint_fmt_field; if (!field) { - field = pevent_find_field(event, "fmt"); + field = tep_find_field(event, "fmt"); if (!field) { do_warning_event(event, "can't find format field for binary printk"); return NULL; @@ -4457,7 +4457,7 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size, fmt = "%.2x%.2x%.2x%.2x%.2x%.2x"; if (!arg->field.field) { arg->field.field = - pevent_find_any_field(event, arg->field.name); + tep_find_any_field(event, arg->field.name); if (!arg->field.field) { do_warning_event(event, "%s: field %s not found", __func__, arg->field.name); @@ -4607,7 +4607,7 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i, if (!arg->field.field) { arg->field.field = - pevent_find_any_field(event, arg->field.name); + tep_find_any_field(event, arg->field.name); if (!arg->field.field) { do_warning("%s: field %s not found", __func__, arg->field.name); @@ -4653,7 +4653,7 @@ static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i, if (!arg->field.field) { arg->field.field = - pevent_find_any_field(event, arg->field.name); + tep_find_any_field(event, arg->field.name); if (!arg->field.field) { do_warning("%s: field %s not found", __func__, arg->field.name); @@ -4711,7 +4711,7 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, if (!arg->field.field) { arg->field.field = - pevent_find_any_field(event, arg->field.name); + tep_find_any_field(event, arg->field.name); if (!arg->field.field) { do_warning("%s: field %s not found", __func__, arg->field.name); @@ -5243,7 +5243,7 @@ int pevent_data_type(struct tep_handle *pevent, struct tep_record *rec) */ struct event_format *pevent_data_event_from_type(struct tep_handle *pevent, int type) { - return pevent_find_event(pevent, type); + return tep_find_event(pevent, type); } /** @@ -5452,7 +5452,7 @@ pevent_find_event_by_record(struct tep_handle *pevent, struct tep_record *record type = trace_parse_common_type(pevent, record->data); - return pevent_find_event(pevent, type); + return tep_find_event(pevent, type); } /** @@ -6288,7 +6288,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, if (!event) return NULL; - field = pevent_find_field(event, name); + field = tep_find_field(event, name); if (!field) { if (err) @@ -6332,7 +6332,7 @@ int pevent_get_field_val(struct trace_seq *s, struct event_format *event, if (!event) return -1; - field = pevent_find_field(event, name); + field = tep_find_field(event, name); return get_field_val(s, field, name, record, val, err); } @@ -6357,7 +6357,7 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, if (!event) return -1; - field = pevent_find_common_field(event, name); + field = tep_find_common_field(event, name); return get_field_val(s, field, name, record, val, err); } @@ -6382,7 +6382,7 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, if (!event) return -1; - field = pevent_find_any_field(event, name); + field = tep_find_any_field(event, name); return get_field_val(s, field, name, record, val, err); } @@ -6402,7 +6402,7 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, struct tep_record *record, int err) { - struct format_field *field = pevent_find_field(event, name); + struct format_field *field = tep_find_field(event, name); unsigned long long val; if (!field) @@ -6434,7 +6434,7 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, struct tep_record *record, int err) { - struct format_field *field = pevent_find_field(event, name); + struct format_field *field = tep_find_field(event, name); struct tep_handle *pevent = event->pevent; unsigned long long val; struct func_map *func; @@ -6599,7 +6599,7 @@ static struct event_format *pevent_search_event(struct tep_handle *pevent, int i if (id >= 0) { /* search by id */ - event = pevent_find_event(pevent, id); + event = tep_find_event(pevent, id); if (!event) return NULL; if (event_name && (strcmp(event_name, event->name) != 0)) diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index c229240666b7..83c78290061e 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -686,9 +686,9 @@ int pevent_register_print_function(struct tep_handle *pevent, int pevent_unregister_print_function(struct tep_handle *pevent, pevent_func_handler func, char *name); -struct format_field *pevent_find_common_field(struct event_format *event, const char *name); -struct format_field *pevent_find_field(struct event_format *event, const char *name); -struct format_field *pevent_find_any_field(struct event_format *event, const char *name); +struct format_field *tep_find_common_field(struct event_format *event, const char *name); +struct format_field *tep_find_field(struct event_format *event, const char *name); +struct format_field *tep_find_any_field(struct event_format *event, const char *name); const char *pevent_find_function(struct tep_handle *pevent, unsigned long long addr); unsigned long long @@ -697,7 +697,7 @@ unsigned long long pevent_read_number(struct tep_handle *pevent, const void *ptr int pevent_read_number_field(struct format_field *field, const void *data, unsigned long long *value); -struct event_format *pevent_find_event(struct tep_handle *pevent, int id); +struct event_format *tep_find_event(struct tep_handle *pevent, int id); struct event_format * pevent_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name); diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 784ccac90999..7b6bab1ab0cd 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -167,7 +167,7 @@ add_filter_type(struct event_filter *filter, int id) filter_type = &filter->event_filters[i]; filter_type->event_id = id; - filter_type->event = pevent_find_event(filter->pevent, id); + filter_type->event = tep_find_event(filter->pevent, id); filter_type->filter = NULL; filter->filters++; @@ -382,7 +382,7 @@ create_arg_item(struct event_format *event, const char *token, break; } /* Consider this a field */ - field = pevent_find_any_field(event, token); + field = tep_find_any_field(event, token); if (!field) { /* If token is 'COMM' or 'CPU' then it is special */ if (strcmp(token, COMM) == 0) { diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index 0a56562d0645..a5f8641495f3 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c @@ -31,7 +31,7 @@ static int call_site_handler(struct trace_seq *s, struct tep_record *record, void *data = record->data; const char *func; - field = pevent_find_field(event, "call_site"); + field = tep_find_field(event, "call_site"); if (!field) return 1; diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index 61eea3543cf1..dd5c7fc0193f 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -28,7 +28,7 @@ static void print_string(struct trace_seq *s, struct event_format *event, const char *name, const void *data) { - struct format_field *f = pevent_find_field(event, name); + struct format_field *f = tep_find_field(event, name); int offset; int length; diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index 24dc2bca8e67..90d2ef293cf9 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c @@ -74,7 +74,7 @@ static int sched_wakeup_handler(struct trace_seq *s, if (pevent_get_field_val(s, event, "pid", record, &val, 1)) return trace_seq_putc(s, '!'); - field = pevent_find_any_field(event, "comm"); + field = tep_find_any_field(event, "comm"); if (field) { write_and_save_comm(field, record, s, val); trace_seq_putc(s, ':'); @@ -103,7 +103,7 @@ static int sched_switch_handler(struct trace_seq *s, if (pevent_get_field_val(s, event, "prev_pid", record, &val, 1)) return trace_seq_putc(s, '!'); - field = pevent_find_any_field(event, "prev_comm"); + field = tep_find_any_field(event, "prev_comm"); if (field) { write_and_save_comm(field, record, s, val); trace_seq_putc(s, ':'); @@ -121,7 +121,7 @@ static int sched_switch_handler(struct trace_seq *s, if (pevent_get_field_val(s, event, "next_pid", record, &val, 1)) return trace_seq_putc(s, '!'); - field = pevent_find_any_field(event, "next_comm"); + field = tep_find_any_field(event, "next_comm"); if (field) { write_and_save_comm(field, record, s, val); trace_seq_putc(s, ':'); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ddf84b941abf..c980bbff6353 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2683,7 +2683,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name) { - return pevent_find_field(evsel->tp_format, name); + return tep_find_field(evsel->tp_format, name); } void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index c669896de98a..3cadc252dd89 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3218,7 +3218,7 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, return -1; } - event = pevent_find_event(pevent, evsel->attr.config); + event = tep_find_event(pevent, evsel->attr.config); if (event == NULL) { pr_debug("cannot find event format for %d\n", (int)evsel->attr.config); return -1; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index fd72cce6599c..ff01cd53eddd 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -394,7 +394,7 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name) evsel->tp_format = tp_format; } - field = pevent_find_any_field(evsel->tp_format, str); + field = tep_find_any_field(evsel->tp_format, str); if (!field) return NULL; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 08cdaf2be1af..f27087d06f52 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2311,7 +2311,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist, if (evsel->attr.type != PERF_TYPE_TRACEPOINT) continue; - field = pevent_find_any_field(evsel->tp_format, field_name); + field = tep_find_any_field(evsel->tp_format, field_name); if (field == NULL) continue; @@ -2378,7 +2378,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok, if (!strcmp(field_name, "*")) { ret = add_evsel_fields(evsel, raw_trace, level); } else { - field = pevent_find_any_field(evsel->tp_format, field_name); + field = tep_find_any_field(evsel->tp_format, field_name); if (field == NULL) { pr_debug("Cannot find event field for %s.%s\n", event_name, field_name); diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 630d0e81fe87..0a769a340fc9 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -41,7 +41,7 @@ static int get_common_field(struct scripting_context *context, return 0; event = pevent->events[0]; - field = pevent_find_common_field(event, type); + field = tep_find_common_field(event, type); if (!field) return 0; *offset = field->offset; @@ -99,7 +99,7 @@ raw_field_value(struct event_format *event, const char *name, void *data) struct format_field *field; unsigned long long val; - field = pevent_find_any_field(event, name); + field = tep_find_any_field(event, name); if (!field) return 0ULL; diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 11066ed43ca4..116fffa788b9 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -116,5 +116,5 @@ struct event_format *trace_event__tp_format_id(int id) if (!tevent_initialized && trace_event__init2()) return ERR_PTR(-ENOMEM); - return pevent_find_event(tevent.pevent, id); + return tep_find_event(tevent.pevent, id); } -- cgit v1.2.3 From c60167c187f9255e698998887bfbbba6418861b5 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:51 -0400 Subject: tools lib traceevent, perf tools: Rename pevent parse APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_parse_event, pevent_parse_format, pevent_parse_header_page Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.469749700@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 22 +++++++++++----------- tools/lib/traceevent/event-parse.h | 18 +++++++++--------- tools/perf/util/trace-event-parse.c | 4 ++-- tools/perf/util/trace-event-read.c | 4 ++-- tools/perf/util/trace-event.c | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 29f22e432084..419e57f5bbf3 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5930,7 +5930,7 @@ static void parse_header_field(const char *field, } /** - * pevent_parse_header_page - parse the data stored in the header page + * tep_parse_header_page - parse the data stored in the header page * @pevent: the handle to the pevent * @buf: the buffer storing the header page format string * @size: the size of @buf @@ -5941,8 +5941,8 @@ static void parse_header_field(const char *field, * * /sys/kernel/debug/tracing/events/header_page */ -int pevent_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, - int long_size) +int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, + int long_size) { int ignore; @@ -6171,7 +6171,7 @@ event_add_failed: } /** - * pevent_parse_format - parse the event format + * tep_parse_format - parse the event format * @pevent: the handle to the pevent * @eventp: returned format * @buf: the buffer storing the event format string @@ -6185,16 +6185,16 @@ event_add_failed: * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno pevent_parse_format(struct tep_handle *pevent, - struct event_format **eventp, - const char *buf, - unsigned long size, const char *sys) +enum pevent_errno tep_parse_format(struct tep_handle *pevent, + struct event_format **eventp, + const char *buf, + unsigned long size, const char *sys) { return __pevent_parse_event(pevent, eventp, buf, size, sys); } /** - * pevent_parse_event - parse the event format + * tep_parse_event - parse the event format * @pevent: the handle to the pevent * @buf: the buffer storing the event format string * @size: the size of @buf @@ -6207,8 +6207,8 @@ enum pevent_errno pevent_parse_format(struct tep_handle *pevent, * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno pevent_parse_event(struct tep_handle *pevent, const char *buf, - unsigned long size, const char *sys) +enum pevent_errno tep_parse_event(struct tep_handle *pevent, const char *buf, + unsigned long size, const char *sys) { struct event_format *event = NULL; return __pevent_parse_event(pevent, &event, buf, size, sys); diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 83c78290061e..eae429a98f7a 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -639,15 +639,15 @@ void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, struct tep_record *record, bool use_trace_clock); -int pevent_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, - int long_size); - -enum pevent_errno pevent_parse_event(struct tep_handle *pevent, const char *buf, - unsigned long size, const char *sys); -enum pevent_errno pevent_parse_format(struct tep_handle *pevent, - struct event_format **eventp, - const char *buf, - unsigned long size, const char *sys); +int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, + int long_size); + +enum pevent_errno tep_parse_event(struct tep_handle *pevent, const char *buf, + unsigned long size, const char *sys); +enum pevent_errno tep_parse_format(struct tep_handle *pevent, + struct event_format **eventp, + const char *buf, + unsigned long size, const char *sys); void pevent_free_format(struct event_format *event); void pevent_free_format_field(struct format_field *field); diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 0a769a340fc9..f8b91f3813ca 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -180,13 +180,13 @@ void parse_saved_cmdline(struct tep_handle *pevent, int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size) { - return pevent_parse_event(pevent, buf, size, "ftrace"); + return tep_parse_event(pevent, buf, size, "ftrace"); } int parse_event_file(struct tep_handle *pevent, char *buf, unsigned long size, char *sys) { - return pevent_parse_event(pevent, buf, size, sys); + return tep_parse_event(pevent, buf, size, sys); } struct event_format *trace_find_next_event(struct tep_handle *pevent, diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index cbd4970415ef..a89a50dee8e7 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -235,8 +235,8 @@ static int read_header_files(struct tep_handle *pevent) return -1; } - if (!pevent_parse_header_page(pevent, header_page, size, - pevent_get_long_size(pevent))) { + if (!tep_parse_header_page(pevent, header_page, size, + pevent_get_long_size(pevent))) { /* * The commit field in the page is of type long, * use that instead, since it represents the kernel. diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 116fffa788b9..eed1c11c1915 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -93,7 +93,7 @@ tp_format(const char *sys, const char *name) if (err) return ERR_PTR(err); - pevent_parse_format(pevent, &event, data, size, sys); + tep_parse_format(pevent, &event, data, size, sys); free(data); return event; -- cgit v1.2.3 From 6a48dc298ee1a4d87403086002b25c6821a1abc5 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:52 -0400 Subject: tools lib traceevent, perf tools: Rename pevent print APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_print_field, pevent_print_fields, pevent_print_funcs, pevent_print_printk Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.654453763@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 74 +++++++++++++++++----------------- tools/lib/traceevent/event-parse.h | 44 ++++++++++---------- tools/lib/traceevent/plugin_hrtimer.c | 28 ++++++------- tools/lib/traceevent/plugin_kvm.c | 16 ++++---- tools/lib/traceevent/plugin_mac80211.c | 6 +-- tools/perf/util/sort.c | 6 +-- tools/perf/util/trace-event-read.c | 4 +- 7 files changed, 89 insertions(+), 89 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 419e57f5bbf3..2b717c2d65cc 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -589,12 +589,12 @@ out_free: } /** - * pevent_print_funcs - print out the stored functions + * tep_print_funcs - print out the stored functions * @pevent: handle for the pevent * * This prints out the stored functions. */ -void pevent_print_funcs(struct tep_handle *pevent) +void tep_print_funcs(struct tep_handle *pevent) { int i; @@ -732,12 +732,12 @@ out_free: } /** - * pevent_print_printk - print out the stored strings + * tep_print_printk - print out the stored strings * @pevent: handle for the pevent * * This prints the string formats that were stored. */ -void pevent_print_printk(struct tep_handle *pevent) +void tep_print_printk(struct tep_handle *pevent) { int i; @@ -4800,8 +4800,8 @@ static int is_printable_array(char *p, unsigned int len) return 1; } -void pevent_print_field(struct trace_seq *s, void *data, - struct format_field *field) +void tep_print_field(struct trace_seq *s, void *data, + struct format_field *field) { unsigned long long val; unsigned int offset, len, i; @@ -4865,15 +4865,15 @@ void pevent_print_field(struct trace_seq *s, void *data, } } -void pevent_print_fields(struct trace_seq *s, void *data, - int size __maybe_unused, struct event_format *event) +void tep_print_fields(struct trace_seq *s, void *data, + int size __maybe_unused, struct event_format *event) { struct format_field *field; field = event->format.fields; while (field) { trace_seq_printf(s, " %s=", field->name); - pevent_print_field(s, data, field); + tep_print_field(s, data, field); field = field->next; } } @@ -4899,7 +4899,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event if (event->flags & EVENT_FL_FAILED) { trace_seq_printf(s, "[FAILED TO PARSE]"); - pevent_print_fields(s, data, size, event); + tep_print_fields(s, data, size, event); return; } @@ -5405,7 +5405,7 @@ void tep_event_info(struct trace_seq *s, struct event_format *event, int print_pretty = 1; if (event->pevent->print_raw || (event->flags & EVENT_FL_PRINTRAW)) - pevent_print_fields(s, record->data, record->size, event); + tep_print_fields(s, record->data, record->size, event); else { if (event->handler && !(event->flags & EVENT_FL_NOHANDLE)) @@ -5456,7 +5456,7 @@ pevent_find_event_by_record(struct tep_handle *pevent, struct tep_record *record } /** - * pevent_print_event_task - Write the event task comm, pid and CPU + * tep_print_event_task - Write the event task comm, pid and CPU * @pevent: a handle to the pevent * @s: the trace_seq to write to * @event: the handle to the record's event @@ -5464,9 +5464,9 @@ pevent_find_event_by_record(struct tep_handle *pevent, struct tep_record *record * * Writes the tasks comm, pid and CPU to @s. */ -void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, - struct event_format *event, - struct tep_record *record) +void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, + struct event_format *event, + struct tep_record *record) { void *data = record->data; const char *comm; @@ -5483,7 +5483,7 @@ void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, } /** - * pevent_print_event_time - Write the event timestamp + * tep_print_event_time - Write the event timestamp * @pevent: a handle to the pevent * @s: the trace_seq to write to * @event: the handle to the record's event @@ -5492,10 +5492,10 @@ void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, * * Writes the timestamp of the record into @s. */ -void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, - struct event_format *event, - struct tep_record *record, - bool use_trace_clock) +void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, + struct event_format *event, + struct tep_record *record, + bool use_trace_clock) { unsigned long secs; unsigned long usecs; @@ -5534,7 +5534,7 @@ void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, } /** - * pevent_print_event_data - Write the event data section + * tep_print_event_data - Write the event data section * @pevent: a handle to the pevent * @s: the trace_seq to write to * @event: the handle to the record's event @@ -5542,9 +5542,9 @@ void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, * * Writes the parsing of the record's data to @s. */ -void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, - struct event_format *event, - struct tep_record *record) +void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, + struct event_format *event, + struct tep_record *record) { static const char *spaces = " "; /* 20 spaces */ int len; @@ -5559,8 +5559,8 @@ void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, tep_event_info(s, event, record); } -void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, - struct tep_record *record, bool use_trace_clock) +void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, + struct tep_record *record, bool use_trace_clock) { struct event_format *event; @@ -5577,9 +5577,9 @@ void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, return; } - pevent_print_event_task(pevent, s, event, record); - pevent_print_event_time(pevent, s, event, record, use_trace_clock); - pevent_print_event_data(pevent, s, event, record); + tep_print_event_task(pevent, s, event, record); + tep_print_event_time(pevent, s, event, record, use_trace_clock); + tep_print_event_data(pevent, s, event, record); } static int events_id_cmp(const void *a, const void *b) @@ -6388,7 +6388,7 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, } /** - * pevent_print_num_field - print a field and a format + * tep_print_num_field - print a field and a format * @s: The seq to print to * @fmt: The printf format to print the field with. * @event: the event that the field is for @@ -6398,9 +6398,9 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, * * Returns: 0 on success, -1 field not found, or 1 if buffer is full. */ -int pevent_print_num_field(struct trace_seq *s, const char *fmt, - struct event_format *event, const char *name, - struct tep_record *record, int err) +int tep_print_num_field(struct trace_seq *s, const char *fmt, + struct event_format *event, const char *name, + struct tep_record *record, int err) { struct format_field *field = tep_find_field(event, name); unsigned long long val; @@ -6420,7 +6420,7 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt, } /** - * pevent_print_func_field - print a field and a format for function pointers + * tep_print_func_field - print a field and a format for function pointers * @s: The seq to print to * @fmt: The printf format to print the field with. * @event: the event that the field is for @@ -6430,9 +6430,9 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt, * * Returns: 0 on success, -1 field not found, or 1 if buffer is full. */ -int pevent_print_func_field(struct trace_seq *s, const char *fmt, - struct event_format *event, const char *name, - struct tep_record *record, int err) +int tep_print_func_field(struct trace_seq *s, const char *fmt, + struct event_format *event, const char *name, + struct tep_record *record, int err) { struct format_field *field = tep_find_field(event, name); struct tep_handle *pevent = event->pevent; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index eae429a98f7a..fb7f2277bbec 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -626,18 +626,18 @@ int pevent_register_print_string(struct tep_handle *pevent, const char *fmt, unsigned long long addr); int pevent_pid_is_registered(struct tep_handle *pevent, int pid); -void pevent_print_event_task(struct tep_handle *pevent, struct trace_seq *s, - struct event_format *event, - struct tep_record *record); -void pevent_print_event_time(struct tep_handle *pevent, struct trace_seq *s, - struct event_format *event, - struct tep_record *record, - bool use_trace_clock); -void pevent_print_event_data(struct tep_handle *pevent, struct trace_seq *s, - struct event_format *event, - struct tep_record *record); -void pevent_print_event(struct tep_handle *pevent, struct trace_seq *s, - struct tep_record *record, bool use_trace_clock); +void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, + struct event_format *event, + struct tep_record *record); +void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, + struct event_format *event, + struct tep_record *record, + bool use_trace_clock); +void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, + struct event_format *event, + struct tep_record *record); +void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, + struct tep_record *record, bool use_trace_clock); int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, int long_size); @@ -665,13 +665,13 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, const char *name, struct tep_record *record, unsigned long long *val, int err); -int pevent_print_num_field(struct trace_seq *s, const char *fmt, +int tep_print_num_field(struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, struct tep_record *record, int err); -int pevent_print_func_field(struct trace_seq *s, const char *fmt, - struct event_format *event, const char *name, - struct tep_record *record, int err); +int tep_print_func_field(struct trace_seq *s, const char *fmt, + struct event_format *event, const char *name, + struct tep_record *record, int err); int pevent_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, @@ -718,10 +718,10 @@ struct cmdline *pevent_data_pid_from_comm(struct tep_handle *pevent, const char struct cmdline *next); int pevent_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); -void pevent_print_field(struct trace_seq *s, void *data, - struct format_field *field); -void pevent_print_fields(struct trace_seq *s, void *data, - int size __maybe_unused, struct event_format *event); +void tep_print_field(struct trace_seq *s, void *data, + struct format_field *field); +void tep_print_fields(struct trace_seq *s, void *data, + int size __maybe_unused, struct event_format *event); void tep_event_info(struct trace_seq *s, struct event_format *event, struct tep_record *record); int pevent_strerror(struct tep_handle *pevent, enum pevent_errno errnum, @@ -805,8 +805,8 @@ const char *pevent_get_input_buf(void); unsigned long long pevent_get_input_buf_ptr(void); /* for debugging */ -void pevent_print_funcs(struct tep_handle *pevent); -void pevent_print_printk(struct tep_handle *pevent); +void tep_print_funcs(struct tep_handle *pevent); +void tep_print_printk(struct tep_handle *pevent); /* ----------------------- filtering ----------------------- */ diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c index 5704d56c6f6f..a37180eef959 100644 --- a/tools/lib/traceevent/plugin_hrtimer.c +++ b/tools/lib/traceevent/plugin_hrtimer.c @@ -30,16 +30,16 @@ static int timer_expire_handler(struct trace_seq *s, { trace_seq_printf(s, "hrtimer="); - if (pevent_print_num_field(s, "0x%llx", event, "timer", - record, 0) == -1) - pevent_print_num_field(s, "0x%llx", event, "hrtimer", - record, 1); + if (tep_print_num_field(s, "0x%llx", event, "timer", + record, 0) == -1) + tep_print_num_field(s, "0x%llx", event, "hrtimer", + record, 1); trace_seq_printf(s, " now="); - pevent_print_num_field(s, "%llu", event, "now", record, 1); + tep_print_num_field(s, "%llu", event, "now", record, 1); - pevent_print_func_field(s, " function=%s", event, "function", + tep_print_func_field(s, " function=%s", event, "function", record, 0); return 0; } @@ -50,19 +50,19 @@ static int timer_start_handler(struct trace_seq *s, { trace_seq_printf(s, "hrtimer="); - if (pevent_print_num_field(s, "0x%llx", event, "timer", - record, 0) == -1) - pevent_print_num_field(s, "0x%llx", event, "hrtimer", - record, 1); + if (tep_print_num_field(s, "0x%llx", event, "timer", + record, 0) == -1) + tep_print_num_field(s, "0x%llx", event, "hrtimer", + record, 1); - pevent_print_func_field(s, " function=%s", event, "function", - record, 0); + tep_print_func_field(s, " function=%s", event, "function", + record, 0); trace_seq_printf(s, " expires="); - pevent_print_num_field(s, "%llu", event, "expires", record, 1); + tep_print_num_field(s, "%llu", event, "expires", record, 1); trace_seq_printf(s, " softexpires="); - pevent_print_num_field(s, "%llu", event, "softexpires", record, 1); + tep_print_num_field(s, "%llu", event, "softexpires", record, 1); return 0; } diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index ab5439e0ad87..d71bc3fde75b 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -276,7 +276,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record, if (print_exit_reason(s, record, event, "exit_reason") < 0) return -1; - pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1); + tep_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1); if (pevent_get_field_val(s, event, "info1", record, &info1, 0) >= 0 && pevent_get_field_val(s, event, "info2", record, &info2, 0) >= 0) @@ -336,10 +336,10 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_reco if (print_exit_reason(s, record, event, "exit_code") < 0) return -1; - pevent_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1); - pevent_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1); - pevent_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1); - pevent_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1); + tep_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1); + tep_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1); + tep_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1); + tep_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1); return 0; } @@ -347,7 +347,7 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_reco static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) { - pevent_print_num_field(s, "rip %llx ", event, "rip", record, 1); + tep_print_num_field(s, "rip %llx ", event, "rip", record, 1); return kvm_nested_vmexit_inject_handler(s, record, event, context); } @@ -406,8 +406,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, } else trace_seq_printf(s, "WORD: %08x", role.word); - pevent_print_num_field(s, " root %u ", event, - "root_count", record, 1); + tep_print_num_field(s, " root %u ", event, + "root_count", record, 1); if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0) return -1; diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index dd5c7fc0193f..611250300855 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -53,8 +53,8 @@ static void print_string(struct trace_seq *s, struct event_format *event, trace_seq_printf(s, "%.*s", length, (char *)data + offset); } -#define SF(fn) pevent_print_num_field(s, fn ":%d", event, fn, record, 0) -#define SFX(fn) pevent_print_num_field(s, fn ":%#x", event, fn, record, 0) +#define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0) +#define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0) #define SP() trace_seq_putc(s, ' ') static int drv_bss_info_changed(struct trace_seq *s, @@ -66,7 +66,7 @@ static int drv_bss_info_changed(struct trace_seq *s, print_string(s, event, "wiphy_name", data); trace_seq_printf(s, " vif:"); print_string(s, event, "vif_name", data); - pevent_print_num_field(s, "(%d)", event, "vif_type", record, 1); + tep_print_num_field(s, "(%d)", event, "vif_type", record, 1); trace_seq_printf(s, "\n%*s", INDENT, ""); SF("assoc"); SP(); diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index f27087d06f52..93bc9b1860af 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -610,8 +610,8 @@ static char *get_trace_output(struct hist_entry *he) trace_seq_init(&seq); if (symbol_conf.raw_trace) { - pevent_print_fields(&seq, he->raw_data, he->raw_size, - evsel->tp_format); + tep_print_fields(&seq, he->raw_data, he->raw_size, + evsel->tp_format); } else { tep_event_info(&seq, evsel->tp_format, &rec); } @@ -2047,7 +2047,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct trace_seq seq; raw_field: trace_seq_init(&seq); - pevent_print_field(&seq, he->raw_data, hde->field); + tep_print_field(&seq, he->raw_data, hde->field); str = seq.buffer; } diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index a89a50dee8e7..850f7bf0eced 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -479,9 +479,9 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) repipe = false; if (show_funcs) { - pevent_print_funcs(pevent); + tep_print_funcs(pevent); } else if (show_printk) { - pevent_print_printk(pevent); + tep_print_printk(pevent); } pevent = NULL; -- cgit v1.2.3 From 59c1baee25e2b34f8e26a923ea229b3e00cab55a Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:53 -0400 Subject: tools lib traceevent, perf tools: Rename pevent_read_number_* APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_read_number, pevent_read_number_field Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.804271434@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 68 +++++++++++----------- tools/lib/traceevent/event-parse.h | 6 +- tools/lib/traceevent/parse-filter.c | 2 +- tools/lib/traceevent/plugin_kmem.c | 2 +- tools/lib/traceevent/plugin_mac80211.c | 2 +- tools/perf/util/data-convert-bt.c | 6 +- tools/perf/util/python.c | 6 +- .../util/scripting-engines/trace-event-python.c | 4 +- tools/perf/util/sort.c | 2 +- tools/perf/util/trace-event-parse.c | 6 +- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 2b717c2d65cc..4220b15781c8 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -3329,7 +3329,7 @@ tep_find_any_field(struct event_format *event, const char *name) } /** - * pevent_read_number - read a number from data + * tep_read_number - read a number from data * @pevent: handle for the pevent * @ptr: the raw data * @size: the size of the data that holds the number @@ -3337,8 +3337,8 @@ tep_find_any_field(struct event_format *event, const char *name) * Returns the number (converted to host) from the * raw data. */ -unsigned long long pevent_read_number(struct tep_handle *pevent, - const void *ptr, int size) +unsigned long long tep_read_number(struct tep_handle *pevent, + const void *ptr, int size) { switch (size) { case 1: @@ -3356,7 +3356,7 @@ unsigned long long pevent_read_number(struct tep_handle *pevent, } /** - * pevent_read_number_field - read a number from data + * tep_read_number_field - read a number from data * @field: a handle to the field * @data: the raw data to read * @value: the value to place the number in @@ -3366,8 +3366,8 @@ unsigned long long pevent_read_number(struct tep_handle *pevent, * * Returns 0 on success, -1 otherwise. */ -int pevent_read_number_field(struct format_field *field, const void *data, - unsigned long long *value) +int tep_read_number_field(struct format_field *field, const void *data, + unsigned long long *value) { if (!field) return -1; @@ -3376,8 +3376,8 @@ int pevent_read_number_field(struct format_field *field, const void *data, case 2: case 4: case 8: - *value = pevent_read_number(field->event->pevent, - data + field->offset, field->size); + *value = tep_read_number(field->event->pevent, + data + field->offset, field->size); return 0; default: return -1; @@ -3420,7 +3420,7 @@ static int __parse_common(struct tep_handle *pevent, void *data, if (ret < 0) return ret; } - return pevent_read_number(pevent, data + *offset, *size); + return tep_read_number(pevent, data + *offset, *size); } static int trace_parse_common_type(struct tep_handle *pevent, void *data) @@ -3559,8 +3559,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg } /* must be a number */ - val = pevent_read_number(pevent, data + arg->field.field->offset, - arg->field.field->size); + val = tep_read_number(pevent, data + arg->field.field->offset, + arg->field.field->size); break; case PRINT_FLAGS: case PRINT_SYMBOL: @@ -3603,7 +3603,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg switch (larg->type) { case PRINT_DYNAMIC_ARRAY: - offset = pevent_read_number(pevent, + offset = tep_read_number(pevent, data + larg->dynarray.field->offset, larg->dynarray.field->size); if (larg->dynarray.field->elementsize) @@ -3632,8 +3632,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg default: goto default_op; /* oops, all bets off */ } - val = pevent_read_number(pevent, - data + offset, field_size); + val = tep_read_number(pevent, + data + offset, field_size); if (typearg) val = eval_type(val, typearg, 1); break; @@ -3733,9 +3733,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg } break; case PRINT_DYNAMIC_ARRAY_LEN: - offset = pevent_read_number(pevent, - data + arg->dynarray.field->offset, - arg->dynarray.field->size); + offset = tep_read_number(pevent, + data + arg->dynarray.field->offset, + arg->dynarray.field->size); /* * The total allocated length of the dynamic array is * stored in the top half of the field, and the offset @@ -3745,9 +3745,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg break; case PRINT_DYNAMIC_ARRAY: /* Without [], we pass the address to the dynamic data */ - offset = pevent_read_number(pevent, - data + arg->dynarray.field->offset, - arg->dynarray.field->size); + offset = tep_read_number(pevent, + data + arg->dynarray.field->offset, + arg->dynarray.field->size); /* * The total allocated length of the dynamic array is * stored in the top half of the field, and the offset @@ -3992,7 +3992,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, case PRINT_HEX_STR: if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { unsigned long offset; - offset = pevent_read_number(pevent, + offset = tep_read_number(pevent, data + arg->hex.field->dynarray.field->offset, arg->hex.field->dynarray.field->size); hex = data + (offset & 0xffff); @@ -4023,9 +4023,9 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, unsigned long offset; struct format_field *field = arg->int_array.field->dynarray.field; - offset = pevent_read_number(pevent, - data + field->offset, - field->size); + offset = tep_read_number(pevent, + data + field->offset, + field->size); num = data + (offset & 0xffff); } else { field = arg->int_array.field->field.field; @@ -4253,7 +4253,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc pevent->bprint_ip_field = ip_field; } - ip = pevent_read_number(pevent, data + ip_field->offset, ip_field->size); + ip = tep_read_number(pevent, data + ip_field->offset, ip_field->size); /* * The first arg is the IP pointer. @@ -4347,7 +4347,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc /* the pointers are always 4 bytes aligned */ bptr = (void *)(((unsigned long)bptr + 3) & ~3); - val = pevent_read_number(pevent, bptr, vsize); + val = tep_read_number(pevent, bptr, vsize); bptr += vsize; arg = alloc_arg(); if (!arg) { @@ -4421,7 +4421,7 @@ get_bprint_format(void *data, int size __maybe_unused, pevent->bprint_fmt_field = field; } - addr = pevent_read_number(pevent, data + field->offset, field->size); + addr = tep_read_number(pevent, data + field->offset, field->size); printk = find_printk(pevent, addr); if (!printk) { @@ -4811,7 +4811,7 @@ void tep_print_field(struct trace_seq *s, void *data, offset = field->offset; len = field->size; if (field->flags & FIELD_IS_DYNAMIC) { - val = pevent_read_number(pevent, data + offset, len); + val = tep_read_number(pevent, data + offset, len); offset = val; len = offset >> 16; offset &= 0xffff; @@ -4831,8 +4831,8 @@ void tep_print_field(struct trace_seq *s, void *data, field->flags &= ~FIELD_IS_STRING; } } else { - val = pevent_read_number(pevent, data + field->offset, - field->size); + val = tep_read_number(pevent, data + field->offset, + field->size); if (field->flags & FIELD_IS_POINTER) { trace_seq_printf(s, "0x%llx", val); } else if (field->flags & FIELD_IS_SIGNED) { @@ -6253,7 +6253,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field, return -1; } - if (pevent_read_number_field(field, record->data, val)) { + if (tep_read_number_field(field, record->data, val)) { if (err) trace_seq_printf(s, " %s=INVALID", name); return -1; @@ -6302,7 +6302,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, offset = field->offset; if (field->flags & FIELD_IS_DYNAMIC) { - offset = pevent_read_number(event->pevent, + offset = tep_read_number(event->pevent, data + offset, field->size); *len = offset >> 16; offset &= 0xffff; @@ -6408,7 +6408,7 @@ int tep_print_num_field(struct trace_seq *s, const char *fmt, if (!field) goto failed; - if (pevent_read_number_field(field, record->data, &val)) + if (tep_read_number_field(field, record->data, &val)) goto failed; return trace_seq_printf(s, fmt, val); @@ -6443,7 +6443,7 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt, if (!field) goto failed; - if (pevent_read_number_field(field, record->data, &val)) + if (tep_read_number_field(field, record->data, &val)) goto failed; func = find_func(pevent, val); diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index fb7f2277bbec..58d9f0dedf05 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -693,9 +693,9 @@ struct format_field *tep_find_any_field(struct event_format *event, const char * const char *pevent_find_function(struct tep_handle *pevent, unsigned long long addr); unsigned long long pevent_find_function_address(struct tep_handle *pevent, unsigned long long addr); -unsigned long long pevent_read_number(struct tep_handle *pevent, const void *ptr, int size); -int pevent_read_number_field(struct format_field *field, const void *data, - unsigned long long *value); +unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size); +int tep_read_number_field(struct format_field *field, const void *data, + unsigned long long *value); struct event_format *tep_find_event(struct tep_handle *pevent, int id); diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 7b6bab1ab0cd..732c9e7d8aaf 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -1728,7 +1728,7 @@ get_value(struct event_format *event, if (field == &cpu) return record->cpu; - pevent_read_number_field(field, record->data, &val); + tep_read_number_field(field, record->data, &val); if (!(field->flags & FIELD_IS_SIGNED)) return val; diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index a5f8641495f3..28cabe250daf 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c @@ -35,7 +35,7 @@ static int call_site_handler(struct trace_seq *s, struct tep_record *record, if (!field) return 1; - if (pevent_read_number_field(field, data, &val)) + if (tep_read_number_field(field, data, &val)) return 1; func = pevent_find_function(event->pevent, val); diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index 611250300855..5197f940d153 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -42,7 +42,7 @@ static void print_string(struct trace_seq *s, struct event_format *event, if (!strncmp(f->type, "__data_loc", 10)) { unsigned long long v; - if (pevent_read_number_field(f, data, &v)) { + if (tep_read_number_field(f, data, &v)) { trace_seq_printf(s, "invalid_data_loc"); return; } diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 5744c12641a5..abd38abf1d91 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -310,8 +310,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, if (flags & FIELD_IS_DYNAMIC) { unsigned long long tmp_val; - tmp_val = pevent_read_number(fmtf->event->pevent, - data + offset, len); + tmp_val = tep_read_number(fmtf->event->pevent, + data + offset, len); offset = tmp_val; len = offset >> 16; offset &= 0xffff; @@ -353,7 +353,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, else { unsigned long long value_int; - value_int = pevent_read_number( + value_int = tep_read_number( fmtf->event->pevent, data + offset + i * len, len); diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index ff01cd53eddd..f74fbb652a4f 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -351,7 +351,7 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) offset = field->offset; len = field->size; if (field->flags & FIELD_IS_DYNAMIC) { - val = pevent_read_number(pevent, data + offset, len); + val = tep_read_number(pevent, data + offset, len); offset = val; len = offset >> 16; offset &= 0xffff; @@ -364,8 +364,8 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) field->flags &= ~FIELD_IS_STRING; } } else { - val = pevent_read_number(pevent, data + field->offset, - field->size); + val = tep_read_number(pevent, data + field->offset, + field->size); if (field->flags & FIELD_IS_POINTER) ret = PyLong_FromUnsignedLong((unsigned long) val); else if (field->flags & FIELD_IS_SIGNED) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 77bddd50e705..dfc6093f118c 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -871,8 +871,8 @@ static void python_process_tracepoint(struct perf_sample *sample, offset = field->offset; len = field->size; if (field->flags & FIELD_IS_DYNAMIC) { - val = pevent_read_number(scripting_context->pevent, - data + offset, len); + val = tep_read_number(scripting_context->pevent, + data + offset, len); offset = val; len = offset >> 16; offset &= 0xffff; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 93bc9b1860af..b284276ec963 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2074,7 +2074,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, if (field->flags & FIELD_IS_DYNAMIC) { unsigned long long dyn; - pevent_read_number_field(field, a->raw_data, &dyn); + tep_read_number_field(field, a->raw_data, &dyn); offset = dyn & 0xffff; size = (dyn >> 16) & 0xffff; diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index f8b91f3813ca..a0e2b2c54567 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -48,7 +48,7 @@ static int get_common_field(struct scripting_context *context, *size = field->size; } - return pevent_read_number(pevent, context->event_data + *offset, *size); + return tep_read_number(pevent, context->event_data + *offset, *size); } int common_lock_depth(struct scripting_context *context) @@ -103,14 +103,14 @@ raw_field_value(struct event_format *event, const char *name, void *data) if (!field) return 0ULL; - pevent_read_number_field(field, data, &val); + tep_read_number_field(field, data, &val); return val; } unsigned long long read_size(struct event_format *event, void *ptr, int size) { - return pevent_read_number(event->pevent, ptr, size); + return tep_read_number(event->pevent, ptr, size); } void event_format__fprintf(struct event_format *event, -- cgit v1.2.3 From 13a418904ee19e7a9892619cc93b025b31d08134 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:54 -0400 Subject: tools lib traceevent, perf tools: Rename pevent_register_* APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_register_comm, pevent_register_print_string Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180700.948980691@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 10 +++++----- tools/lib/traceevent/event-parse.h | 6 +++--- tools/lib/traceevent/plugin_sched_switch.c | 2 +- tools/perf/util/trace-event-parse.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 4220b15781c8..cab411b99087 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -288,7 +288,7 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) } /** - * pevent_register_comm - register a pid / comm mapping + * tep_register_comm - register a pid / comm mapping * @pevent: handle for the pevent * @comm: the command line to register * @pid: the pid to map the command line to @@ -296,7 +296,7 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) * This adds a mapping to search for command line names with * a given pid. The comm is duplicated. */ -int pevent_register_comm(struct tep_handle *pevent, const char *comm, int pid) +int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid) { struct cmdline_list *item; @@ -685,7 +685,7 @@ find_printk(struct tep_handle *pevent, unsigned long long addr) } /** - * pevent_register_print_string - register a string by its address + * tep_register_print_string - register a string by its address * @pevent: handle for the pevent * @fmt: the string format to register * @addr: the address the string was located at @@ -693,8 +693,8 @@ find_printk(struct tep_handle *pevent, unsigned long long addr) * This registers a string by the address it was stored in the kernel. * The @fmt passed in is duplicated. */ -int pevent_register_print_string(struct tep_handle *pevent, const char *fmt, - unsigned long long addr) +int tep_register_print_string(struct tep_handle *pevent, const char *fmt, + unsigned long long addr) { struct printk_list *item = malloc(sizeof(*item)); char *p; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 58d9f0dedf05..399dea66b80e 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -618,12 +618,12 @@ enum trace_flag_type { int pevent_set_function_resolver(struct tep_handle *pevent, tep_func_resolver_t *func, void *priv); void pevent_reset_function_resolver(struct tep_handle *pevent); -int pevent_register_comm(struct tep_handle *pevent, const char *comm, int pid); +int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid); int pevent_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); int pevent_register_function(struct tep_handle *pevent, char *name, unsigned long long addr, char *mod); -int pevent_register_print_string(struct tep_handle *pevent, const char *fmt, - unsigned long long addr); +int tep_register_print_string(struct tep_handle *pevent, const char *fmt, + unsigned long long addr); int pevent_pid_is_registered(struct tep_handle *pevent, int pid); void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index 90d2ef293cf9..4d8eaab6ac15 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c @@ -61,7 +61,7 @@ static void write_and_save_comm(struct format_field *field, comm = &s->buffer[len]; /* Help out the comm to ids. This will handle dups */ - pevent_register_comm(field->event->pevent, comm, pid); + tep_register_comm(field->event->pevent, comm, pid); } static int sched_wakeup_handler(struct trace_seq *s, diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index a0e2b2c54567..920b1d58a068 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -157,7 +157,7 @@ void parse_ftrace_printk(struct tep_handle *pevent, /* fmt still has a space, skip it */ printk = strdup(fmt+1); line = strtok_r(NULL, "\n", &next); - pevent_register_print_string(pevent, printk, addr); + tep_register_print_string(pevent, printk, addr); } } @@ -172,7 +172,7 @@ void parse_saved_cmdline(struct tep_handle *pevent, line = strtok_r(file, "\n", &next); while (line) { sscanf(line, "%d %ms", &pid, &comm); - pevent_register_comm(pevent, comm, pid); + tep_register_comm(pevent, comm, pid); free(comm); line = strtok_r(NULL, "\n", &next); } -- cgit v1.2.3 From ece2a4f48386acf7e35a751008976c9dda8d6232 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:55 -0400 Subject: tools lib traceevent, perf tools: Rename pevent_set_* APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_set_file_bigendian, pevent_set_flag, pevent_set_function_resolver, pevent_set_host_bigendian, pevent_set_long_size, pevent_set_page_size and pevent_get_long_size Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180701.256265951@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 6 +++--- tools/lib/traceevent/event-parse.h | 16 ++++++++-------- tools/perf/builtin-report.c | 6 +++--- tools/perf/builtin-script.c | 6 +++--- tools/perf/util/machine.h | 2 +- tools/perf/util/trace-event-read.c | 14 +++++++------- tools/perf/util/trace-event.c | 8 ++++---- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index cab411b99087..2667c18db27c 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -444,7 +444,7 @@ struct func_resolver { }; /** - * pevent_set_function_resolver - set an alternative function resolver + * tep_set_function_resolver - set an alternative function resolver * @pevent: handle for the pevent * @resolver: function to be used * @priv: resolver function private state. @@ -453,8 +453,8 @@ struct func_resolver { * keep using it instead of duplicating all the entries inside * pevent->funclist. */ -int pevent_set_function_resolver(struct tep_handle *pevent, - tep_func_resolver_t *func, void *priv) +int tep_set_function_resolver(struct tep_handle *pevent, + tep_func_resolver_t *func, void *priv) { struct func_resolver *resolver = malloc(sizeof(*resolver)); diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 399dea66b80e..a68591c8dec3 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -532,7 +532,7 @@ struct tep_handle { char *trace_clock; }; -static inline void pevent_set_flag(struct tep_handle *pevent, int flag) +static inline void tep_set_flag(struct tep_handle *pevent, int flag) { pevent->flags |= flag; } @@ -615,8 +615,8 @@ enum trace_flag_type { TRACE_FLAG_SOFTIRQ = 0x10, }; -int pevent_set_function_resolver(struct tep_handle *pevent, - tep_func_resolver_t *func, void *priv); +int tep_set_function_resolver(struct tep_handle *pevent, + tep_func_resolver_t *func, void *priv); void pevent_reset_function_resolver(struct tep_handle *pevent); int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid); int pevent_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); @@ -741,12 +741,12 @@ static inline void pevent_set_cpus(struct tep_handle *pevent, int cpus) pevent->cpus = cpus; } -static inline int pevent_get_long_size(struct tep_handle *pevent) +static inline int tep_get_long_size(struct tep_handle *pevent) { return pevent->long_size; } -static inline void pevent_set_long_size(struct tep_handle *pevent, int long_size) +static inline void tep_set_long_size(struct tep_handle *pevent, int long_size) { pevent->long_size = long_size; } @@ -756,7 +756,7 @@ static inline int pevent_get_page_size(struct tep_handle *pevent) return pevent->page_size; } -static inline void pevent_set_page_size(struct tep_handle *pevent, int _page_size) +static inline void tep_set_page_size(struct tep_handle *pevent, int _page_size) { pevent->page_size = _page_size; } @@ -766,7 +766,7 @@ static inline int pevent_is_file_bigendian(struct tep_handle *pevent) return pevent->file_bigendian; } -static inline void pevent_set_file_bigendian(struct tep_handle *pevent, int endian) +static inline void tep_set_file_bigendian(struct tep_handle *pevent, int endian) { pevent->file_bigendian = endian; } @@ -776,7 +776,7 @@ static inline int pevent_is_host_bigendian(struct tep_handle *pevent) return pevent->host_bigendian; } -static inline void pevent_set_host_bigendian(struct tep_handle *pevent, int endian) +static inline void tep_set_host_bigendian(struct tep_handle *pevent, int endian) { pevent->host_bigendian = endian; } diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 143542ffac20..76e12bcd1765 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1369,9 +1369,9 @@ repeat: } if (session->tevent.pevent && - pevent_set_function_resolver(session->tevent.pevent, - machine__resolve_kernel_addr, - &session->machines.host) < 0) { + tep_set_function_resolver(session->tevent.pevent, + machine__resolve_kernel_addr, + &session->machines.host) < 0) { pr_err("%s: failed to set libtraceevent function resolver\n", __func__); return -1; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 568ddfac3213..ba481d73f910 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3429,9 +3429,9 @@ int cmd_script(int argc, const char **argv) symbol_conf.use_callchain = false; if (session->tevent.pevent && - pevent_set_function_resolver(session->tevent.pevent, - machine__resolve_kernel_addr, - &session->machines.host) < 0) { + tep_set_function_resolver(session->tevent.pevent, + machine__resolve_kernel_addr, + &session->machines.host) < 0) { pr_err("%s: failed to set libtraceevent function resolver\n", __func__); err = -1; goto out_delete; diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 1de7660d93e9..d856b85862e2 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -265,7 +265,7 @@ pid_t machine__get_current_tid(struct machine *machine, int cpu); int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, pid_t tid); /* - * For use with libtraceevent's pevent_set_function_resolver() + * For use with libtraceevent's tep_set_function_resolver() */ char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp); diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index 850f7bf0eced..d970163f0145 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -236,12 +236,12 @@ static int read_header_files(struct tep_handle *pevent) } if (!tep_parse_header_page(pevent, header_page, size, - pevent_get_long_size(pevent))) { + tep_get_long_size(pevent))) { /* * The commit field in the page is of type long, * use that instead, since it represents the kernel. */ - pevent_set_long_size(pevent, pevent->header_page_size_size); + tep_set_long_size(pevent, pevent->header_page_size_size); } free(header_page); @@ -439,9 +439,9 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) pevent = tevent->pevent; - pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT); - pevent_set_file_bigendian(pevent, file_bigendian); - pevent_set_host_bigendian(pevent, host_bigendian); + tep_set_flag(pevent, PEVENT_NSEC_OUTPUT); + tep_set_file_bigendian(pevent, file_bigendian); + tep_set_host_bigendian(pevent, host_bigendian); if (do_read(buf, 1) < 0) goto out; @@ -451,8 +451,8 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) if (!file_page_size) goto out; - pevent_set_long_size(pevent, file_long_size); - pevent_set_page_size(pevent, file_page_size); + tep_set_long_size(pevent, file_long_size); + tep_set_page_size(pevent, file_page_size); err = read_header_files(pevent); if (err) diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index eed1c11c1915..679c93644a08 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -47,9 +47,9 @@ static int trace_event__init2(void) return -1; pevent = tevent.pevent; - pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT); - pevent_set_file_bigendian(pevent, be); - pevent_set_host_bigendian(pevent, be); + tep_set_flag(pevent, PEVENT_NSEC_OUTPUT); + tep_set_file_bigendian(pevent, be); + tep_set_host_bigendian(pevent, be); tevent_initialized = true; return 0; } @@ -60,7 +60,7 @@ int trace_event__register_resolver(struct machine *machine, if (!tevent_initialized && trace_event__init2()) return -1; - return pevent_set_function_resolver(tevent.pevent, func, machine); + return tep_set_function_resolver(tevent.pevent, func, machine); } void trace_event__cleanup(struct trace_event *t) -- cgit v1.2.3 From fc9b69710e0e5833c5d3e56c37cb56cfe89217c3 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:56 -0400 Subject: tools lib traceevent, perf tools: Rename traceevent_* APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "traceevent_". This changes APIs: traceevent_host_bigendian, traceevent_load_plugins and traceevent_unload_plugins Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180701.484691639@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.h | 8 ++++---- tools/lib/traceevent/event-plugin.c | 8 ++++---- tools/perf/util/trace-event.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index a68591c8dec3..97abeaced9c3 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -435,9 +435,9 @@ struct plugin_list; #define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) -struct plugin_list *traceevent_load_plugins(struct tep_handle *pevent); -void traceevent_unload_plugins(struct plugin_list *plugin_list, - struct tep_handle *pevent); +struct plugin_list *tep_load_plugins(struct tep_handle *pevent); +void tep_unload_plugins(struct plugin_list *plugin_list, + struct tep_handle *pevent); char **traceevent_plugin_list_options(void); void traceevent_plugin_free_options_list(char **list); int traceevent_plugin_add_options(const char *name, @@ -597,7 +597,7 @@ __data2host8(struct tep_handle *pevent, unsigned long long data) __data2host8(pevent, __val); \ }) -static inline int traceevent_host_bigendian(void) +static inline int tep_host_bigendian(void) { unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; unsigned int val; diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index 8c91c8f0abd9..39859cee7712 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -264,10 +264,10 @@ void traceevent_plugin_remove_options(struct tep_plugin_option *options) * @s: the trace_seq descripter to write to * @prefix: The prefix string to add before listing the option name * @suffix: The suffix string ot append after the option name - * @list: The list of plugins (usually returned by traceevent_load_plugins() + * @list: The list of plugins (usually returned by tep_load_plugins() * * Writes to the trace_seq @s the list of plugins (files) that is - * returned by traceevent_load_plugins(). Use @prefix and @suffix for formating: + * returned by tep_load_plugins(). Use @prefix and @suffix for formating: * @prefix = " ", @suffix = "\n". */ void traceevent_print_plugins(struct trace_seq *s, @@ -431,7 +431,7 @@ load_plugins(struct tep_handle *pevent, const char *suffix, } struct plugin_list* -traceevent_load_plugins(struct tep_handle *pevent) +tep_load_plugins(struct tep_handle *pevent) { struct plugin_list *list = NULL; @@ -440,7 +440,7 @@ traceevent_load_plugins(struct tep_handle *pevent) } void -traceevent_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent) +tep_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent) { tep_plugin_unload_func func; struct plugin_list *list; diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 679c93644a08..3102e8be81f5 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -31,7 +31,7 @@ int trace_event__init(struct trace_event *t) struct tep_handle *pevent = tep_alloc(); if (pevent) { - t->plugin_list = traceevent_load_plugins(pevent); + t->plugin_list = tep_load_plugins(pevent); t->pevent = pevent; } @@ -40,7 +40,7 @@ int trace_event__init(struct trace_event *t) static int trace_event__init2(void) { - int be = traceevent_host_bigendian(); + int be = tep_host_bigendian(); struct tep_handle *pevent; if (trace_event__init(&tevent)) @@ -65,7 +65,7 @@ int trace_event__register_resolver(struct machine *machine, void trace_event__cleanup(struct trace_event *t) { - traceevent_unload_plugins(t->plugin_list, t->pevent); + tep_unload_plugins(t->plugin_list, t->pevent); tep_free(t->pevent); } -- cgit v1.2.3 From 6fed932e9242b55a32dd75da7c2448b9b0c48a73 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:57 -0400 Subject: tools lib traceevent, perf tools: Rename 'enum pevent_flag' to 'enum tep_flag' In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes pevent_get_page_size API and enum pevent_flag to enum tep_flag Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180701.623942406@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 2 +- tools/lib/traceevent/event-parse.h | 10 +++++----- tools/lib/traceevent/event-plugin.c | 4 ++-- tools/perf/builtin-kmem.c | 2 +- tools/perf/util/trace-event-read.c | 2 +- tools/perf/util/trace-event.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 2667c18db27c..cfb86b789da6 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5515,7 +5515,7 @@ void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, } if (use_usec_format) { - if (pevent->flags & PEVENT_NSEC_OUTPUT) { + if (pevent->flags & TEP_NSEC_OUTPUT) { usecs = nsecs; p = 9; } else { diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 97abeaced9c3..97deb15f5355 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -373,10 +373,10 @@ enum pevent_func_arg_type { PEVENT_FUNC_ARG_MAX_TYPES }; -enum pevent_flag { - PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */ - PEVENT_DISABLE_SYS_PLUGINS = 1 << 1, - PEVENT_DISABLE_PLUGINS = 1 << 2, +enum tep_flag { + TEP_NSEC_OUTPUT = 1, /* output in NSECS */ + TEP_DISABLE_SYS_PLUGINS = 1 << 1, + TEP_DISABLE_PLUGINS = 1 << 2, }; #define PEVENT_ERRORS \ @@ -751,7 +751,7 @@ static inline void tep_set_long_size(struct tep_handle *pevent, int long_size) pevent->long_size = long_size; } -static inline int pevent_get_page_size(struct tep_handle *pevent) +static inline int tep_get_page_size(struct tep_handle *pevent) { return pevent->page_size; } diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index 39859cee7712..c837a73c03e6 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -390,7 +390,7 @@ load_plugins(struct tep_handle *pevent, const char *suffix, char *envdir; int ret; - if (pevent->flags & PEVENT_DISABLE_PLUGINS) + if (pevent->flags & TEP_DISABLE_PLUGINS) return; /* @@ -398,7 +398,7 @@ load_plugins(struct tep_handle *pevent, const char *suffix, * check that first. */ #ifdef PLUGIN_DIR - if (!(pevent->flags & PEVENT_DISABLE_SYS_PLUGINS)) + if (!(pevent->flags & TEP_DISABLE_SYS_PLUGINS)) load_plugins_dir(pevent, suffix, PLUGIN_DIR, load_plugin, data); #endif diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 73c073ade71c..b63bca4b0c2a 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -1974,7 +1974,7 @@ int cmd_kmem(int argc, const char **argv) goto out_delete; } - kmem_page_size = pevent_get_page_size(evsel->tp_format->pevent); + kmem_page_size = tep_get_page_size(evsel->tp_format->pevent); symbol_conf.use_callchain = true; } diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index d970163f0145..3dfc1db6b25b 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -439,7 +439,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) pevent = tevent->pevent; - tep_set_flag(pevent, PEVENT_NSEC_OUTPUT); + tep_set_flag(pevent, TEP_NSEC_OUTPUT); tep_set_file_bigendian(pevent, file_bigendian); tep_set_host_bigendian(pevent, host_bigendian); diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 3102e8be81f5..58bb72f266f3 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -47,7 +47,7 @@ static int trace_event__init2(void) return -1; pevent = tevent.pevent; - tep_set_flag(pevent, PEVENT_NSEC_OUTPUT); + tep_set_flag(pevent, TEP_NSEC_OUTPUT); tep_set_file_bigendian(pevent, be); tep_set_host_bigendian(pevent, be); tevent_initialized = true; -- cgit v1.2.3 From d97f4ef177ddf8b877de2545dbd67d1faf6878f2 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:58 -0400 Subject: tools lib traceevent, tools lib lockdep: Rename 'enum pevent_errno' to 'enum tep_errno' In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes 'enum pevent_errno' to 'enum tep_errno'. Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180701.770475059@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/lockdep/Makefile | 4 +- tools/lib/traceevent/Makefile | 4 +- tools/lib/traceevent/event-parse.c | 60 +++++++-------- tools/lib/traceevent/event-parse.h | 48 ++++++------ tools/lib/traceevent/parse-filter.c | 150 ++++++++++++++++++------------------ 5 files changed, 133 insertions(+), 133 deletions(-) diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile index 9b0ca3ad1ef3..9dafb8cb752f 100644 --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile @@ -129,12 +129,12 @@ $(OUTPUT)liblockdep.a: $(LIB_IN) tags: force $(RM) tags find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ - --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' + --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/' TAGS: force $(RM) TAGS find . -name '*.[ch]' | xargs etags \ - --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' + --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/' define do_install $(print_install) \ diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 46cd5f871ad7..0b4e833088a4 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile @@ -233,12 +233,12 @@ endef tags: force $(RM) tags find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ - --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' + --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/' TAGS: force $(RM) TAGS find . -name '*.[ch]' | xargs etags \ - --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' + --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/' define do_install_mkdir if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index cfb86b789da6..01b5dbf2abdf 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -6035,9 +6035,9 @@ static int find_event_handle(struct tep_handle *pevent, struct event_format *eve * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno __pevent_parse_format(struct event_format **eventp, - struct tep_handle *pevent, const char *buf, - unsigned long size, const char *sys) +enum tep_errno __pevent_parse_format(struct event_format **eventp, + struct tep_handle *pevent, const char *buf, + unsigned long size, const char *sys) { struct event_format *event; int ret; @@ -6046,12 +6046,12 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, *eventp = event = alloc_event(); if (!event) - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; event->name = event_read_name(); if (!event->name) { /* Bad event? */ - ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; + ret = TEP_ERRNO__MEM_ALLOC_FAILED; goto event_alloc_failed; } @@ -6064,7 +6064,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, event->id = event_read_id(); if (event->id < 0) { - ret = PEVENT_ERRNO__READ_ID_FAILED; + ret = TEP_ERRNO__READ_ID_FAILED; /* * This isn't an allocation error actually. * But as the ID is critical, just bail out. @@ -6074,7 +6074,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, event->system = strdup(sys); if (!event->system) { - ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; + ret = TEP_ERRNO__MEM_ALLOC_FAILED; goto event_alloc_failed; } @@ -6083,7 +6083,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, ret = event_read_format(event); if (ret < 0) { - ret = PEVENT_ERRNO__READ_FORMAT_FAILED; + ret = TEP_ERRNO__READ_FORMAT_FAILED; goto event_parse_failed; } @@ -6098,7 +6098,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, show_warning = 1; if (ret < 0) { - ret = PEVENT_ERRNO__READ_PRINT_FAILED; + ret = TEP_ERRNO__READ_PRINT_FAILED; goto event_parse_failed; } @@ -6112,14 +6112,14 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, arg = alloc_arg(); if (!arg) { event->flags |= EVENT_FL_FAILED; - return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED; + return TEP_ERRNO__OLD_FTRACE_ARG_FAILED; } arg->type = PRINT_FIELD; arg->field.name = strdup(field->name); if (!arg->field.name) { event->flags |= EVENT_FL_FAILED; free_arg(arg); - return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED; + return TEP_ERRNO__OLD_FTRACE_ARG_FAILED; } arg->field.field = field; *list = arg; @@ -6142,7 +6142,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, return ret; } -static enum pevent_errno +static enum tep_errno __pevent_parse_event(struct tep_handle *pevent, struct event_format **eventp, const char *buf, unsigned long size, @@ -6155,7 +6155,7 @@ __pevent_parse_event(struct tep_handle *pevent, return ret; if (pevent && add_event(pevent, event)) { - ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; + ret = TEP_ERRNO__MEM_ALLOC_FAILED; goto event_add_failed; } @@ -6185,10 +6185,10 @@ event_add_failed: * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno tep_parse_format(struct tep_handle *pevent, - struct event_format **eventp, - const char *buf, - unsigned long size, const char *sys) +enum tep_errno tep_parse_format(struct tep_handle *pevent, + struct event_format **eventp, + const char *buf, + unsigned long size, const char *sys) { return __pevent_parse_event(pevent, eventp, buf, size, sys); } @@ -6207,8 +6207,8 @@ enum pevent_errno tep_parse_format(struct tep_handle *pevent, * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno tep_parse_event(struct tep_handle *pevent, const char *buf, - unsigned long size, const char *sys) +enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf, + unsigned long size, const char *sys) { struct event_format *event = NULL; return __pevent_parse_event(pevent, &event, buf, size, sys); @@ -6217,12 +6217,12 @@ enum pevent_errno tep_parse_event(struct tep_handle *pevent, const char *buf, #undef _PE #define _PE(code, str) str static const char * const pevent_error_str[] = { - PEVENT_ERRORS + TEP_ERRORS }; #undef _PE int pevent_strerror(struct tep_handle *pevent __maybe_unused, - enum pevent_errno errnum, char *buf, size_t buflen) + enum tep_errno errnum, char *buf, size_t buflen) { int idx; const char *msg; @@ -6232,11 +6232,11 @@ int pevent_strerror(struct tep_handle *pevent __maybe_unused, return 0; } - if (errnum <= __PEVENT_ERRNO__START || - errnum >= __PEVENT_ERRNO__END) + if (errnum <= __TEP_ERRNO__START || + errnum >= __TEP_ERRNO__END) return -1; - idx = errnum - __PEVENT_ERRNO__START - 1; + idx = errnum - __TEP_ERRNO__START - 1; msg = pevent_error_str[idx]; snprintf(buf, buflen, "%s", msg); @@ -6517,7 +6517,7 @@ int pevent_register_print_function(struct tep_handle *pevent, func_handle = calloc(1, sizeof(*func_handle)); if (!func_handle) { do_warning("Failed to allocate function handler"); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } func_handle->ret_type = ret_type; @@ -6526,7 +6526,7 @@ int pevent_register_print_function(struct tep_handle *pevent, if (!func_handle->name) { do_warning("Failed to allocate function name"); free(func_handle); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } next_param = &(func_handle->params); @@ -6538,14 +6538,14 @@ int pevent_register_print_function(struct tep_handle *pevent, if (type >= PEVENT_FUNC_ARG_MAX_TYPES) { do_warning("Invalid argument type %d", type); - ret = PEVENT_ERRNO__INVALID_ARG_TYPE; + ret = TEP_ERRNO__INVALID_ARG_TYPE; goto out_free; } param = malloc(sizeof(*param)); if (!param) { do_warning("Failed to allocate function param"); - ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; + ret = TEP_ERRNO__MEM_ALLOC_FAILED; goto out_free; } param->type = type; @@ -6654,7 +6654,7 @@ int pevent_register_event_handler(struct tep_handle *pevent, int id, handle = calloc(1, sizeof(*handle)); if (!handle) { do_warning("Failed to allocate event handler"); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } handle->id = id; @@ -6669,7 +6669,7 @@ int pevent_register_event_handler(struct tep_handle *pevent, int id, free((void *)handle->event_name); free((void *)handle->sys_name); free(handle); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } handle->func = func; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 97deb15f5355..3067f524fef8 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -379,7 +379,7 @@ enum tep_flag { TEP_DISABLE_PLUGINS = 1 << 2, }; -#define PEVENT_ERRORS \ +#define TEP_ERRORS \ _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \ _PE(PARSE_EVENT_FAILED, "failed to parse event"), \ _PE(READ_ID_FAILED, "failed to read event id"), \ @@ -411,10 +411,10 @@ enum tep_flag { _PE(FILTER_MISS, "record does not match to filter") #undef _PE -#define _PE(__code, __str) PEVENT_ERRNO__ ## __code -enum pevent_errno { - PEVENT_ERRNO__SUCCESS = 0, - PEVENT_ERRNO__FILTER_MATCH = PEVENT_ERRNO__SUCCESS, +#define _PE(__code, __str) TEP_ERRNO__ ## __code +enum tep_errno { + TEP_ERRNO__SUCCESS = 0, + TEP_ERRNO__FILTER_MATCH = TEP_ERRNO__SUCCESS, /* * Choose an arbitrary negative big number not to clash with standard @@ -423,11 +423,11 @@ enum pevent_errno { * * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html */ - __PEVENT_ERRNO__START = -100000, + __TEP_ERRNO__START = -100000, - PEVENT_ERRORS, + TEP_ERRORS, - __PEVENT_ERRNO__END, + __TEP_ERRNO__END, }; #undef _PE @@ -642,12 +642,12 @@ void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size, int long_size); -enum pevent_errno tep_parse_event(struct tep_handle *pevent, const char *buf, - unsigned long size, const char *sys); -enum pevent_errno tep_parse_format(struct tep_handle *pevent, - struct event_format **eventp, - const char *buf, - unsigned long size, const char *sys); +enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf, + unsigned long size, const char *sys); +enum tep_errno tep_parse_format(struct tep_handle *pevent, + struct event_format **eventp, + const char *buf, + unsigned long size, const char *sys); void pevent_free_format(struct event_format *event); void pevent_free_format_field(struct format_field *field); @@ -724,7 +724,7 @@ void tep_print_fields(struct trace_seq *s, void *data, int size __maybe_unused, struct event_format *event); void tep_event_info(struct trace_seq *s, struct event_format *event, struct tep_record *record); -int pevent_strerror(struct tep_handle *pevent, enum pevent_errno errnum, +int pevent_strerror(struct tep_handle *pevent, enum tep_errno errnum, char *buf, size_t buflen); struct event_format **pevent_list_events(struct tep_handle *pevent, enum event_sort_type); @@ -942,10 +942,10 @@ struct event_filter { struct event_filter *pevent_filter_alloc(struct tep_handle *pevent); /* for backward compatibility */ -#define FILTER_NONE PEVENT_ERRNO__NO_FILTER -#define FILTER_NOEXIST PEVENT_ERRNO__FILTER_NOT_FOUND -#define FILTER_MISS PEVENT_ERRNO__FILTER_MISS -#define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH +#define FILTER_NONE TEP_ERRNO__NO_FILTER +#define FILTER_NOEXIST TEP_ERRNO__FILTER_NOT_FOUND +#define FILTER_MISS TEP_ERRNO__FILTER_MISS +#define FILTER_MATCH TEP_ERRNO__FILTER_MATCH enum filter_trivial_type { FILTER_TRIVIAL_FALSE, @@ -953,13 +953,13 @@ enum filter_trivial_type { FILTER_TRIVIAL_BOTH, }; -enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, - const char *filter_str); +enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, + const char *filter_str); -enum pevent_errno pevent_filter_match(struct event_filter *filter, - struct tep_record *record); +enum tep_errno pevent_filter_match(struct event_filter *filter, + struct tep_record *record); -int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, +int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, char *buf, size_t buflen); int pevent_event_filtered(struct event_filter *filter, diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 732c9e7d8aaf..5dc474027313 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -268,7 +268,7 @@ static int event_match(struct event_format *event, !regexec(ereg, event->name, 0, NULL, 0); } -static enum pevent_errno +static enum tep_errno find_event(struct tep_handle *pevent, struct event_list **events, char *sys_name, char *event_name) { @@ -289,26 +289,26 @@ find_event(struct tep_handle *pevent, struct event_list **events, ret = asprintf(®, "^%s$", event_name); if (ret < 0) - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; ret = regcomp(&ereg, reg, REG_ICASE|REG_NOSUB); free(reg); if (ret) - return PEVENT_ERRNO__INVALID_EVENT_NAME; + return TEP_ERRNO__INVALID_EVENT_NAME; if (sys_name) { ret = asprintf(®, "^%s$", sys_name); if (ret < 0) { regfree(&ereg); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } ret = regcomp(&sreg, reg, REG_ICASE|REG_NOSUB); free(reg); if (ret) { regfree(&ereg); - return PEVENT_ERRNO__INVALID_EVENT_NAME; + return TEP_ERRNO__INVALID_EVENT_NAME; } } @@ -328,9 +328,9 @@ find_event(struct tep_handle *pevent, struct event_list **events, regfree(&sreg); if (!match) - return PEVENT_ERRNO__EVENT_NOT_FOUND; + return TEP_ERRNO__EVENT_NOT_FOUND; if (fail) - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; return 0; } @@ -346,7 +346,7 @@ static void free_events(struct event_list *events) } } -static enum pevent_errno +static enum tep_errno create_arg_item(struct event_format *event, const char *token, enum event_type type, struct filter_arg **parg, char *error_str) { @@ -356,7 +356,7 @@ create_arg_item(struct event_format *event, const char *token, arg = allocate_arg(); if (arg == NULL) { show_error(error_str, "failed to allocate filter arg"); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } switch (type) { @@ -370,7 +370,7 @@ create_arg_item(struct event_format *event, const char *token, if (!arg->value.str) { free_arg(arg); show_error(error_str, "failed to allocate string filter arg"); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } break; case EVENT_ITEM: @@ -402,7 +402,7 @@ create_arg_item(struct event_format *event, const char *token, default: free_arg(arg); show_error(error_str, "expected a value but found %s", token); - return PEVENT_ERRNO__UNEXPECTED_TYPE; + return TEP_ERRNO__UNEXPECTED_TYPE; } *parg = arg; return 0; @@ -454,7 +454,7 @@ create_arg_cmp(enum filter_cmp_type ctype) return arg; } -static enum pevent_errno +static enum tep_errno add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) { struct filter_arg *left; @@ -487,7 +487,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) break; default: show_error(error_str, "Illegal rvalue"); - return PEVENT_ERRNO__ILLEGAL_RVALUE; + return TEP_ERRNO__ILLEGAL_RVALUE; } /* @@ -534,7 +534,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) if (left->type != FILTER_ARG_FIELD) { show_error(error_str, "Illegal lvalue for string comparison"); - return PEVENT_ERRNO__ILLEGAL_LVALUE; + return TEP_ERRNO__ILLEGAL_LVALUE; } /* Make sure this is a valid string compare */ @@ -553,13 +553,13 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) show_error(error_str, "RegEx '%s' did not compute", str); - return PEVENT_ERRNO__INVALID_REGEX; + return TEP_ERRNO__INVALID_REGEX; } break; default: show_error(error_str, "Illegal comparison for string"); - return PEVENT_ERRNO__ILLEGAL_STRING_CMP; + return TEP_ERRNO__ILLEGAL_STRING_CMP; } op->type = FILTER_ARG_STR; @@ -568,7 +568,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) op->str.val = strdup(str); if (!op->str.val) { show_error(error_str, "Failed to allocate string filter"); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } /* * Need a buffer to copy data for tests @@ -576,7 +576,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) op->str.buffer = malloc(op->str.field->size + 1); if (!op->str.buffer) { show_error(error_str, "Failed to allocate string filter"); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } /* Null terminate this buffer */ op->str.buffer[op->str.field->size] = 0; @@ -595,7 +595,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) case FILTER_CMP_NOT_REGEX: show_error(error_str, "Op not allowed with integers"); - return PEVENT_ERRNO__ILLEGAL_INTEGER_CMP; + return TEP_ERRNO__ILLEGAL_INTEGER_CMP; default: break; @@ -616,7 +616,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) out_fail: show_error(error_str, "Syntax error"); - return PEVENT_ERRNO__SYNTAX_ERROR; + return TEP_ERRNO__SYNTAX_ERROR; } static struct filter_arg * @@ -629,7 +629,7 @@ rotate_op_right(struct filter_arg *a, struct filter_arg *b) return arg; } -static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg) +static enum tep_errno add_left(struct filter_arg *op, struct filter_arg *arg) { switch (op->type) { case FILTER_ARG_EXP: @@ -648,11 +648,11 @@ static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg) /* left arg of compares must be a field */ if (arg->type != FILTER_ARG_FIELD && arg->type != FILTER_ARG_BOOLEAN) - return PEVENT_ERRNO__INVALID_ARG_TYPE; + return TEP_ERRNO__INVALID_ARG_TYPE; op->num.left = arg; break; default: - return PEVENT_ERRNO__INVALID_ARG_TYPE; + return TEP_ERRNO__INVALID_ARG_TYPE; } return 0; } @@ -765,7 +765,7 @@ enum filter_vals { FILTER_VAL_TRUE, }; -static enum pevent_errno +static enum tep_errno reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, struct filter_arg *arg, char *error_str) { @@ -775,7 +775,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, if (parent->type != FILTER_ARG_OP && arg->type != FILTER_ARG_OP) { show_error(error_str, "can not reparent other than OP"); - return PEVENT_ERRNO__REPARENT_NOT_OP; + return TEP_ERRNO__REPARENT_NOT_OP; } /* Get the sibling */ @@ -787,7 +787,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, other_child = old_child->op.right; } else { show_error(error_str, "Error in reparent op, find other child"); - return PEVENT_ERRNO__REPARENT_FAILED; + return TEP_ERRNO__REPARENT_FAILED; } /* Detach arg from old_child */ @@ -808,7 +808,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, ptr = &parent->op.left; else { show_error(error_str, "Error in reparent op"); - return PEVENT_ERRNO__REPARENT_FAILED; + return TEP_ERRNO__REPARENT_FAILED; } *ptr = arg; @@ -817,7 +817,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, return 0; } -/* Returns either filter_vals (success) or pevent_errno (failfure) */ +/* Returns either filter_vals (success) or tep_errno (failfure) */ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, char *error_str) { @@ -912,7 +912,7 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, return rval; default: show_error(error_str, "bad arg in filter tree"); - return PEVENT_ERRNO__BAD_FILTER_ARG; + return TEP_ERRNO__BAD_FILTER_ARG; } return FILTER_VAL_NORM; } @@ -937,7 +937,7 @@ static int collapse_tree(struct filter_arg *arg, arg->boolean.value = ret == FILTER_VAL_TRUE; } else { show_error(error_str, "Failed to allocate filter arg"); - ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; + ret = TEP_ERRNO__MEM_ALLOC_FAILED; } break; @@ -952,7 +952,7 @@ static int collapse_tree(struct filter_arg *arg, return ret; } -static enum pevent_errno +static enum tep_errno process_filter(struct event_format *event, struct filter_arg **parg, char *error_str, int not) { @@ -966,7 +966,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, enum filter_op_type btype; enum filter_exp_type etype; enum filter_cmp_type ctype; - enum pevent_errno ret; + enum tep_errno ret; *parg = NULL; @@ -1004,7 +1004,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, case EVENT_DELIM: if (*token == ',') { show_error(error_str, "Illegal token ','"); - ret = PEVENT_ERRNO__ILLEGAL_TOKEN; + ret = TEP_ERRNO__ILLEGAL_TOKEN; goto fail; } @@ -1012,22 +1012,22 @@ process_filter(struct event_format *event, struct filter_arg **parg, if (left_item) { show_error(error_str, "Open paren can not come after item"); - ret = PEVENT_ERRNO__INVALID_PAREN; + ret = TEP_ERRNO__INVALID_PAREN; goto fail; } if (current_exp) { show_error(error_str, "Open paren can not come after expression"); - ret = PEVENT_ERRNO__INVALID_PAREN; + ret = TEP_ERRNO__INVALID_PAREN; goto fail; } ret = process_filter(event, &arg, error_str, 0); - if (ret != PEVENT_ERRNO__UNBALANCED_PAREN) { + if (ret != TEP_ERRNO__UNBALANCED_PAREN) { if (ret == 0) { show_error(error_str, "Unbalanced number of '('"); - ret = PEVENT_ERRNO__UNBALANCED_PAREN; + ret = TEP_ERRNO__UNBALANCED_PAREN; } goto fail; } @@ -1064,7 +1064,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, else *parg = current_exp; free(token); - return PEVENT_ERRNO__UNBALANCED_PAREN; + return TEP_ERRNO__UNBALANCED_PAREN; } break; @@ -1091,7 +1091,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, case OP_NONE: show_error(error_str, "Unknown op token %s", token); - ret = PEVENT_ERRNO__UNKNOWN_TOKEN; + ret = TEP_ERRNO__UNKNOWN_TOKEN; goto fail; } @@ -1179,11 +1179,11 @@ process_filter(struct event_format *event, struct filter_arg **parg, fail_alloc: show_error(error_str, "failed to allocate filter arg"); - ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; + ret = TEP_ERRNO__MEM_ALLOC_FAILED; goto fail; fail_syntax: show_error(error_str, "Syntax error"); - ret = PEVENT_ERRNO__SYNTAX_ERROR; + ret = TEP_ERRNO__SYNTAX_ERROR; fail: free_arg(current_op); free_arg(current_exp); @@ -1192,7 +1192,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, return ret; } -static enum pevent_errno +static enum tep_errno process_event(struct event_format *event, const char *filter_str, struct filter_arg **parg, char *error_str) { @@ -1208,7 +1208,7 @@ process_event(struct event_format *event, const char *filter_str, if (!*parg) { *parg = allocate_arg(); if (*parg == NULL) - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; (*parg)->type = FILTER_ARG_BOOLEAN; (*parg)->boolean.value = FILTER_FALSE; @@ -1217,13 +1217,13 @@ process_event(struct event_format *event, const char *filter_str, return 0; } -static enum pevent_errno +static enum tep_errno filter_event(struct event_filter *filter, struct event_format *event, const char *filter_str, char *error_str) { struct filter_type *filter_type; struct filter_arg *arg; - enum pevent_errno ret; + enum tep_errno ret; if (filter_str) { ret = process_event(event, filter_str, &arg, error_str); @@ -1234,7 +1234,7 @@ filter_event(struct event_filter *filter, struct event_format *event, /* just add a TRUE arg */ arg = allocate_arg(); if (arg == NULL) - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; arg->type = FILTER_ARG_BOOLEAN; arg->boolean.value = FILTER_TRUE; @@ -1242,7 +1242,7 @@ filter_event(struct event_filter *filter, struct event_format *event, filter_type = add_filter_type(filter, event->id); if (filter_type == NULL) - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; if (filter_type->filter) free_arg(filter_type->filter); @@ -1267,7 +1267,7 @@ static void filter_init_error_buf(struct event_filter *filter) * negative error code. Use pevent_filter_strerror() to see * actual error message in case of error. */ -enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, +enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, const char *filter_str) { struct tep_handle *pevent = filter->pevent; @@ -1279,7 +1279,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, char *event_name = NULL; char *sys_name = NULL; char *sp; - enum pevent_errno rtn = 0; /* PEVENT_ERRNO__SUCCESS */ + enum tep_errno rtn = 0; /* TEP_ERRNO__SUCCESS */ int len; int ret; @@ -1305,7 +1305,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, if (this_event == NULL) { /* This can only happen when events is NULL, but still */ free_events(events); - return PEVENT_ERRNO__MEM_ALLOC_FAILED; + return TEP_ERRNO__MEM_ALLOC_FAILED; } memcpy(this_event, filter_str, len); this_event[len] = 0; @@ -1322,7 +1322,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, /* This can only happen when events is NULL, but still */ free_events(events); free(this_event); - return PEVENT_ERRNO__FILTER_NOT_FOUND; + return TEP_ERRNO__FILTER_NOT_FOUND; } /* Find this event */ @@ -1379,10 +1379,10 @@ static void free_filter_type(struct filter_type *filter_type) * * Returns 0 if message was filled successfully, -1 if error */ -int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, +int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, char *buf, size_t buflen) { - if (err <= __PEVENT_ERRNO__START || err >= __PEVENT_ERRNO__END) + if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END) return -1; if (strlen(filter->error_buffer) > 0) { @@ -1697,7 +1697,7 @@ int pevent_filter_event_has_trivial(struct event_filter *filter, } static int test_filter(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err); + struct tep_record *record, enum tep_errno *err); static const char * get_comm(struct event_format *event, struct tep_record *record) @@ -1748,11 +1748,11 @@ get_value(struct event_format *event, static unsigned long long get_arg_value(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err); + struct tep_record *record, enum tep_errno *err); static unsigned long long get_exp_value(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err) + struct tep_record *record, enum tep_errno *err) { unsigned long long lval, rval; @@ -1800,14 +1800,14 @@ get_exp_value(struct event_format *event, struct filter_arg *arg, case FILTER_EXP_NOT: default: if (!*err) - *err = PEVENT_ERRNO__INVALID_EXP_TYPE; + *err = TEP_ERRNO__INVALID_EXP_TYPE; } return 0; } static unsigned long long get_arg_value(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err) + struct tep_record *record, enum tep_errno *err) { switch (arg->type) { case FILTER_ARG_FIELD: @@ -1816,7 +1816,7 @@ get_arg_value(struct event_format *event, struct filter_arg *arg, case FILTER_ARG_VALUE: if (arg->value.type != FILTER_NUMBER) { if (!*err) - *err = PEVENT_ERRNO__NOT_A_NUMBER; + *err = TEP_ERRNO__NOT_A_NUMBER; } return arg->value.val; @@ -1825,13 +1825,13 @@ get_arg_value(struct event_format *event, struct filter_arg *arg, default: if (!*err) - *err = PEVENT_ERRNO__INVALID_ARG_TYPE; + *err = TEP_ERRNO__INVALID_ARG_TYPE; } return 0; } static int test_num(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err) + struct tep_record *record, enum tep_errno *err) { unsigned long long lval, rval; @@ -1866,7 +1866,7 @@ static int test_num(struct event_format *event, struct filter_arg *arg, default: if (!*err) - *err = PEVENT_ERRNO__ILLEGAL_INTEGER_CMP; + *err = TEP_ERRNO__ILLEGAL_INTEGER_CMP; return 0; } } @@ -1922,7 +1922,7 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco } static int test_str(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err) + struct tep_record *record, enum tep_errno *err) { const char *val; @@ -1947,13 +1947,13 @@ static int test_str(struct event_format *event, struct filter_arg *arg, default: if (!*err) - *err = PEVENT_ERRNO__ILLEGAL_STRING_CMP; + *err = TEP_ERRNO__ILLEGAL_STRING_CMP; return 0; } } static int test_op(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err) + struct tep_record *record, enum tep_errno *err) { switch (arg->op.type) { case FILTER_OP_AND: @@ -1969,13 +1969,13 @@ static int test_op(struct event_format *event, struct filter_arg *arg, default: if (!*err) - *err = PEVENT_ERRNO__INVALID_OP_TYPE; + *err = TEP_ERRNO__INVALID_OP_TYPE; return 0; } } static int test_filter(struct event_format *event, struct filter_arg *arg, - struct tep_record *record, enum pevent_errno *err) + struct tep_record *record, enum tep_errno *err) { if (*err) { /* @@ -2009,7 +2009,7 @@ static int test_filter(struct event_format *event, struct filter_arg *arg, default: if (!*err) - *err = PEVENT_ERRNO__INVALID_ARG_TYPE; + *err = TEP_ERRNO__INVALID_ARG_TYPE; return 0; } } @@ -2039,38 +2039,38 @@ int pevent_event_filtered(struct event_filter *filter, int event_id) * @filter: filter struct with filter information * @record: the record to test against the filter * - * Returns: match result or error code (prefixed with PEVENT_ERRNO__) + * Returns: match result or error code (prefixed with TEP_ERRNO__) * FILTER_MATCH - filter found for event and @record matches * FILTER_MISS - filter found for event and @record does not match * FILTER_NOT_FOUND - no filter found for @record's event * NO_FILTER - if no filters exist * otherwise - error occurred during test */ -enum pevent_errno pevent_filter_match(struct event_filter *filter, - struct tep_record *record) +enum tep_errno pevent_filter_match(struct event_filter *filter, + struct tep_record *record) { struct tep_handle *pevent = filter->pevent; struct filter_type *filter_type; int event_id; int ret; - enum pevent_errno err = 0; + enum tep_errno err = 0; filter_init_error_buf(filter); if (!filter->filters) - return PEVENT_ERRNO__NO_FILTER; + return TEP_ERRNO__NO_FILTER; event_id = pevent_data_type(pevent, record); filter_type = find_filter_type(filter, event_id); if (!filter_type) - return PEVENT_ERRNO__FILTER_NOT_FOUND; + return TEP_ERRNO__FILTER_NOT_FOUND; ret = test_filter(filter_type->event, filter_type->filter, record, &err); if (err) return err; - return ret ? PEVENT_ERRNO__FILTER_MATCH : PEVENT_ERRNO__FILTER_MISS; + return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS; } static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) -- cgit v1.2.3 From 3cf477836e24187f2f3acbbf48c80a478d979093 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:02:59 -0400 Subject: tools lib traceevent: Rename pevent_function* APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "pevent_". This changes APIs: pevent_function_handler, pevent_func_handler, pevent_func_arg_type, PEVENT_FUNC_ARG_VOID, PEVENT_FUNC_ARG_INT, PEVENT_FUNC_ARG_LONG, PEVENT_FUNC_ARG_STRING, PEVENT_FUNC_ARG_PTRS, PEVENT_FUNC_ARG_MAX_TYPES Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180701.935881193@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 62 +++++++++++++++++----------------- tools/lib/traceevent/event-parse.h | 30 ++++++++-------- tools/lib/traceevent/plugin_cfg80211.c | 6 ++-- tools/lib/traceevent/plugin_jbd2.c | 12 +++---- tools/lib/traceevent/plugin_kvm.c | 6 ++-- tools/lib/traceevent/plugin_scsi.c | 10 +++--- tools/lib/traceevent/plugin_xen.c | 6 ++-- 7 files changed, 66 insertions(+), 66 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 01b5dbf2abdf..8d0ce0ea52dc 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -94,14 +94,14 @@ struct event_handler { struct pevent_func_params { struct pevent_func_params *next; - enum pevent_func_arg_type type; + enum tep_func_arg_type type; }; -struct pevent_function_handler { - struct pevent_function_handler *next; - enum pevent_func_arg_type ret_type; +struct tep_function_handler { + struct tep_function_handler *next; + enum tep_func_arg_type ret_type; char *name; - pevent_func_handler func; + tep_func_handler func; struct pevent_func_params *params; int nr_args; }; @@ -110,7 +110,7 @@ static unsigned long long process_defined_func(struct trace_seq *s, void *data, int size, struct event_format *event, struct print_arg *arg); -static void free_func_handle(struct pevent_function_handler *func); +static void free_func_handle(struct tep_function_handler *func); /** * pevent_buffer_init - init buffer for parsing @@ -2914,10 +2914,10 @@ process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg return EVENT_ERROR; } -static struct pevent_function_handler * +static struct tep_function_handler * find_func_handler(struct tep_handle *pevent, char *func_name) { - struct pevent_function_handler *func; + struct tep_function_handler *func; if (!pevent) return NULL; @@ -2932,8 +2932,8 @@ find_func_handler(struct tep_handle *pevent, char *func_name) static void remove_func_handler(struct tep_handle *pevent, char *func_name) { - struct pevent_function_handler *func; - struct pevent_function_handler **next; + struct tep_function_handler *func; + struct tep_function_handler **next; next = &pevent->func_handlers; while ((func = *next)) { @@ -2947,7 +2947,7 @@ static void remove_func_handler(struct tep_handle *pevent, char *func_name) } static enum event_type -process_func_handler(struct event_format *event, struct pevent_function_handler *func, +process_func_handler(struct event_format *event, struct tep_function_handler *func, struct print_arg *arg, char **tok) { struct print_arg **next_arg; @@ -3008,7 +3008,7 @@ static enum event_type process_function(struct event_format *event, struct print_arg *arg, char *token, char **tok) { - struct pevent_function_handler *func; + struct tep_function_handler *func; if (strcmp(token, "__print_flags") == 0) { free_token(token); @@ -4132,7 +4132,7 @@ static unsigned long long process_defined_func(struct trace_seq *s, void *data, int size, struct event_format *event, struct print_arg *arg) { - struct pevent_function_handler *func_handle = arg->func.func; + struct tep_function_handler *func_handle = arg->func.func; struct pevent_func_params *param; unsigned long long *args; unsigned long long ret; @@ -4159,12 +4159,12 @@ process_defined_func(struct trace_seq *s, void *data, int size, for (i = 0; i < func_handle->nr_args; i++) { switch (param->type) { - case PEVENT_FUNC_ARG_INT: - case PEVENT_FUNC_ARG_LONG: - case PEVENT_FUNC_ARG_PTR: + case TEP_FUNC_ARG_INT: + case TEP_FUNC_ARG_LONG: + case TEP_FUNC_ARG_PTR: args[i] = eval_num_arg(data, size, event, farg); break; - case PEVENT_FUNC_ARG_STRING: + case TEP_FUNC_ARG_STRING: trace_seq_init(&str); print_str_arg(&str, data, size, event, "%s", -1, farg); trace_seq_terminate(&str); @@ -6461,7 +6461,7 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt, return -1; } -static void free_func_handle(struct pevent_function_handler *func) +static void free_func_handle(struct tep_function_handler *func) { struct pevent_func_params *params; @@ -6482,24 +6482,24 @@ static void free_func_handle(struct pevent_function_handler *func) * @func: the function to process the helper function * @ret_type: the return type of the helper function * @name: the name of the helper function - * @parameters: A list of enum pevent_func_arg_type + * @parameters: A list of enum tep_func_arg_type * * Some events may have helper functions in the print format arguments. * This allows a plugin to dynamically create a way to process one * of these functions. * - * The @parameters is a variable list of pevent_func_arg_type enums that - * must end with PEVENT_FUNC_ARG_VOID. + * The @parameters is a variable list of tep_func_arg_type enums that + * must end with TEP_FUNC_ARG_VOID. */ int pevent_register_print_function(struct tep_handle *pevent, - pevent_func_handler func, - enum pevent_func_arg_type ret_type, + tep_func_handler func, + enum tep_func_arg_type ret_type, char *name, ...) { - struct pevent_function_handler *func_handle; + struct tep_function_handler *func_handle; struct pevent_func_params **next_param; struct pevent_func_params *param; - enum pevent_func_arg_type type; + enum tep_func_arg_type type; va_list ap; int ret; @@ -6532,11 +6532,11 @@ int pevent_register_print_function(struct tep_handle *pevent, next_param = &(func_handle->params); va_start(ap, name); for (;;) { - type = va_arg(ap, enum pevent_func_arg_type); - if (type == PEVENT_FUNC_ARG_VOID) + type = va_arg(ap, enum tep_func_arg_type); + if (type == TEP_FUNC_ARG_VOID) break; - if (type >= PEVENT_FUNC_ARG_MAX_TYPES) { + if (type >= TEP_FUNC_ARG_MAX_TYPES) { do_warning("Invalid argument type %d", type); ret = TEP_ERRNO__INVALID_ARG_TYPE; goto out_free; @@ -6579,9 +6579,9 @@ int pevent_register_print_function(struct tep_handle *pevent, * Returns 0 if the handler was removed successully, -1 otherwise. */ int pevent_unregister_print_function(struct tep_handle *pevent, - pevent_func_handler func, char *name) + tep_func_handler func, char *name) { - struct pevent_function_handler *func_handle; + struct tep_function_handler *func_handle; func_handle = find_func_handler(pevent, name); if (func_handle && func_handle->func == func) { @@ -6819,7 +6819,7 @@ void tep_free(struct tep_handle *pevent) struct cmdline_list *cmdlist, *cmdnext; struct func_list *funclist, *funcnext; struct printk_list *printklist, *printknext; - struct pevent_function_handler *func_handler; + struct tep_function_handler *func_handler; struct event_handler *handle; int i; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 3067f524fef8..81f34132fc47 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -269,10 +269,10 @@ struct print_arg_op { struct print_arg *right; }; -struct pevent_function_handler; +struct tep_function_handler; struct print_arg_func { - struct pevent_function_handler *func; + struct tep_function_handler *func; struct print_arg *args; }; @@ -361,16 +361,16 @@ enum event_type { EVENT_SQUOTE, }; -typedef unsigned long long (*pevent_func_handler)(struct trace_seq *s, - unsigned long long *args); +typedef unsigned long long (*tep_func_handler)(struct trace_seq *s, + unsigned long long *args); -enum pevent_func_arg_type { - PEVENT_FUNC_ARG_VOID, - PEVENT_FUNC_ARG_INT, - PEVENT_FUNC_ARG_LONG, - PEVENT_FUNC_ARG_STRING, - PEVENT_FUNC_ARG_PTR, - PEVENT_FUNC_ARG_MAX_TYPES +enum tep_func_arg_type { + TEP_FUNC_ARG_VOID, + TEP_FUNC_ARG_INT, + TEP_FUNC_ARG_LONG, + TEP_FUNC_ARG_STRING, + TEP_FUNC_ARG_PTR, + TEP_FUNC_ARG_MAX_TYPES }; enum tep_flag { @@ -524,7 +524,7 @@ struct tep_handle { struct format_field *bprint_buf_field; struct event_handler *handlers; - struct pevent_function_handler *func_handlers; + struct tep_function_handler *func_handlers; /* cache */ struct event_format *last_event; @@ -680,11 +680,11 @@ int pevent_unregister_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, tep_event_handler_func func, void *context); int pevent_register_print_function(struct tep_handle *pevent, - pevent_func_handler func, - enum pevent_func_arg_type ret_type, + tep_func_handler func, + enum tep_func_arg_type ret_type, char *name, ...); int pevent_unregister_print_function(struct tep_handle *pevent, - pevent_func_handler func, char *name); + tep_func_handler func, char *name); struct format_field *tep_find_common_field(struct event_format *event, const char *name); struct format_field *tep_find_field(struct event_format *event, const char *name); diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c index c189bbc9fa18..e0421e31509f 100644 --- a/tools/lib/traceevent/plugin_cfg80211.c +++ b/tools/lib/traceevent/plugin_cfg80211.c @@ -29,10 +29,10 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process___le16_to_cpup, - PEVENT_FUNC_ARG_INT, + TEP_FUNC_ARG_INT, "__le16_to_cpup", - PEVENT_FUNC_ARG_PTR, - PEVENT_FUNC_ARG_VOID); + TEP_FUNC_ARG_PTR, + TEP_FUNC_ARG_VOID); return 0; } diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c index 9b88aebb48a9..6da955ff037e 100644 --- a/tools/lib/traceevent/plugin_jbd2.c +++ b/tools/lib/traceevent/plugin_jbd2.c @@ -51,17 +51,17 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_jbd2_dev_to_name, - PEVENT_FUNC_ARG_STRING, + TEP_FUNC_ARG_STRING, "jbd2_dev_to_name", - PEVENT_FUNC_ARG_INT, - PEVENT_FUNC_ARG_VOID); + TEP_FUNC_ARG_INT, + TEP_FUNC_ARG_VOID); pevent_register_print_function(pevent, process_jiffies_to_msecs, - PEVENT_FUNC_ARG_LONG, + TEP_FUNC_ARG_LONG, "jiffies_to_msecs", - PEVENT_FUNC_ARG_LONG, - PEVENT_FUNC_ARG_VOID); + TEP_FUNC_ARG_LONG, + TEP_FUNC_ARG_VOID); return 0; } diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index d71bc3fde75b..c20f743edf1f 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -479,10 +479,10 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) pevent_register_print_function(pevent, process_is_writable_pte, - PEVENT_FUNC_ARG_INT, + TEP_FUNC_ARG_INT, "is_writable_pte", - PEVENT_FUNC_ARG_LONG, - PEVENT_FUNC_ARG_VOID); + TEP_FUNC_ARG_LONG, + TEP_FUNC_ARG_VOID); return 0; } diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index bb9aea6fb000..ce38df7ed4d8 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c @@ -417,12 +417,12 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_scsi_trace_parse_cdb, - PEVENT_FUNC_ARG_STRING, + TEP_FUNC_ARG_STRING, "scsi_trace_parse_cdb", - PEVENT_FUNC_ARG_PTR, - PEVENT_FUNC_ARG_PTR, - PEVENT_FUNC_ARG_INT, - PEVENT_FUNC_ARG_VOID); + TEP_FUNC_ARG_PTR, + TEP_FUNC_ARG_PTR, + TEP_FUNC_ARG_INT, + TEP_FUNC_ARG_VOID); return 0; } diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c index 1973dd8abbfd..2ffbd91d5bb7 100644 --- a/tools/lib/traceevent/plugin_xen.c +++ b/tools/lib/traceevent/plugin_xen.c @@ -123,10 +123,10 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) { pevent_register_print_function(pevent, process_xen_hypercall_name, - PEVENT_FUNC_ARG_STRING, + TEP_FUNC_ARG_STRING, "xen_hypercall_name", - PEVENT_FUNC_ARG_INT, - PEVENT_FUNC_ARG_VOID); + TEP_FUNC_ARG_INT, + TEP_FUNC_ARG_VOID); return 0; } -- cgit v1.2.3 From ca2921dd90268dc37cd5096eb985da4288aa7041 Mon Sep 17 00:00:00 2001 From: "Tzvetomir Stoyanov (VMware)" Date: Wed, 8 Aug 2018 14:03:00 -0400 Subject: tools lib traceevent, perf tools: Rename traceevent_plugin_* APIs In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_" and not "traceevent_". This changes APIs: traceevent_plugin_list_options, traceevent_plugin_free_options_list, traceevent_plugin_add_options, traceevent_plugin_remove_options, traceevent_print_plugins Signed-off-by: Tzvetomir Stoyanov (VMware) Cc: Andrew Morton Cc: Peter Zijlstra Cc: Yordan Karadzhov (VMware) Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180808180702.089951638@goodmis.org Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.h | 16 ++++++++-------- tools/lib/traceevent/event-plugin.c | 28 ++++++++++++++-------------- tools/lib/traceevent/plugin_function.c | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 81f34132fc47..ec327849a7dc 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -438,14 +438,14 @@ struct plugin_list; struct plugin_list *tep_load_plugins(struct tep_handle *pevent); void tep_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent); -char **traceevent_plugin_list_options(void); -void traceevent_plugin_free_options_list(char **list); -int traceevent_plugin_add_options(const char *name, - struct tep_plugin_option *options); -void traceevent_plugin_remove_options(struct tep_plugin_option *options); -void traceevent_print_plugins(struct trace_seq *s, - const char *prefix, const char *suffix, - const struct plugin_list *list); +char **tep_plugin_list_options(void); +void tep_plugin_free_options_list(char **list); +int tep_plugin_add_options(const char *name, + struct tep_plugin_option *options); +void tep_plugin_remove_options(struct tep_plugin_option *options); +void tep_print_plugins(struct trace_seq *s, + const char *prefix, const char *suffix, + const struct plugin_list *list); struct cmdline; struct cmdline_list; diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index c837a73c03e6..8e324ed46547 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -97,7 +97,7 @@ static int update_option_value(struct tep_plugin_option *op, const char *val) } /** - * traceevent_plugin_list_options - get list of plugin options + * tep_plugin_list_options - get list of plugin options * * Returns an array of char strings that list the currently registered * plugin options in the format of :