mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Masami Hiramatsu <mhiramat@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, acme@redhat.com,
	hpa@zytor.com, mingo@redhat.com, a.p.zijlstra@chello.nl,
	efault@gmx.de, dle-develop@lists.sourceforge.net,
	fweisbec@gmail.com, tglx@linutronix.de, mhiramat@redhat.com,
	mingo@elte.hu, systemtap@sources.redhat.com
Subject: [tip:perf/core] perf probe: Add --dry-run option
Date: Wed, 17 Mar 2010 11:29:22 GMT	[thread overview]
Message-ID: <tip-f4d7da499e4fc1fdff8f26fdeb1a058d475a7a6c@git.kernel.org> (raw)
In-Reply-To: <20100316220605.32050.6571.stgit@localhost6.localdomain6>

Commit-ID:  f4d7da499e4fc1fdff8f26fdeb1a058d475a7a6c
Gitweb:     http://git.kernel.org/tip/f4d7da499e4fc1fdff8f26fdeb1a058d475a7a6c
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Tue, 16 Mar 2010 18:06:05 -0400
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 17 Mar 2010 11:32:31 +0100

perf probe: Add --dry-run option

Add --dry-run option for debugging and testing.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20100316220605.32050.6571.stgit@localhost6.localdomain6>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/Documentation/perf-probe.txt |    5 +++++
 tools/perf/builtin-probe.c              |    1 +
 tools/perf/util/probe-event.c           |   24 ++++++++++++++++--------
 tools/perf/util/probe-event.h           |    2 ++
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index 34202b1..0f944b3 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -57,6 +57,11 @@ OPTIONS
 --force::
 	Forcibly add events with existing name.
 
+-n::
+--dry-run::
+	Dry run. With this option, --add and --del doesn't execute actual
+	adding and removal operations.
+
 PROBE SYNTAX
 ------------
 Probe points are defined by following syntax.
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index f577e14..a1a2891 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -175,6 +175,7 @@ static const struct option options[] = {
 		     "FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]",
 		     "Show source code lines.", opt_show_lines),
 #endif
+	OPT__DRY_RUN(&probe_event_dry_run),
 	OPT_END()
 };
 
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 1e60a65..ac41578 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -49,6 +49,8 @@
 #define MAX_PROBE_ARGS 128
 #define PERFPROBE_GROUP "probe"
 
+bool probe_event_dry_run;	/* Dry run flag */
+
 #define semantic_error(msg ...) die("Semantic error :" msg)
 
 /* If there is no space to write, returns -E2BIG. */
@@ -430,7 +432,7 @@ error:
 	return ret;
 }
 
