From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Paul Mackerras <paulus@samba.org>,
Stephane Eranian <eranian@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Thomas Gleixner <tglx@linutronix.de>,
Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Subject: [RFC PATCH 4/4] perf: New --enable-on-starter option
Date: Mon, 14 Mar 2011 20:18:03 +0100 [thread overview]
Message-ID: <1300130283-10466-5-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1300130283-10466-1-git-send-email-fweisbec@gmail.com>
The new --enable-on-starter option can be used to perf record
and perf stat in order to get the event that precedes to be
started only once the starter fires. It won't count or sample
before.
starter/stopper events without --enable-on-starter must be
typically used to count everywhere but outside a pair of
events boundaries whereas the use of --enable-on-starter
should be rather used to count nowhere but inside the
pair of events boundaries.
Counting only outside softirqs:
perf stat -e irq:softirq_exit -e irq:softirq_entry \
-e instructions --starter 0 --stopper 1
Counting only inside softirqs:
perf stat -e irq:softirq_entry -e irq:softirq_exit \
-e instructions --starter 0 --stopper 1 --enable-on-starter
The following example shows a more complicated example, have three
instruction counters:
* One that counts instructions only when we hold the runqueue lock
* One that counts instructions only when we don't hold the
runqueue lock.
* One that always count instructions
./perf stat -e lock:lock_acquire --filter "name==\"&rq->lock\"" \
-e lock:lock_release --filter "name==\"&rq->lock\"" \
-e instructions --starter 0 --stopper 1 --enable-on-starter \
-e instructions --starter 1 --stopper 0 -e instructions ./perf bench sched messaging
# Running sched/messaging benchmark...
# 20 sender and receiver processes per group
# 10 groups == 400 processes run
Total time: 1.636 [sec]
Performance counter stats for './perf bench sched messaging':
2 274 lock:lock_acquire
2 234 lock:lock_release
9 601 767 instructions # 0,000 IPC <-- inside lock
482 273 822 instructions # 0,000 IPC <-- outside lock
490 646 837 instructions # 0,000 IPC <-- all
1,787294881 seconds time elapsed
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
---
tools/perf/builtin-record.c | 2 ++
tools/perf/builtin-stat.c | 2 ++
tools/perf/util/parse-events.c | 20 ++++++++++++++++++++
tools/perf/util/parse-events.h | 1 +
4 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7cc690e..272f0e4 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -745,6 +745,8 @@ const struct option record_options[] = {
"event starter", parse_starter),
OPT_CALLBACK(0, "stopper", &evsel_list, "stopper",
"event stopper", parse_stopper),
+ OPT_CALLBACK_NOOPT(0, "enable-on-starter", &evsel_list, "enable-on-starter",
+ "enable-on-starter", parse_enable_on_starter),
OPT_INTEGER('p', "pid", &target_pid,
"record events on existing process id"),
OPT_INTEGER('t', "tid", &target_tid,
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index ba89a4d..84f9e7f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -658,6 +658,8 @@ static const struct option options[] = {
"event starter", parse_starter),
OPT_CALLBACK(0, "stopper", &evsel_list, "stopper",
"event stopper", parse_stopper),
+ OPT_CALLBACK_NOOPT(0, "enable-on-starter", &evsel_list, "enable-on-starter",
+ "enable-on-starter", parse_enable_on_starter),
OPT_BOOLEAN('i', "no-inherit", &no_inherit,
"child tasks do not inherit counters"),
OPT_INTEGER('p', "pid", &target_pid,
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 7dd494f..ce5cf10 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -845,6 +845,26 @@ int parse_filter(const struct option *opt, const char *str,
return 0;
}
+int parse_enable_on_starter(const struct option *opt, const char __used *str,
+ int unset __used)
+{
+ struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
+ struct perf_evsel *last = NULL;
+
+ if (evlist->nr_entries > 0)
+ last = list_entry(evlist->entries.prev, struct perf_evsel, node);
+
+ if (last == NULL) {
+ fprintf(stderr,
+ "--enable-on-starter option should follow a -e tracepoint option\n");
+ return -1;
+ }
+
+ last->attr.enable_on_starter = 1;
+
+ return 0;
+}
+
static int parse_starter_stopper(const struct option *opt,
const char *str, int starter)
{
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 72d73b5..262ebc8 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -27,6 +27,7 @@ extern int parse_events(const struct option *opt, const char *str, int unset);
extern int parse_filter(const struct option *opt, const char *str, int unset);
extern int parse_starter(const struct option *opt, const char *str, int unset);
extern int parse_stopper(const struct option *opt, const char *str, int unset);
+extern int parse_enable_on_starter(const struct option *opt, const char *str, int unset);
#define EVENTS_HELP_MAX (128*1024)
--
1.7.3.2
next prev parent reply other threads:[~2011-03-14 19:18 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-14 19:17 [RFC PATCH 0/4] perf: Custom contexts Frederic Weisbecker
2011-03-14 19:18 ` [RFC PATCH 1/4] perf: Starter and stopper events Frederic Weisbecker
2011-03-15 14:36 ` Lin Ming
2011-03-15 17:54 ` Frederic Weisbecker
2011-03-16 14:21 ` Frederic Weisbecker
2011-03-14 19:18 ` [RFC PATCH 3/4] perf: Support for starter and stopper in tools Frederic Weisbecker
2011-03-14 19:18 ` Frederic Weisbecker [this message]
2011-03-14 20:43 ` [RFC PATCH 0/4] perf: Custom contexts Arnaldo Carvalho de Melo
2011-03-14 20:51 ` Frederic Weisbecker
2011-03-14 21:03 ` Arnaldo Carvalho de Melo
2011-03-14 21:20 ` Frederic Weisbecker
2011-03-14 21:56 ` Arnaldo Carvalho de Melo
2011-03-14 22:19 ` Arnaldo Carvalho de Melo
2011-03-14 22:43 ` Frederic Weisbecker
2011-03-14 23:02 ` Arnaldo Carvalho de Melo
2011-03-15 18:58 ` Frederic Weisbecker
2011-03-15 19:24 ` Arnaldo Carvalho de Melo
2011-03-16 1:03 ` Frederic Weisbecker
2011-03-16 15:47 ` Masami Hiramatsu
2011-03-16 17:53 ` Arnaldo Carvalho de Melo
2011-03-16 18:02 ` Peter Zijlstra
2011-03-15 22:32 ` Peter Zijlstra
2011-03-16 13:53 ` Frederic Weisbecker
2011-03-16 13:56 ` Peter Zijlstra
2011-03-16 14:02 ` Frederic Weisbecker
2011-03-16 14:31 ` Peter Zijlstra
2011-03-25 14:47 ` Frederic Weisbecker
2011-03-25 15:03 ` Peter Zijlstra
2011-04-13 14:27 ` Frederic Weisbecker
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=1300130283-10466-5-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=mitake@dcl.info.waseda.ac.jp \
--cc=paulus@samba.org \
--cc=rostedt@goodmis.org \
--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
all inboxes | Powered by JetHome®