Skip to contentSkip to conversation

perf tools: Add a per tracepoint counter attribute to get raw sample

PATCH In review Frederic Weisbecker 2 participants 6 messages Aug 13, 2009 – Aug 14, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf tools: Add a per tracepoint counter attribute to get raw sample

Add a new flag field while opening a tracepoint perf counter:

-e tracepoint_subsystem:tracepoint_name:flags

This is intended to be generic although for now it only supports the r[e[c[o[r[d]]]]] flag:

./perf record -e workqueue:workqueue_insertion:record ./perf record -e workqueue:workqueue_insertion:r

will have the same effect: enabling the raw samples record for the given tracepoint counter.

In the future, we may want to support further flags, separated by commas.

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>
---
 tools/perf/builtin-record.c    |    2 +-
 tools/perf/util/parse-events.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
tools/perf/builtin-record.c +1 -1
index 5aeb632..3be0301 100644
@@ -380,7 +380,7 @@ static void create_counter(int counter, int cpu, pid_t pid)
 				  PERF_FORMAT_TOTAL_TIME_RUNNING |
 				  PERF_FORMAT_ID;
 
-	attr->sample_type	= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
+	attr->sample_type	|= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
 
 	if (freq) {
 		attr->sample_type	|= PERF_SAMPLE_PERIOD;
tools/perf/util/parse-events.c +10 -0
index a5d661b..4bab278 100644
@@ -379,6 +379,7 @@ static int parse_tracepoint_event(const char **strp,
 				    struct perf_counter_attr *attr)
 {
 	const char *evt_name;
+	char *flags;
 	char sys_name[MAX_EVENT_LENGTH];
 	char id_buf[4];
 	int fd;
@@ -400,6 +401,15 @@ static int parse_tracepoint_event(const char **strp,
 	strncpy(sys_name, *strp, sys_length);
 	sys_name[sys_length] = '\0';
 	evt_name = evt_name + 1;
+
+	flags = strchr(evt_name, ':');
+	if (flags) {
+		*flags = '\0';
+		flags++;
+		if (!strncmp(flags, "record", strlen(flags)))
+			attr->sample_type |= PERF_SAMPLE_RAW;
+	}
+
 	evt_length = strlen(evt_name);
 	if (evt_length >= MAX_EVENT_LENGTH)
 		return 0;
Signature · 1 line
1.6.2.3
#1 lore raw

PATCH 2/2 perf tools: Add a general option to enable raw sample records

While we can enable the perf sample records per tracepoint counter, we may also want to enable this option for every tracepoint counters to open, so that we don't need to add a :record flag for all of them.

Add the -R, --raw-samples options for this purpose.

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>
---
 tools/perf/builtin-record.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
tools/perf/builtin-record.c +5 -0
index 3be0301..e67c4fa 100644
@@ -35,6 +35,7 @@ static int			output;
 static const char		*output_name			= "perf.data";
 static int			group				= 0;
 static unsigned int		realtime_prio			= 0;
+static int			raw_samples			= 0;
 static int			system_wide			= 0;
 static int			profile_cpu			= -1;
 static pid_t			target_pid			= -1;
@@ -400,6 +401,8 @@ static void create_counter(int counter, int cpu, pid_t pid)
 	if (call_graph)
 		attr->sample_type	|= PERF_SAMPLE_CALLCHAIN;
 
+	if (raw_samples)
+		attr->sample_type	|= PERF_SAMPLE_RAW;
 
 	attr->mmap		= track;
 	attr->comm		= track;
@@ -632,6 +635,8 @@ static const struct option options[] = {
 		    "record events on existing pid"),
 	OPT_INTEGER('r', "realtime", &realtime_prio,
 		    "collect data with this RT SCHED_FIFO priority"),
+	OPT_BOOLEAN('R', "raw-samples", &raw_samples,
+		    "collect raw sample records from all opened counters"),
 	OPT_BOOLEAN('a', "all-cpus", &system_wide,
 			    "system-wide collection from all CPUs"),
 	OPT_BOOLEAN('A', "append", &append_file,
Signature · 1 line
1.6.2.3
#2 lore raw

[tip:perfcounters/urgent] perf tools: Add a general option to enable raw sample records

Commit-ID:  daac07b2e6b77f1bd44104aa2f0593e5505f27d4
Gitweb:     http://git.kernel.org/tip/daac07b2e6b77f1bd44104aa2f0593e5505f27d4
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Thu, 13 Aug 2009 10:27:19 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 13 Aug 2009 10:37:25 +0200

perf tools: Add a general option to enable raw sample records

While we can enable the perf sample records per tracepoint counter, we may also want to enable this option for every tracepoint counters to open, so that we don't need to add a :record flag for all of them.

Add the -R, --raw-samples options for this purpose.

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-record.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
tools/perf/builtin-record.c +5 -0
index 78adc47..3d051b9 100644
@@ -34,6 +34,7 @@ static int			output;
 static const char		*output_name			= "perf.data";
 static int			group				= 0;
 static unsigned int		realtime_prio			= 0;
+static int			raw_samples			= 0;
 static int			system_wide			= 0;
 static int			profile_cpu			= -1;
 static pid_t			target_pid			= -1;
@@ -418,6 +419,8 @@ static void create_counter(int counter, int cpu, pid_t pid)
 	if (call_graph)
 		attr->sample_type	|= PERF_SAMPLE_CALLCHAIN;
 
+	if (raw_samples)
+		attr->sample_type	|= PERF_SAMPLE_RAW;
 
 	attr->mmap		= track;
 	attr->comm		= track;
@@ -650,6 +653,8 @@ static const struct option options[] = {
 		    "record events on existing pid"),
 	OPT_INTEGER('r', "realtime", &realtime_prio,
 		    "collect data with this RT SCHED_FIFO priority"),
+	OPT_BOOLEAN('R', "raw-samples", &raw_samples,
+		    "collect raw sample records from all opened counters"),
 	OPT_BOOLEAN('a', "all-cpus", &system_wide,
 			    "system-wide collection from all CPUs"),
 	OPT_BOOLEAN('A', "append", &append_file,
#3 lore raw
In reply to Frederic Weisbecker
Commit-ID:  3a9f131fb00b8ac5950a11ad1599e45edfb5ae44
Gitweb:     http://git.kernel.org/tip/3a9f131fb00b8ac5950a11ad1599e45edfb5ae44
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Thu, 13 Aug 2009 10:27:18 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 13 Aug 2009 10:37:25 +0200

perf tools: Add a per tracepoint counter attribute to get raw sample

Add a new flag field while opening a tracepoint perf counter:

-e tracepoint_subsystem:tracepoint_name:flags

This is intended to be generic although for now it only supports the r[e[c[o[r[d]]]]] flag:

./perf record -e workqueue:workqueue_insertion:record ./perf record -e workqueue:workqueue_insertion:r

will have the same effect: enabling the raw samples record for the given tracepoint counter.

In the future, we may want to support further flags, separated by commas.

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-record.c    |    2 +-
 tools/perf/util/parse-events.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
tools/perf/builtin-record.c +1 -1
index de76008..78adc47 100644
@@ -398,7 +398,7 @@ static void create_counter(int counter, int cpu, pid_t pid)
 				  PERF_FORMAT_TOTAL_TIME_RUNNING |
 				  PERF_FORMAT_ID;
 
-	attr->sample_type	= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
+	attr->sample_type	|= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
 
 	if (freq) {
 		attr->sample_type	|= PERF_SAMPLE_PERIOD;
tools/perf/util/parse-events.c +10 -0
index 4858d83..0441784 100644
@@ -379,6 +379,7 @@ static int parse_tracepoint_event(const char **strp,
 				    struct perf_counter_attr *attr)
 {
 	const char *evt_name;
+	char *flags;
 	char sys_name[MAX_EVENT_LENGTH];
 	char id_buf[4];
 	int fd;
@@ -400,6 +401,15 @@ static int parse_tracepoint_event(const char **strp,
 	strncpy(sys_name, *strp, sys_length);
 	sys_name[sys_length] = '\0';
 	evt_name = evt_name + 1;
+
+	flags = strchr(evt_name, ':');
+	if (flags) {
+		*flags = '\0';
+		flags++;
+		if (!strncmp(flags, "record", strlen(flags)))
+			attr->sample_type |= PERF_SAMPLE_RAW;
+	}
+
 	evt_length = strlen(evt_name);
 	if (evt_length >= MAX_EVENT_LENGTH)
 		return 0;
#4 lore raw
In reply to Frederic Weisbecker

Em Thu, Aug 13, 2009 at 10:27:18AM +0200, Frederic Weisbecker escreveu:

Quoted 7 lines

Add a new flag field while opening a tracepoint perf counter:

-e tracepoint_subsystem:tracepoint_name:flags

This is intended to be generic although for now it only supports the r[e[c[o[r[d]]]]] flag:

Quoted 8 lines

./perf record -e workqueue:workqueue_insertion:record ./perf record -e workqueue:workqueue_insertion:r

will have the same effect: enabling the raw samples record for the given tracepoint counter.

In the future, we may want to support further flags, separated by commas.

Will you at some point get those commit messages massaged into 'perf record --help'? :-)

- Arnaldo

#5 lore raw
Quoted 14 lines · Arnaldo Carvalho de Melo

Em Thu, Aug 13, 2009 at 10:27:18AM +0200, Frederic Weisbecker escreveu:

Quoted 13 lines

Add a new flag field while opening a tracepoint perf counter:

-e tracepoint_subsystem:tracepoint_name:flags

This is intended to be generic although for now it only supports the r[e[c[o[r[d]]]]] flag:

./perf record -e workqueue:workqueue_insertion:record ./perf record -e workqueue:workqueue_insertion:r

will have the same effect: enabling the raw samples record for the given tracepoint counter.

Quoted 7 lines
Quoted 2 lines

In the future, we may want to support further flags, separated by commas.

Will you at some point get those commit messages massaged into 'perf record --help'? :-)

- Arnaldo

Hehe, yeah, I will :-)

Oh BTW:

nobody@nowhere:~/linux/linux-2.6-tip/tools/perf/Documentation$ make
    SUBDIR ../
make[1]: « PERF-VERSION-FILE » est à jour.
    ASCIIDOC perf-annotate.html
    ASCIIDOC perf-examples.html
ERROR: perf-examples.txt: line 1: manpage document title is mandatory
WARNING: perf-examples.txt: line 8: missing [paradef-default] From an e-mail by Ingo Molnar-style entry
make: *** [perf-examples.html] Erreur 1

I've never touched an ascii doc thing. I'll soon put my hands into it.