-static int open_kprobe_events(int flags, int mode)
+static int open_kprobe_events(bool readwrite)
 {
 	char buf[PATH_MAX];
 	int ret;
@@ -439,7 +441,11 @@ static int open_kprobe_events(int flags, int mode)
 	if (ret < 0)
 		die("Failed to make kprobe_events path.");
 
-	ret = open(buf, flags, mode);
+	if (readwrite && !probe_event_dry_run)
+		ret = open(buf, O_RDWR, O_APPEND);
+	else
+		ret = open(buf, O_RDONLY, 0);
+
 	if (ret < 0) {
 		if (errno == ENOENT)
 			die("kprobe_events file does not exist -"
@@ -535,7 +541,7 @@ void show_perf_probe_events(void)
 	setup_pager();
 	memset(&pp, 0, sizeof(pp));
 
-	fd = open_kprobe_events(O_RDONLY, 0);
+	fd = open_kprobe_events(false);
 	rawlist = get_trace_kprobe_event_rawlist(fd);
 	close(fd);
 
@@ -585,9 +591,11 @@ static void write_trace_kprobe_event(int fd, const char *buf)
 	int ret;
 
 	pr_debug("Writing event: %s\n", buf);
-	ret = write(fd, buf, strlen(buf));
-	if (ret <= 0)
-		die("Failed to write event: %s", strerror(errno));
+	if (!probe_event_dry_run) {
+		ret = write(fd, buf, strlen(buf));
+		if (ret <= 0)
+			die("Failed to write event: %s", strerror(errno));
+	}
 }
 
 static void get_new_event_name(char *buf, size_t len, const char *base,
@@ -630,7 +638,7 @@ static void __add_trace_kprobe_events(struct probe_point *probes,
 	struct strlist *namelist;
 	bool allow_suffix;
 
-	fd = open_kprobe_events(O_RDWR, O_APPEND);
+	fd = open_kprobe_events(true);
 	/* Get current event names */
 	namelist = get_perf_event_names(fd, false);
 
@@ -814,7 +822,7 @@ void del_trace_kprobe_events(struct strlist *dellist)
 	struct str_node *ent;
 	struct strlist *namelist;
 
-	fd = open_kprobe_events(O_RDWR, O_APPEND);
+	fd = open_kprobe_events(true);
 	/* Get current event names */
 	namelist = get_perf_event_names(fd, true);
 
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 3865e16..703b887 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -5,6 +5,8 @@
 #include "probe-finder.h"
 #include "strlist.h"
 
+extern bool probe_event_dry_run;
+
 extern void parse_line_range_desc(const char *arg, struct line_range *lr);
 extern void parse_perf_probe_event(const char *str, struct probe_point *pp,
 				   bool *need_dwarf);

  reply	other threads:[~2010-03-17 11:30 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 22:05 [PATCH -tip 00/10] perf-probe updates - data-structure support, etc Masami Hiramatsu
2010-03-16 22:05 ` [PATCH -tip 01/10] perf tools: Introduce xzalloc() for detecting out of memory Masami Hiramatsu
2010-03-17 11:27   ` [tip:perf/core] perf tools: Introduce xzalloc() for detecting out of memory conditions tip-bot for Masami Hiramatsu
2010-03-16 22:05 ` [PATCH -tip 02/10] perf probe: Use wrapper functions Masami Hiramatsu
2010-03-17 11:27   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-03-16 22:05 ` [PATCH -tip 03/10] perf probe: Move add-probe routine under util/ Masami Hiramatsu
2010-03-17 11:28   ` [tip:perf/core] perf probe: Move add-probe routine to util/ tip-bot for Masami Hiramatsu
2010-03-16 22:05 ` [PATCH -tip 04/10] perf probe: Rename session to param Masami Hiramatsu
2010-03-17 11:28   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-03-16 22:05 ` [PATCH -tip 05/10] perf probe: Rename some die_get_* functions Masami Hiramatsu
2010-03-17 11:28   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-03-16 22:05 ` [PATCH -tip 06/10] perf probe: Introduce die_find_child() function Masami Hiramatsu
2010-03-17 11:29   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-03-16 22:06 ` [PATCH -tip 07/10] perf probe: Add --dry-run option Masami Hiramatsu
2010-03-17 11:29   ` tip-bot for Masami Hiramatsu [this message]
2010-03-16 22:06 ` [PATCH -tip 08/10] perf probe: Introduce kprobe_trace_event and perf_probe_event Masami Hiramatsu
2010-03-17 11:29   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-03-17 11:30   ` [tip:perf/core] perf probe: Fix !dwarf build tip-bot for Ingo Molnar
2010-03-17 14:14     ` Masami Hiramatsu
2010-03-18 17:38   ` [tip:perf/core] perf events: Fix false positive build warning with older GCC's tip-bot for Ingo Molnar
2010-03-18 20:03     ` Masami Hiramatsu
2010-03-16 22:06 ` [PATCH -tip 09/10] perf probe: List probes with line number and file name Masami Hiramatsu
2010-03-17 11:29   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-03-16 22:06 ` [PATCH -tip 10/10] perf probe: Accessing members in data structures Masami Hiramatsu
2010-03-17 10:25   ` Mark Wielaard
2010-03-17 19:14     ` Masami Hiramatsu
2010-03-18  3:28       ` Frederic Weisbecker
2010-03-20  4:20         ` Masami Hiramatsu
2010-03-23 15:55         ` Peter Zijlstra
2010-03-23 16:27           ` Arnaldo Carvalho de Melo
2010-03-17 11:30   ` [tip:perf/core] perf probe: Add data structure member access support tip-bot for Masami Hiramatsu
2010-03-17 10:34 ` [PATCH -tip 00/10] perf-probe updates - data-structure support, etc Ingo Molnar

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-f4d7da499e4fc1fdff8f26fdeb1a058d475a7a6c@git.kernel.org \
    --to=mhiramat@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=efault@gmx.de \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=systemtap@sources.redhat.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome