perf tools: Add a per tracepoint counter attribute to get raw sample
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.
--- 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
@@ -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
@@ -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
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.
--- tools/perf/builtin-record.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
tools/perf/builtin-record.c +5 -0
@@ -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
Re: [PATCH 2/2] perf tools: Add a general option to enable raw sample records
Sorry, please ignore this one, it has been resent by mistake :-(
Quoted 48 lines · Frederic Weisbecker
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.
Signed-off-by Frederic Weisbecker <[email protected]>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@@ -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
PATCH 1/1 perf tools: Factorize the thread code in a dedicated file
In reply to Frederic WeisbeckerFactorize the thread management code used by perf-annotate and perf-report in dedicated source and header files.
--- tools/perf/Makefile | 1 + tools/perf/builtin-annotate.c | 173 ++++------------------------------- tools/perf/builtin-report.c | 205 ++++------------------------------------ tools/perf/util/thread.c | 143 ++++++++++++++++++++++++++++ tools/perf/util/thread.h | 19 ++++ 5 files changed, 202 insertions(+), 339 deletions(-) create mode 100644 tools/perf/util/thread.c create mode 100644 tools/perf/util/thread.h
tools/perf/Makefile +1 -0
@@ -341,6 +341,7 @@ LIB_OBJS += util/callchain.o LIB_OBJS += util/values.o LIB_OBJS += util/debug.o LIB_OBJS += util/map.o +LIB_OBJS += util/thread.o BUILTIN_OBJS += builtin-annotate.o BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +18 -155
234 lines not on this page · raw message
tools/perf/builtin-report.c +21 -184
271 lines not on this page · raw message
tools/perf/util/thread.c new file +143 -0
143 lines not on this page · raw message
tools/perf/util/thread.h new file +19 -0
@@ -0,0 +1,19 @@ +#include <linux/rbtree.h> +#include <linux/list.h> +#include <unistd.h> +#include "symbol.h" + +struct thread { +struct rb_node rb_node; +struct list_head maps; +pid_t pid; +char *comm; +}; + +int thread__set_comm (struct thread *self,const char *comm); +struct thread * +threads__findnew (pid_t pid,struct rb_root *threads,struct thread *last_match); +void thread__insert_map (struct thread *self,struct map *map); +int thread__fork (struct thread *self,struct thread *parent); +struct map *thread__find_map (struct thread *self,u64 ip); +size_t threads__fprintf (FILE *fp,struct rb_root *threads);
Signature · 1 line
1.6.2.3
PATCH v2 1/1 perf tools: Factorize the thread code in a dedicated file
Factorize the thread management code used by perf-annotate and perf-report in dedicated source and header files.
v2: pass last_match by address so that it can actually be modified.
--- tools/perf/Makefile | 1 + tools/perf/builtin-annotate.c | 173 ++++------------------------------- tools/perf/builtin-report.c | 205 ++++------------------------------------ tools/perf/util/thread.c | 143 ++++++++++++++++++++++++++++ tools/perf/util/thread.h | 19 ++++ 5 files changed, 202 insertions(+), 339 deletions(-) create mode 100644 tools/perf/util/thread.c create mode 100644 tools/perf/util/thread.h
tools/perf/Makefile +1 -0
@@ -341,6 +341,7 @@ LIB_OBJS += util/callchain.o LIB_OBJS += util/values.o LIB_OBJS += util/debug.o LIB_OBJS += util/map.o +LIB_OBJS += util/thread.o BUILTIN_OBJS += builtin-annotate.o BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +18 -155
234 lines not on this page · raw message
tools/perf/builtin-report.c +21 -184
271 lines not on this page · raw message
tools/perf/util/thread.c new file +143 -0
143 lines not on this page · raw message
tools/perf/util/thread.h new file +19 -0
@@ -0,0 +1,19 @@ +#include <linux/rbtree.h> +#include <linux/list.h> +#include <unistd.h> +#include "symbol.h" + +struct thread { +struct rb_node rb_node; +struct list_head maps; +pid_t pid; +char *comm; +}; + +int thread__set_comm (struct thread *self,const char *comm); +struct thread * +threads__findnew (pid_t pid,struct rb_root *threads,struct thread **last_match); +void thread__insert_map (struct thread *self,struct map *map); +int thread__fork (struct thread *self,struct thread *parent); +struct map *thread__find_map (struct thread *self,u64 ip); +size_t threads__fprintf (FILE *fp,struct rb_root *threads);
Signature · 1 line
1.6.2.3
[tip:perfcounters/core] perf tools: Factorize the thread code in a dedicated file
Commit-ID: 6baa0a5ae0954fb2486c480a20556a9f1aee0965 Gitweb: http://git.kernel.org/tip/6baa0a5ae0954fb2486c480a20556a9f1aee0965 Author: Frederic Weisbecker <[email protected]> AuthorDate: Fri, 14 Aug 2009 12:21:53 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 15 Aug 2009 16:10:19 +0200
perf tools: Factorize the thread code in a dedicated file
Factorize the thread management code used by perf-annotate and perf-report in dedicated source and header files.
v2: pass last_match by address so that it can actually be modified.
LKML-Reference: <[email protected]>
--- tools/perf/Makefile | 1 + tools/perf/builtin-annotate.c | 173 ++++------------------------------- tools/perf/builtin-report.c | 205 ++++------------------------------------ tools/perf/util/thread.c | 143 ++++++++++++++++++++++++++++ tools/perf/util/thread.h | 19 ++++ 5 files changed, 202 insertions(+), 339 deletions(-)
tools/perf/Makefile +1 -0
@@ -341,6 +341,7 @@ LIB_OBJS += util/callchain.o LIB_OBJS += util/values.o LIB_OBJS += util/debug.o LIB_OBJS += util/map.o +LIB_OBJS += util/thread.o BUILTIN_OBJS += builtin-annotate.o BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +18 -155
234 lines not on this page · raw message
tools/perf/builtin-report.c +21 -184
271 lines not on this page · raw message
tools/perf/util/thread.c new file +143 -0
143 lines not on this page · raw message
tools/perf/util/thread.h new file +19 -0
@@ -0,0 +1,19 @@ +#include <linux/rbtree.h> +#include <linux/list.h> +#include <unistd.h> +#include "symbol.h" + +struct thread { +struct rb_node rb_node; +struct list_head maps; +pid_t pid; +char *comm; +}; + +int thread__set_comm (struct thread *self,const char *comm); +struct thread * +threads__findnew (pid_t pid,struct rb_root *threads,struct thread **last_match); +void thread__insert_map (struct thread *self,struct map *map); +int thread__fork (struct thread *self,struct thread *parent); +struct map *thread__find_map (struct thread *self,u64 ip); +size_t threads__fprintf (FILE *fp,struct rb_root *threads);
Sorry, please ignore this one, it has been resent by mistake :-(
Quoted 69 lines · Frederic Weisbecker
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.
Signed-off-by Frederic Weisbecker <[email protected]>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@@ -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@@ -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