Commit e607f142 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

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: default avatarNamhyung 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e7895e42
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "util/parse-options.h" #include "util/parse-options.h"
#include "util/probe-finder.h" #include "util/probe-finder.h"
#include "util/probe-event.h" #include "util/probe-event.h"
#include "util/probe-file.h"
#define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*" #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
#define DEFAULT_FUNC_FILTER "!_*" #define DEFAULT_FUNC_FILTER "!_*"
...@@ -357,6 +358,65 @@ static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs) ...@@ -357,6 +358,65 @@ static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
return ret; return ret;
} }
static int perf_del_probe_events(struct strfilter *filter)
{
int ret, ret2, ufd = -1, kfd = -1;
char *str = strfilter__string(filter);
struct strlist *klist = NULL, *ulist = NULL;
struct str_node *ent;
if (!str)
return -EINVAL;
pr_debug("Delete filter: \'%s\'\n", str);
/* Get current event names */
ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW);
if (ret < 0)
goto out;
klist = strlist__new(NULL, NULL);
if (!klist)
return -ENOMEM;
ret = probe_file__get_events(kfd, filter, klist);
if (ret == 0) {
strlist__for_each(ent, klist)
pr_info("Removed event: %s\n", ent->s);
ret = probe_file__del_strlist(kfd, klist);
if (ret < 0)
goto error;
}
ret2 = probe_file__get_events(ufd, filter, ulist);
if (ret2 == 0) {
strlist__for_each(ent, ulist)
pr_info("Removed event: %s\n", ent->s);
ret2 = probe_file__del_strlist(ufd, ulist);
if (ret2 < 0)
goto error;
}
if (ret == -ENOENT && ret2 == -ENOENT)
pr_debug("\"%s\" does not hit any event.\n", str);
/* Note that this is silently ignored */
ret = 0;
error:
if (kfd >= 0)
close(kfd);
if (ufd >= 0)
close(ufd);
out:
strlist__delete(klist);
strlist__delete(ulist);
free(str);
return ret;
}
static int static int
__cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
{ {
...@@ -529,7 +589,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -529,7 +589,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
return ret; return ret;
#endif #endif
case 'd': case 'd':
ret = del_perf_probe_events(params.filter); ret = perf_del_probe_events(params.filter);
if (ret < 0) { if (ret < 0) {
pr_err_with_code(" Error: Failed to delete events.", ret); pr_err_with_code(" Error: Failed to delete events.", ret);
return ret; return ret;
......
...@@ -2819,8 +2819,6 @@ int del_perf_probe_events(struct strfilter *filter) ...@@ -2819,8 +2819,6 @@ int del_perf_probe_events(struct strfilter *filter)
if (!str) if (!str)
return -EINVAL; return -EINVAL;
pr_debug("Delete filter: \'%s\'\n", str);
/* Get current event names */ /* Get current event names */
ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW); ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW);
if (ret < 0) if (ret < 0)
...@@ -2835,9 +2833,6 @@ int del_perf_probe_events(struct strfilter *filter) ...@@ -2835,9 +2833,6 @@ int del_perf_probe_events(struct strfilter *filter)
ret = ret2; ret = ret2;
goto error; goto error;
} }
if (ret == -ENOENT && ret2 == -ENOENT)
pr_debug("\"%s\" does not hit any event.\n", str);
/* Note that this is silently ignored */
ret = 0; ret = 0;
error: error:
......
...@@ -144,6 +144,7 @@ extern int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs); ...@@ -144,6 +144,7 @@ extern int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
extern int del_perf_probe_events(struct strfilter *filter); extern int del_perf_probe_events(struct strfilter *filter);
extern int show_perf_probe_event(const char *group, const char *event, extern int show_perf_probe_event(const char *group, const char *event,
struct perf_probe_event *pev, struct perf_probe_event *pev,
const char *module, bool use_stdout); const char *module, bool use_stdout);
......
...@@ -267,7 +267,6 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) ...@@ -267,7 +267,6 @@ static int __del_trace_probe_event(int fd, struct str_node *ent)
goto error; goto error;
} }
pr_info("Removed event: %s\n", ent->s);
return 0; return 0;
error: error:
pr_warning("Failed to delete event: %s\n", pr_warning("Failed to delete event: %s\n",
...@@ -275,7 +274,7 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) ...@@ -275,7 +274,7 @@ static int __del_trace_probe_event(int fd, struct str_node *ent)
return ret; return ret;
} }
static int probe_file__get_events(int fd, struct strfilter *filter, int probe_file__get_events(int fd, struct strfilter *filter,
struct strlist *plist) struct strlist *plist)
{ {
struct strlist *namelist; struct strlist *namelist;
...@@ -300,7 +299,7 @@ static int probe_file__get_events(int fd, struct strfilter *filter, ...@@ -300,7 +299,7 @@ static int probe_file__get_events(int fd, struct strfilter *filter,
return ret; return ret;
} }
static int probe_file__del_strlist(int fd, struct strlist *namelist) int probe_file__del_strlist(int fd, struct strlist *namelist)
{ {
int ret = 0; int ret = 0;
struct str_node *ent; struct str_node *ent;
......
...@@ -14,5 +14,9 @@ struct strlist *probe_file__get_namelist(int fd); ...@@ -14,5 +14,9 @@ struct strlist *probe_file__get_namelist(int fd);
struct strlist *probe_file__get_rawlist(int fd); struct strlist *probe_file__get_rawlist(int fd);
int probe_file__add_event(int fd, struct probe_trace_event *tev); int probe_file__add_event(int fd, struct probe_trace_event *tev);
int probe_file__del_events(int fd, struct strfilter *filter); int probe_file__del_events(int fd, struct strfilter *filter);
int probe_file__get_events(int fd, struct strfilter *filter,
struct strlist *plist);
int probe_file__del_strlist(int fd, struct strlist *namelist);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment