Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf probe: Print deleted events in cmd_probe()

Showing actual trace event when deleteing perf events is only needed in
perf probe command. But the add functionality itself can be used by
other places. So move the printing code into the cmd_probe().

The output is not changed.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1441368963-11565-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
e607f142 e7895e42

+69 -10
+61 -1
tools/perf/builtin-probe.c
··· 41 41 #include "util/parse-options.h" 42 42 #include "util/probe-finder.h" 43 43 #include "util/probe-event.h" 44 + #include "util/probe-file.h" 44 45 45 46 #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*" 46 47 #define DEFAULT_FUNC_FILTER "!_*" ··· 358 357 return ret; 359 358 } 360 359 360 + static int perf_del_probe_events(struct strfilter *filter) 361 + { 362 + int ret, ret2, ufd = -1, kfd = -1; 363 + char *str = strfilter__string(filter); 364 + struct strlist *klist = NULL, *ulist = NULL; 365 + struct str_node *ent; 366 + 367 + if (!str) 368 + return -EINVAL; 369 + 370 + pr_debug("Delete filter: \'%s\'\n", str); 371 + 372 + /* Get current event names */ 373 + ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW); 374 + if (ret < 0) 375 + goto out; 376 + 377 + klist = strlist__new(NULL, NULL); 378 + if (!klist) 379 + return -ENOMEM; 380 + 381 + ret = probe_file__get_events(kfd, filter, klist); 382 + if (ret == 0) { 383 + strlist__for_each(ent, klist) 384 + pr_info("Removed event: %s\n", ent->s); 385 + 386 + ret = probe_file__del_strlist(kfd, klist); 387 + if (ret < 0) 388 + goto error; 389 + } 390 + 391 + ret2 = probe_file__get_events(ufd, filter, ulist); 392 + if (ret2 == 0) { 393 + strlist__for_each(ent, ulist) 394 + pr_info("Removed event: %s\n", ent->s); 395 + 396 + ret2 = probe_file__del_strlist(ufd, ulist); 397 + if (ret2 < 0) 398 + goto error; 399 + } 400 + 401 + if (ret == -ENOENT && ret2 == -ENOENT) 402 + pr_debug("\"%s\" does not hit any event.\n", str); 403 + /* Note that this is silently ignored */ 404 + ret = 0; 405 + 406 + error: 407 + if (kfd >= 0) 408 + close(kfd); 409 + if (ufd >= 0) 410 + close(ufd); 411 + out: 412 + strlist__delete(klist); 413 + strlist__delete(ulist); 414 + free(str); 415 + 416 + return ret; 417 + } 418 + 361 419 static int 362 420 __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) 363 421 { ··· 589 529 return ret; 590 530 #endif 591 531 case 'd': 592 - ret = del_perf_probe_events(params.filter); 532 + ret = perf_del_probe_events(params.filter); 593 533 if (ret < 0) { 594 534 pr_err_with_code(" Error: Failed to delete events.", ret); 595 535 return ret;
-5
tools/perf/util/probe-event.c
··· 2819 2819 if (!str) 2820 2820 return -EINVAL; 2821 2821 2822 - pr_debug("Delete filter: \'%s\'\n", str); 2823 - 2824 2822 /* Get current event names */ 2825 2823 ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW); 2826 2824 if (ret < 0) ··· 2833 2835 ret = ret2; 2834 2836 goto error; 2835 2837 } 2836 - if (ret == -ENOENT && ret2 == -ENOENT) 2837 - pr_debug("\"%s\" does not hit any event.\n", str); 2838 - /* Note that this is silently ignored */ 2839 2838 ret = 0; 2840 2839 2841 2840 error:
+1
tools/perf/util/probe-event.h
··· 144 144 extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); 145 145 extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); 146 146 extern int del_perf_probe_events(struct strfilter *filter); 147 + 147 148 extern int show_perf_probe_event(const char *group, const char *event, 148 149 struct perf_probe_event *pev, 149 150 const char *module, bool use_stdout);
+3 -4
tools/perf/util/probe-file.c
··· 267 267 goto error; 268 268 } 269 269 270 - pr_info("Removed event: %s\n", ent->s); 271 270 return 0; 272 271 error: 273 272 pr_warning("Failed to delete event: %s\n", ··· 274 275 return ret; 275 276 } 276 277 277 - static int probe_file__get_events(int fd, struct strfilter *filter, 278 - struct strlist *plist) 278 + int probe_file__get_events(int fd, struct strfilter *filter, 279 + struct strlist *plist) 279 280 { 280 281 struct strlist *namelist; 281 282 struct str_node *ent; ··· 299 300 return ret; 300 301 } 301 302 302 - static int probe_file__del_strlist(int fd, struct strlist *namelist) 303 + int probe_file__del_strlist(int fd, struct strlist *namelist) 303 304 { 304 305 int ret = 0; 305 306 struct str_node *ent;
+4
tools/perf/util/probe-file.h
··· 14 14 struct strlist *probe_file__get_rawlist(int fd); 15 15 int probe_file__add_event(int fd, struct probe_trace_event *tev); 16 16 int probe_file__del_events(int fd, struct strfilter *filter); 17 + int probe_file__get_events(int fd, struct strfilter *filter, 18 + struct strlist *plist); 19 + int probe_file__del_strlist(int fd, struct strlist *namelist); 20 + 17 21 18 22 #endif