Commit 39876e7dd385e0f0a438ee0ab13cf75a4f5e0e3b
1 parent
de332ac40f
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
perf evlist: Introduce add_newtp method
To reduce the boilerplate of creating and adding a new tracepoint to an evlist. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-4z90i79gnmsza2czv2dhdrb7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Showing 3 changed files with 20 additions and 15 deletions Side-by-side Diff
tools/perf/builtin-trace.c
... | ... | @@ -200,23 +200,11 @@ |
200 | 200 | goto out; |
201 | 201 | } |
202 | 202 | |
203 | - evsel = perf_evsel__newtp("raw_syscalls", "sys_enter", 0); | |
204 | - if (evsel == NULL) { | |
205 | - printf("Couldn't read the raw_syscalls:sys_enter tracepoint information!\n"); | |
203 | + if (perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_enter", trace__sys_enter) || | |
204 | + perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_exit", trace__sys_exit)) { | |
205 | + printf("Couldn't read the raw_syscalls tracepoints information!\n"); | |
206 | 206 | goto out_delete_evlist; |
207 | 207 | } |
208 | - | |
209 | - evsel->handler.func = trace__sys_enter; | |
210 | - perf_evlist__add(evlist, evsel); | |
211 | - | |
212 | - evsel = perf_evsel__newtp("raw_syscalls", "sys_exit", 1); | |
213 | - if (evsel == NULL) { | |
214 | - printf("Couldn't read the raw_syscalls:sys_exit tracepoint information!\n"); | |
215 | - goto out_delete_evlist; | |
216 | - } | |
217 | - | |
218 | - evsel->handler.func = trace__sys_exit; | |
219 | - perf_evlist__add(evlist, evsel); | |
220 | 208 | |
221 | 209 | err = perf_evlist__create_maps(evlist, &trace->opts.target); |
222 | 210 | if (err < 0) { |
tools/perf/util/evlist.c
... | ... | @@ -285,6 +285,20 @@ |
285 | 285 | return err; |
286 | 286 | } |
287 | 287 | |
288 | +int perf_evlist__add_newtp(struct perf_evlist *evlist, | |
289 | + const char *sys, const char *name, void *handler) | |
290 | +{ | |
291 | + struct perf_evsel *evsel; | |
292 | + | |
293 | + evsel = perf_evsel__newtp(sys, name, evlist->nr_entries); | |
294 | + if (evsel == NULL) | |
295 | + return -1; | |
296 | + | |
297 | + evsel->handler.func = handler; | |
298 | + perf_evlist__add(evlist, evsel); | |
299 | + return 0; | |
300 | +} | |
301 | + | |
288 | 302 | void perf_evlist__disable(struct perf_evlist *evlist) |
289 | 303 | { |
290 | 304 | int cpu, thread; |
tools/perf/util/evlist.h
... | ... | @@ -72,6 +72,9 @@ |
72 | 72 | #define perf_evlist__set_tracepoints_handlers_array(evlist, array) \ |
73 | 73 | perf_evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array)) |
74 | 74 | |
75 | +int perf_evlist__add_newtp(struct perf_evlist *evlist, | |
76 | + const char *sys, const char *name, void *handler); | |
77 | + | |
75 | 78 | int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter); |
76 | 79 | |
77 | 80 | struct perf_evsel * |