This patch adds the support to delete SDT events from the cache.
To delete an event corresponding to a file, first the cache is read into
the file_hash list. The key is calculated from the file name.
And then, the file_list for that file_hash entry is traversed to find out
the target file_list entry. Once, it is found, its contents are all freed up.
# ./perf sdt-cache --del /usr/lib64/libc-2.16.so
8 events removed for /usr/lib64/libc-2.16.so!
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
---
tools/perf/builtin-sdt-cache.c | 28 +++++++++++++++++++++++++++-
tools/perf/util/parse-events.h | 1 +
tools/perf/util/sdt.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-sdt-cache.c b/tools/perf/builtin-sdt-cache.c
index 5faf8e5..12276da 100644
--- a/tools/perf/builtin-sdt-cache.c
+++ b/tools/perf/builtin-sdt-cache.c
@@ -16,6 +16,7 @@
/* Session management structure */
static struct {
bool add;
+ bool del;
bool dump;
const char *target;
} params;
@@ -29,6 +30,15 @@ static int opt_add_sdt_events(const struct option *opt __maybe_unused,
return 0;
}
+static int opt_del_sdt_events(const struct option *opt __maybe_unused,
+ const char *str, int unset __maybe_unused)
+{
+ params.del = true;
+ params.target = str;
+
+ return 0;
+}
+
static int opt_show_sdt_events(const struct option *opt __maybe_unused,
const char *str, int unset __maybe_unused)
{
@@ -45,13 +55,17 @@ int cmd_sdt_cache(int argc, const char **argv, const char *prefix __maybe_unused
OPT_CALLBACK('a', "add", NULL, "filename",
"add SDT events from a file.",
opt_add_sdt_events),
+ OPT_CALLBACK('d', "del", NULL, "filename",
+ "Remove SDT events corresponding to a file from the"
+ " sdt cache.",
+ opt_del_sdt_events),
OPT_CALLBACK_NOOPT('s', "dump", NULL, "show SDT events",
"Read SDT events from cache and display.",
opt_show_sdt_events),
OPT_END()
};
const char * const sdt_cache_usage[] = {
- "perf sdt_cache [--add filename | --dump]",
+ "perf sdt_cache [--add filename | --del filename | --dump]",