From: Hemant Kumar <hemant@linux.vnet.ibm.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: linux-kernel@vger.kernel.org, srikar@linux.vnet.ibm.com,
peterz@infradead.org, oleg@redhat.com,
hegdevasant@linux.vnet.ibm.com, mingo@redhat.com,
anton@redhat.com, systemtap@sourceware.org,
masami.hiramatsu.pt@hitachi.com,
aravinda@linux.vnet.ibm.com, penberg@iki.fi
Subject: Re: [PATCH v2 4/5] perf/sdt: Delete SDT events from cache
Date: Tue, 07 Oct 2014 06:25:00 -0000 [thread overview]
Message-ID: <5433872B.1080405@linux.vnet.ibm.com> (raw)
In-Reply-To: <87egukh8lq.fsf@sejong.aot.lge.com>
On 10/07/2014 08:47 AM, Namhyung Kim wrote:
> On Wed, 01 Oct 2014 08:18:41 +0530, Hemant Kumar wrote:
>> 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]",
> I think it'd be better split the usage into two lines:
>
> "perf sdt_cache [--add | --del] <filename>"
> "perf sdt_cache --dump"
Nice suggestion. Will change that.
>
>> NULL
>> };
>>
>> @@ -63,6 +77,10 @@ int cmd_sdt_cache(int argc, const char **argv, const char *prefix __maybe_unused
>>
>> symbol__elf_init();
>> if (params.add) {
>> + if (params.del) {
>> + pr_err("Error: Don't use --del with --add\n");
>> + usage_with_options(sdt_cache_usage, sdt_cache_options);
>> + }
>> if (params.dump) {
>> pr_err("Error: Don't use --dump with --add\n");
>> usage_with_options(sdt_cache_usage, sdt_cache_options);
>> @@ -70,6 +88,14 @@ int cmd_sdt_cache(int argc, const char **argv, const char *prefix __maybe_unused
>> ret = add_sdt_events(params.target);
>> if (ret < 0)
>> pr_err("Cannot add SDT events to cache!\n");
>> + } else if (params.del) {
>> + if (params.dump) {
>> + pr_err("Error: Don't use --dump with --del\n");
>> + usage_with_options(sdt_cache_usage, sdt_cache_options);
>> + }
>> + ret = remove_sdt_events(params.target);
>> + if (ret < 0)
>> + pr_err("Cannot remove SDT events from cache!\n");
>> } else if (params.dump) {
>> if (argc == 0) {
>> ret = dump_sdt_events();
> I think we need to a flag for exclusive options so that it can emit
> warnings like this automatically during option parsing.
Ok.
> Thanks,
> Namhyung
>
> [...]
--
Thanks,
Hemant Kumar
next prev parent reply other threads:[~2014-10-07 6:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 17:37 [PATCH v2 0/5] perf/sdt: SDT events listing/probing Hemant Kumar
2014-10-01 17:38 ` [PATCH v2 1/5] perf/sdt: ELF support for SDT Hemant Kumar
2014-10-03 11:39 ` Masami Hiramatsu
2014-10-05 8:17 ` Hemant Kumar
2014-10-07 2:20 ` Namhyung Kim
2014-10-07 6:10 ` Hemant Kumar
2014-10-01 17:39 ` [PATCH v2 3/5] perf/sdt: Show SDT cache contents Hemant Kumar
2014-10-03 12:52 ` Masami Hiramatsu
2014-10-03 12:55 ` Masami Hiramatsu
2014-10-05 8:18 ` Hemant Kumar
2014-10-01 17:40 ` [PATCH v2 5/5] perf/sdt: Add support to perf record to trace SDT events Hemant Kumar
2014-10-01 17:40 ` [PATCH v2 4/5] perf/sdt: Delete SDT events from cache Hemant Kumar
2014-10-07 3:17 ` Namhyung Kim
2014-10-07 6:25 ` Hemant Kumar [this message]
2014-10-01 17:40 ` [PATCH v2 2/5] perf/sdt: Add SDT events into a cache Hemant Kumar
2014-10-07 3:00 ` Namhyung Kim
2014-10-07 6:23 ` Hemant Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5433872B.1080405@linux.vnet.ibm.com \
--to=hemant@linux.vnet.ibm.com \
--cc=anton@redhat.com \
--cc=aravinda@linux.vnet.ibm.com \
--cc=hegdevasant@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=penberg@iki.fi \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).