All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: masami.hiramatsu.pt@hitachi.com, acme@redhat.com,
	namhyung@kernel.org, linux-kernel@vger.kernel.org,
	a.p.zijlstra@chello.nl, hpa@zytor.com, mingo@kernel.org,
	tglx@linutronix.de, wangnan0@huawei.com, jolsa@redhat.com
Subject: [tip:perf/core] perf probe: Split del_perf_probe_events()
Date: Tue, 8 Sep 2015 07:40:03 -0700	[thread overview]
Message-ID: <tip-e7895e422e4da63daedacad0a2ed1a5a6b502d66@git.kernel.org> (raw)
In-Reply-To: <1441368963-11565-4-git-send-email-namhyung@kernel.org>

Commit-ID:  e7895e422e4da63daedacad0a2ed1a5a6b502d66
Gitweb:     http://git.kernel.org/tip/e7895e422e4da63daedacad0a2ed1a5a6b502d66
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 4 Sep 2015 21:16:02 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 4 Sep 2015 12:43:19 -0300

perf probe: Split del_perf_probe_events()

The del_perf_probe_events() does 2 things:

1. find existing events which match to filter
2. delete such trace events from kernel

But sometimes we need to do something with the trace events.  So split
the funtion into two, so that it can access intermediate trace events
name using strlist if needed.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jiri Olsa <jolsa@redhat.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-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-file.c | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index bbb2437..f00b0df 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -275,7 +275,8 @@ error:
 	return ret;
 }
 
-int probe_file__del_events(int fd, struct strfilter *filter)
+static int probe_file__get_events(int fd, struct strfilter *filter,
+				  struct strlist *plist)
 {
 	struct strlist *namelist;
 	struct str_node *ent;
@@ -290,12 +291,43 @@ int probe_file__del_events(int fd, struct strfilter *filter)
 		p = strchr(ent->s, ':');
 		if ((p && strfilter__compare(filter, p + 1)) ||
 		    strfilter__compare(filter, ent->s)) {
-			ret = __del_trace_probe_event(fd, ent);
-			if (ret < 0)
-				break;
+			strlist__add(plist, ent->s);
+			ret = 0;
 		}
 	}
 	strlist__delete(namelist);
 
 	return ret;
 }
+
+static int probe_file__del_strlist(int fd, struct strlist *namelist)
+{
+	int ret = 0;
+	struct str_node *ent;
+
+	strlist__for_each(ent, namelist) {
+		ret = __del_trace_probe_event(fd, ent);
+		if (ret < 0)
+			break;
+	}
+	return ret;
+}
+
+int probe_file__del_events(int fd, struct strfilter *filter)
+{
+	struct strlist *namelist;
+	int ret;
+
+	namelist = strlist__new(NULL, NULL);
+	if (!namelist)
+		return -ENOMEM;
+
+	ret = probe_file__get_events(fd, filter, namelist);
+	if (ret < 0)
+		return ret;
+
+	ret = probe_file__del_strlist(fd, namelist);
+	strlist__delete(namelist);
+
+	return ret;
+}

  reply	other threads:[~2015-09-08 14:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 12:15 [PATCH v2 1/5] perf probe: Split add_perf_probe_events() Namhyung Kim
2015-09-04 12:16 ` [PATCH v2 2/5] perf probe: Attach trace_probe_event with perf_probe_event Namhyung Kim
2015-09-08 14:39   ` [tip:perf/core] perf probe: Link trace_probe_event into perf_probe_event tip-bot for Wang Nan
2015-09-04 12:16 ` [PATCH v2 3/5] perf probe: Move print logic into cmd_probe() Namhyung Kim
2015-09-08 14:39   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-04 12:16 ` [PATCH v2 4/5] perf probe: Split del_perf_probe_events() Namhyung Kim
2015-09-08 14:40   ` tip-bot for Namhyung Kim [this message]
2015-09-04 12:16 ` [PATCH v2 5/5] perf probe: Print deleted events in cmd_probe() Namhyung Kim
2015-09-07  1:12   ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-08 14:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-06  7:47 ` [PATCH v2 1/5] perf probe: Split add_perf_probe_events() Wangnan (F)
2015-09-08  1:53   ` Namhyung Kim
2015-09-10  2:23   ` Namhyung Kim
2015-09-10  5:00     ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-10  6:40       ` Namhyung Kim
2015-09-10  8:10         ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-11 16:29           ` Namhyung Kim
2015-09-08 14:39 ` [tip:perf/core] " tip-bot for Namhyung Kim

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=tip-e7895e422e4da63daedacad0a2ed1a5a6b502d66@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.