perf tools: Various fixes
Jiri Olsa
reviewercover perf tools: Various fixes
hi,
sending various fixes that piled up plus some
I'll need in future patchsets.
thanks,
jirka
---
Don Zickus (1):
perf tools: Add support for sorting on the iaddr
Jiri Olsa (8):
tools lib api fs: Do not use PATH_MAX + 1
perf evlist: Display DATA_SRC sample type bit perf annotate: Fix sizeof_sym_hist overflow issue perf tools: Make perf_event_attr__set_max_precise_ip global perf tools: Introduce 'P' modifier
perf tests: Add parsing test for 'P' modifier perf tools: Setup proper width for symbol_iaddr field perf tools: Handle -h and -v options
tools/lib/api/fs/fs.c | 2 +- tools/lib/api/fs/tracing_path.c | 6 +++--- tools/perf/Documentation/perf-list.txt | 1 + tools/perf/Documentation/perf.txt | 8 ++++++++ tools/perf/perf.c | 14 ++++++++++++++ tools/perf/tests/parse-events.c | 16 ++++++++++++++++ tools/perf/util/annotate.h | 2 +- tools/perf/util/evlist.c | 2 +- tools/perf/util/evlist.h | 2 ++ tools/perf/util/evsel.c | 5 ++++- tools/perf/util/evsel.h | 1 + tools/perf/util/hist.c | 13 +++++++++++++ tools/perf/util/hist.h | 1 + tools/perf/util/parse-events.c | 8 +++++++- tools/perf/util/parse-events.l | 2 +- tools/perf/util/sort.c | 37 +++++++++++++++++++++++++++++++++++++ tools/perf/util/sort.h | 1 + 17 files changed, 112 insertions(+), 9 deletions(-)
Jiri Olsa
reviewerPATCH 1/9 tools lib api fs: Do not use PATH_MAX + 1
Because there's no point, PATH_MAX is big enough.
--- tools/lib/api/fs/fs.c | 2 +- tools/lib/api/fs/tracing_path.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/api/fs/fs.c +1 -1
@@ -69,7 +69,7 @@ static const char * const tracefs__known_mountpoints[] = {struct fs {const char *name;const char *const *mounts; -char path[PATH_MAX +1 ]; +char path[PATH_MAX ];bool found;long magic; };
tools/lib/api/fs/tracing_path.c +3 -3
@@ -12,9 +12,9 @@#include "tracing_path.h" -char tracing_mnt[PATH_MAX +1 ] ="/sys/kernel/debug" ; -char tracing_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing" ; -char tracing_events_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing/events" ; +char tracing_mnt[PATH_MAX ] ="/sys/kernel/debug" ; +char tracing_path[PATH_MAX ] ="/sys/kernel/debug/tracing" ; +char tracing_events_path[PATH_MAX ] ="/sys/kernel/debug/tracing/events" ;static void __tracing_path_set (const char *tracing,const char *mountpoint)
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] tools lib api fs: No need to use PATH_MAX + 1
tools lib api fs: No need to use PATH_MAX + 1
Commit-ID: ccb5597f9ba11b67b8aa8c6f4682675eceee0e21 Gitweb: http://git.kernel.org/tip/ccb5597f9ba11b67b8aa8c6f4682675eceee0e21 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:01 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:12:09 -0300
tools lib api fs: No need to use PATH_MAX + 1
Because there's no point, PATH_MAX is big enough.
--- tools/lib/api/fs/fs.c | 2 +- tools/lib/api/fs/tracing_path.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/api/fs/fs.c +1 -1
@@ -69,7 +69,7 @@ static const char * const tracefs__known_mountpoints[] = {struct fs {const char *name;const char *const *mounts; -char path[PATH_MAX +1 ]; +char path[PATH_MAX ];bool found;long magic; };
tools/lib/api/fs/tracing_path.c +3 -3
@@ -12,9 +12,9 @@#include "tracing_path.h" -char tracing_mnt[PATH_MAX +1 ] ="/sys/kernel/debug" ; -char tracing_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing" ; -char tracing_events_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing/events" ; +char tracing_mnt[PATH_MAX ] ="/sys/kernel/debug" ; +char tracing_path[PATH_MAX ] ="/sys/kernel/debug/tracing" ; +char tracing_events_path[PATH_MAX ] ="/sys/kernel/debug/tracing/events" ;static void __tracing_path_set (const char *tracing,const char *mountpoint)
Jiri Olsa
reviewerPATCH 2/9 perf evlist: Display DATA_SRC sample type bit
In reply to Jiri OlsaAdding DATA_SRC bit_name call to display sample_type properly.
$ perf evlist -v cpu/mem-loads/pp: ...SNIP... sample_type: IP|TID|TIME|ADDR|CPU|PERIOD|DATA_SRC, ...
--- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -1
@@ -1178,7 +1178,7 @@ static void __p_sample_type(char *buf, size_t size, u64 value)bit_name (READ ),bit_name (CALLCHAIN ),bit_name (ID ),bit_name (CPU ),bit_name (PERIOD ),bit_name (STREAM_ID ),bit_name (RAW ),bit_name (BRANCH_STACK ),bit_name (REGS_USER ),bit_name (STACK_USER ), -bit_name (IDENTIFIER ),bit_name (REGS_INTR ), +bit_name (IDENTIFIER ),bit_name (REGS_INTR ),bit_name (DATA_SRC ), { .name = NULL, } };#undef bit_name
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf evlist: Display DATA_SRC sample type bit
perf evlist: Display DATA_SRC sample type bit
Commit-ID: 84422592e58f6f1ea03688fcf92143bbc095fa88 Gitweb: http://git.kernel.org/tip/84422592e58f6f1ea03688fcf92143bbc095fa88 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:02 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:15:10 -0300
perf evlist: Display DATA_SRC sample type bit
Adding DATA_SRC bit_name call to display sample_type properly.
$ perf evlist -v cpu/mem-loads/pp: ...SNIP... sample_type: IP|TID|TIME|ADDR|CPU|PERIOD|DATA_SRC, ...
--- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -1
@@ -1178,7 +1178,7 @@ static void __p_sample_type(char *buf, size_t size, u64 value)bit_name (READ ),bit_name (CALLCHAIN ),bit_name (ID ),bit_name (CPU ),bit_name (PERIOD ),bit_name (STREAM_ID ),bit_name (RAW ),bit_name (BRANCH_STACK ),bit_name (REGS_USER ),bit_name (STACK_USER ), -bit_name (IDENTIFIER ),bit_name (REGS_INTR ), +bit_name (IDENTIFIER ),bit_name (REGS_INTR ),bit_name (DATA_SRC ), { .name = NULL, } };#undef bit_name
Jiri Olsa
reviewerPATCH 3/9 perf annotate: Fix sizeof_sym_hist overflow issue
In reply to Jiri OlsaThe annotated_source::sizeof_sym_hist could easily overflow int size, resulting in crash in __symbol__inc_addr_samples.
Changing its type int size_t as was probably intended from beginning based on initialization code in symbol__alloc_hist.
--- tools/perf/util/annotate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.h +1 -1
@@ -122,7 +122,7 @@ struct annotated_source {struct list_head source;struct source_line *lines;int nr_histograms; -int sizeof_sym_hist; +size_t sizeof_sym_hist;struct cyc_hist *cycles_hist;struct sym_hist histograms[0 ]; };
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf annotate: Fix sizeof_sym_hist overflow issue
perf annotate: Fix sizeof_sym_hist overflow issue
Commit-ID: 5ec4502d774699194952209ff3ebe65d2472e15a Gitweb: http://git.kernel.org/tip/5ec4502d774699194952209ff3ebe65d2472e15a Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:03 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:15:38 -0300
perf annotate: Fix sizeof_sym_hist overflow issue
The annotated_source::sizeof_sym_hist could easily overflow int size, resulting in crash in __symbol__inc_addr_samples.
Changing its type int size_t as was probably intended from beginning based on the initialization code in symbol__alloc_hist.
--- tools/perf/util/annotate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.h +1 -1
@@ -122,7 +122,7 @@ struct annotated_source {struct list_head source;struct source_line *lines;int nr_histograms; -int sizeof_sym_hist; +size_t sizeof_sym_hist;struct cyc_hist *cycles_hist;struct sym_hist histograms[0 ]; };
Jiri Olsa
reviewerPATCH 4/9 perf tools: Make perf_event_attr__set_max_precise_ip global
In reply to Jiri OlsaIt'll be used in following patch.
--- tools/perf/util/evlist.c | 2 +- tools/perf/util/evlist.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/evlist.c +1 -1
@@ -205,7 +205,7 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) } } -static void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr) +void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr) { attr->precise_ip =3 ;
tools/perf/util/evlist.h +2 -0
@@ -290,4 +290,6 @@ void perf_evlist__to_front(struct perf_evlist *evlist,void perf_evlist__set_tracking_event (struct perf_evlist *evlist,struct perf_evsel *tracking_evsel); + +void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr);#endif /* __PERF_EVLIST_H */
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Export perf_event_attr__set_max_precise_ip()
perf tools: Export perf_event_attr__set_max_precise_ip()
Commit-ID: 45cf6c33f95448752dd3d5531388429c3a5012d0 Gitweb: http://git.kernel.org/tip/45cf6c33f95448752dd3d5531388429c3a5012d0 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:04 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:16:20 -0300
perf tools: Export perf_event_attr__set_max_precise_ip()
It'll be used in following patch.
--- tools/perf/util/evlist.c | 2 +- tools/perf/util/evlist.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/evlist.c +1 -1
@@ -205,7 +205,7 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) } } -static void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr) +void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr) { attr->precise_ip =3 ;
tools/perf/util/evlist.h +2 -0
@@ -290,4 +290,6 @@ void perf_evlist__to_front(struct perf_evlist *evlist,void perf_evlist__set_tracking_event (struct perf_evlist *evlist,struct perf_evsel *tracking_evsel); + +void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr);#endif /* __PERF_EVLIST_H */
Jiri Olsa
reviewerPATCH 5/9 perf tools: Introduce 'P' modifier
In reply to Jiri OlsaThe 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...
will detect maximum precise level for 'cycles' event and use it.
--- tools/perf/Documentation/perf-list.txt | 1 + tools/perf/util/evsel.c | 3 +++ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 8 +++++++- tools/perf/util/parse-events.l | 2 +- 5 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-list.txt +1 -0
@@ -30,6 +30,7 @@ counted. The following modifiers exist: G - guest counting (in KVM guests) H - host counting (not in KVM guests) p - precise level + P - use maximum detected precise level S - read sample value (PERF_SAMPLE_READ) D - pin the event to the PMU
tools/perf/util/evsel.c +3 -0
@@ -882,6 +882,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->clockid = opts->clockid; } +if (evsel->precise_max) +perf_event_attr__set_max_precise_ip (attr); +/* * Apply event specific term settings, * it overloads any global configuration.
tools/perf/util/evsel.h +1 -0
@@ -111,6 +111,7 @@ struct perf_evsel {bool system_wide;bool tracking;bool per_pkg; +bool precise_max;/* parse modifier helper */ int exclude_GH;int nr_members;
tools/perf/util/parse-events.c +7 -1
@@ -923,6 +923,7 @@ struct event_modifier {int eG;int eI;int precise; +int precise_max;int exclude_GH;int sample_read;int pinned;
@@ -938,6 +939,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str,int eG = evsel ? evsel->attr.exclude_guest :0 ;int eI = evsel ? evsel->attr.exclude_idle :0 ;int precise = evsel ? evsel->attr.precise_ip :0 ; +int precise_max =0 ;int sample_read =0 ;int pinned = evsel ? evsel->attr.pinned :0 ;
@@ -974,6 +976,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str,/* use of precise requires exclude_guest */ if (!exclude_GH) eG =1 ; + }else if (*str =='P' ) { + precise_max =1 ; }else if (*str =='S' ) { sample_read =1 ; }else if (*str =='D' ) {
@@ -1004,6 +1008,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str, mod->eG = eG; mod->eI = eI; mod->precise = precise; + mod->precise_max = precise_max; mod->exclude_GH = exclude_GH; mod->sample_read = sample_read; mod->pinned = pinned;
@@ -1020,7 +1025,7 @@ static int check_modifier(char *str)char *p = str;/* The sizeof includes 0 byte as well. */ -if (strlen (str) > (sizeof ("ukhGHpppSDI" ) -1 )) +if (strlen (str) > (sizeof ("ukhGHpppPSDI" ) -1 ))return -1 ;while (*p) {
@@ -1059,6 +1064,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) evsel->attr.exclude_idle = mod.eI; evsel->exclude_GH = mod.exclude_GH; evsel->sample_read = mod.sample_read; + evsel->precise_max = mod.precise_max;if (perf_evsel__is_group_leader (evsel)) evsel->attr.pinned = mod.pinned;
tools/perf/util/parse-events.l +1 -1
@@ -122,7 +122,7 @@ num_raw_hex [a-fA-F0-9]+ name [a-zA-Z_*?][a-zA-Z0-9_*?.]* name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]* /* If you add a modifier you need to update check_modifier() */ -modifier_event [ukhpGHSDI]+ +modifier_event [ukhpPGHSDI]+ modifier_bp [rwx]{1,3} %%
Signature · 1 line
2.4.3
Re: [PATCH 5/9] perf tools: Introduce 'P' modifier
Quoted 9 lines · Jiri Olsa
The 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...will detect maximum precise level for 'cycles' event and use it.
Does the end result (which precise level is used) get saved to the header and displayed to the user properly?
Re: [PATCH 5/9] perf tools: Introduce 'P' modifier
Quoted 7 lines · David Ahern
Quoted 6 lines · Jiri Olsa
The 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...
Quoted 6 lines
Quoted 3 lines
will detect maximum precise level for 'cycles' event and use it.
Does the end result (which precise level is used) get saved to the header and displayed to the user properly?
yep..
[jolsa@krava perf]$ ./perf record -e cycles:P ls
...
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB perf.data (8 samples) ] [jolsa@krava perf]$ ./perf evlist
cycles:P
[jolsa@krava perf]$ ./perf evlist -v
cycles:P: size: 112, ... precise_ip: 2 ...
[jolsa@krava perf]$ ./perf report --stdio
# To display the perf.data header info, please use --header/--header-only options. #
#
# Total Lost Samples: 0
#
# Samples: 8 of event 'cycles:P'
# Event count (approx.): 4270406
#
# Overhead Command Shared Object Symbol
...
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 5/9] perf tools: Introduce 'P' modifier
Em Mon, Oct 05, 2015 at 08:38:06PM +0200, Jiri Olsa escreveu:
Quoted 16 lines · David Ahern
Quoted 12 lines · Jiri Olsa
Quoted 8 lines
The 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...will detect maximum precise level for 'cycles' event and use it.
Does the end result (which precise level is used) get saved to the header and displayed to the user properly?
yep..
Quoted 8 lines
[jolsa@krava perf]$ ./perf record -e cycles:P ls
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB perf.data (8 samples) ] [jolsa@krava perf]$ ./perf evlist
cycles:P
[jolsa@krava perf]$ ./perf evlist -v
cycles:P: size: 112, ...precise_ip: 2 ...
[root@zoo ~]# perf record usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.016 MB perf.data (12 samples) ]
[root@zoo ~]# perf evlist
cycles:pp
[root@zoo ~]# perf evlist -v
cycles:pp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1 [root@zoo ~]#
- Arnaldo
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 5/9] perf tools: Introduce 'P' modifier
In reply to Jiri OlsaEm Mon, Oct 05, 2015 at 08:06:05PM +0200, Jiri Olsa escreveu:
Quoted 8 lines
The 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...will detect maximum precise level for 'cycles' event and use it.
I had to do a 'make -C tools/perf clean' to get this to work, i.e. it is not noticing that the parser files were changed and thus need to run again, can you please take a look?
Thanks,
- Arnaldo
Re: [PATCH 5/9] perf tools: Introduce 'P' modifier
Quoted 7 lines · Arnaldo Carvalho de Melo
Em Mon, Oct 05, 2015 at 08:06:05PM +0200, Jiri Olsa escreveu:
Quoted 6 lines
The 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...
Quoted 6 lines
Quoted 2 lines
will detect maximum precise level for 'cycles' event and use it.
I had to do a 'make -C
tools/perfclean' to get this to work, i.e. it is not noticing that the parser files were changed and thus need to run again, can you please take a look?
can't see that:
[jolsa@krava perf]$ make
BUILD: Doing 'make -j4' parallel build CC util/parse-events.o LD util/libperf-in.o LD libperf-in.o AR libperf.a LINK perf LINK libperf-gtk.so [jolsa@krava perf]$ touch util/parse-events.l [jolsa@krava perf]$ make BUILD: Doing 'make -j4' parallel build FLEX util/parse-events-flex.c CC util/parse-events-flex.o CC util/parse-events.o LD util/libperf-in.o LD libperf-in.o AR libperf.a LINK perf LINK libperf-gtk.so [jolsa@krava perf]$ touch util/parse-events.y [jolsa@krava perf]$ make BUILD: Doing 'make -j4' parallel build BISON util/parse-events-bison.c FLEX util/parse-events-flex.c CC util/parse-events-bison.o CC util/parse-events.o CC util/parse-events-flex.o LD util/libperf-in.o LD libperf-in.o AR libperf.a LINK perf LINK libperf-gtk.so [jolsa@krava linux-perf]$ make -C tools/perf make: Entering directory '/home/jolsa/kernel/linux-perf/tools/perf' BUILD: Doing 'make -j4' parallel build CC util/parse-events.o LD util/libperf-in.o LD libperf-in.o AR libperf.a LINK perf LINK libperf-gtk.so make: Leaving directory '/home/jolsa/kernel/linux-perf/tools/perf' [jolsa@krava linux-perf]$ make -C tools/perf make: Entering directory '/home/jolsa/kernel/linux-perf/tools/perf' BUILD: Doing 'make -j4' parallel build BISON util/parse-events-bison.c FLEX util/parse-events-flex.c CC util/parse-events-bison.o CC util/parse-events.o CC util/parse-events-flex.o LD util/libperf-in.o LD libperf-in.o AR libperf.a LINK perf LINK libperf-gtk.so make: Leaving directory '/home/jolsa/kernel/linux-perf/tools/perf' [jolsa@krava linux-perf]$ make -C tools/perf make: Entering directory '/home/jolsa/kernel/linux-perf/tools/perf' BUILD: Doing 'make -j4' parallel build FLEX util/parse-events-flex.c CC util/parse-events-flex.o CC util/parse-events.o LD util/libperf-in.o LD libperf-in.o AR libperf.a LINK perf LINK libperf-gtk.so
make: Leaving directory '/home/jolsa/kernel/linux-perf/tools/perf'
jirka
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Introduce 'P' modifier to request max precision
In reply to Jiri Olsaperf tools: Introduce 'P' modifier to request max precision
Commit-ID: 7f94af7a489fada17d28cc60e8f4409ce216bd6d Gitweb: http://git.kernel.org/tip/7f94af7a489fada17d28cc60e8f4409ce216bd6d Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:05 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:21:11 -0300
perf tools: Introduce 'P' modifier to request max precision
The 'P' will cause the event to get maximum possible detected precise level.
Following record:
$ perf record -e cycles:P ...
will detect maximum precise level for 'cycles' event and use it.
Commiter note:
Testing it:
$ perf record -e cycles:P usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data (9 samples) ]
$ perf evlist
cycles:P
$ perf evlist -v
cycles:P: size: 112, { sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1,
enable_on_exec: 1, task: 1, precise_ip: 2, sample_id_all: 1, mmap2: 1,
comm_exec: 1
$--- tools/perf/Documentation/perf-list.txt | 1 + tools/perf/util/evsel.c | 3 +++ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 8 +++++++- tools/perf/util/parse-events.l | 2 +- 5 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-list.txt +1 -0
@@ -30,6 +30,7 @@ counted. The following modifiers exist: G - guest counting (in KVM guests) H - host counting (not in KVM guests) p - precise level + P - use maximum detected precise level S - read sample value (PERF_SAMPLE_READ) D - pin the event to the PMU
tools/perf/util/evsel.c +3 -0
@@ -882,6 +882,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->clockid = opts->clockid; } +if (evsel->precise_max) +perf_event_attr__set_max_precise_ip (attr); +/* * Apply event specific term settings, * it overloads any global configuration.
tools/perf/util/evsel.h +1 -0
@@ -111,6 +111,7 @@ struct perf_evsel {bool system_wide;bool tracking;bool per_pkg; +bool precise_max;/* parse modifier helper */ int exclude_GH;int nr_members;
tools/perf/util/parse-events.c +7 -1
@@ -923,6 +923,7 @@ struct event_modifier {int eG;int eI;int precise; +int precise_max;int exclude_GH;int sample_read;int pinned;
@@ -938,6 +939,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str,int eG = evsel ? evsel->attr.exclude_guest :0 ;int eI = evsel ? evsel->attr.exclude_idle :0 ;int precise = evsel ? evsel->attr.precise_ip :0 ; +int precise_max =0 ;int sample_read =0 ;int pinned = evsel ? evsel->attr.pinned :0 ;
@@ -974,6 +976,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str,/* use of precise requires exclude_guest */ if (!exclude_GH) eG =1 ; + }else if (*str =='P' ) { + precise_max =1 ; }else if (*str =='S' ) { sample_read =1 ; }else if (*str =='D' ) {
@@ -1004,6 +1008,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str, mod->eG = eG; mod->eI = eI; mod->precise = precise; + mod->precise_max = precise_max; mod->exclude_GH = exclude_GH; mod->sample_read = sample_read; mod->pinned = pinned;
@@ -1020,7 +1025,7 @@ static int check_modifier(char *str)char *p = str;/* The sizeof includes 0 byte as well. */ -if (strlen (str) > (sizeof ("ukhGHpppSDI" ) -1 )) +if (strlen (str) > (sizeof ("ukhGHpppPSDI" ) -1 ))return -1 ;while (*p) {
@@ -1059,6 +1064,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) evsel->attr.exclude_idle = mod.eI; evsel->exclude_GH = mod.exclude_GH; evsel->sample_read = mod.sample_read; + evsel->precise_max = mod.precise_max;if (perf_evsel__is_group_leader (evsel)) evsel->attr.pinned = mod.pinned;
tools/perf/util/parse-events.l +1 -1
@@ -122,7 +122,7 @@ num_raw_hex [a-fA-F0-9]+ name [a-zA-Z_*?][a-zA-Z0-9_*?.]* name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]* /* If you add a modifier you need to update check_modifier() */ -modifier_event [ukhpGHSDI]+ +modifier_event [ukhpPGHSDI]+ modifier_bp [rwx]{1,3} %%
Jiri Olsa
reviewerPATCH 6/9 perf tests: Add parsing test for 'P' modifier
In reply to Jiri OlsaWe cant test 'P' modifier gets properly parsed, the functionality test itself is beyond this suite.
--- tools/perf/tests/parse-events.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/perf/tests/parse-events.c +16 -0
@@ -1259,6 +1259,17 @@ test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)return test__checkevent_breakpoint_rw (evlist); } +static int test__checkevent_precise_max_modifier (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel =perf_evlist__first (evlist); + +TEST_ASSERT_VAL ("wrong number of entries" ,2 == evlist->nr_entries); +TEST_ASSERT_VAL ("wrong type" ,PERF_TYPE_SOFTWARE == evsel->attr.type); +TEST_ASSERT_VAL ("wrong config" , +PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config); +return 0 ; +} +static int count_tracepoints (void ) {struct dirent *events_ent;
@@ -1562,6 +1573,11 @@ static struct evlist_test test__events[] = { .check = test__checkevent_exclude_idle_modifier_1, .id = 46, }, + { + .name = "task-clock:P,cycles", + .check = test__checkevent_precise_max_modifier, + .id = 47, + }, };static struct evlist_test test__events_pmu[] = {
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tests: Add parsing test for 'P' modifier
perf tests: Add parsing test for 'P' modifier
Commit-ID: ddd83c9717ef8204f17cc63d6dcb5053d472caee Gitweb: http://git.kernel.org/tip/ddd83c9717ef8204f17cc63d6dcb5053d472caee Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:06 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:22:15 -0300
perf tests: Add parsing test for 'P' modifier
We cant test 'P' modifier gets properly parsed, the functionality test itself is beyond this suite.
--- tools/perf/tests/parse-events.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/perf/tests/parse-events.c +16 -0
@@ -1259,6 +1259,17 @@ test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)return test__checkevent_breakpoint_rw (evlist); } +static int test__checkevent_precise_max_modifier (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel =perf_evlist__first (evlist); + +TEST_ASSERT_VAL ("wrong number of entries" ,2 == evlist->nr_entries); +TEST_ASSERT_VAL ("wrong type" ,PERF_TYPE_SOFTWARE == evsel->attr.type); +TEST_ASSERT_VAL ("wrong config" , +PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config); +return 0 ; +} +static int count_tracepoints (void ) {struct dirent *events_ent;
@@ -1562,6 +1573,11 @@ static struct evlist_test test__events[] = { .check = test__checkevent_exclude_idle_modifier_1, .id = 46, }, + { + .name = "task-clock:P,cycles", + .check = test__checkevent_precise_max_modifier, + .id = 47, + }, };static struct evlist_test test__events_pmu[] = {
Jiri Olsa
reviewerPATCH 7/9 perf tools: Add support for sorting on the iaddr
In reply to Jiri OlsaFrom: Don Zickus <[email protected]>
Sorting on 'symbol' gives to broad a resolution as it can cover a range of IP address. Use the iaddr instead to get proper sorting on IP addresses. Need to use the 'mem_sort' feature of perf record.
New sort option is: symbol_iaddr, header label is 'Code Symbol'.
$ perf mem report --stdio -F +symbol_iaddr
# Overhead Samples Code Symbol Local Weight
# ........ ............ ........................ ............
#
54.08% 1 [k] nmi_handle 192
4.51% 1 [k] finish_task_switch 16
3.66% 1 [.] malloc 13
3.10% 1 [.] __strcoll_l 11--- tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 37 +++++++++++++++++++++++++++++++++++++ tools/perf/util/sort.h | 1 + 3 files changed, 39 insertions(+)
tools/perf/util/hist.h +1 -0
@@ -49,6 +49,7 @@ enum hist_column {HISTC_MEM_LVL ,HISTC_MEM_SNOOP ,HISTC_MEM_DCACHELINE , +HISTC_MEM_IADDR_SYMBOL ,HISTC_TRANSACTION ,HISTC_CYCLES , HISTC_NR_COLS, /* Last entry */
tools/perf/util/sort.c +37 -0
@@ -655,6 +655,35 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf, }static int64_t +sort__iaddr_cmp (struct hist_entry *left,struct hist_entry *right) +{ +uint64_t l =0 , r =0 ; + +if (left->mem_info) + l = left->mem_info->iaddr.addr; +if (right->mem_info) + r = right->mem_info->iaddr.addr; + +return (int64_t )(r - l); +} + +static int hist_entry__iaddr_snprintf (struct hist_entry *he,char *bf, +size_t size,unsigned int width) +{ +uint64_t addr =0 ; +struct map *map =NULL ; +struct symbol *sym =NULL ; + +if (he->mem_info) { + addr = he->mem_info->iaddr.addr; + map = he->mem_info->iaddr.map; + sym = he->mem_info->iaddr.sym; + } +return _hist_entry__sym_snprintf (map, sym, addr, he->level, bf, size, + width); +} + +static int64_t sort__dso_daddr_cmp (struct hist_entry *left,struct hist_entry *right) {struct map *map_l =NULL ;
@@ -1077,6 +1106,13 @@ struct sort_entry sort_mem_daddr_sym = { .se_width_idx = HISTC_MEM_DADDR_SYMBOL, }; +struct sort_entry sort_mem_iaddr_sym = { + .se_header ="Code Symbol" , + .se_cmp = sort__iaddr_cmp, + .se_snprintf = hist_entry__iaddr_snprintf, + .se_width_idx =HISTC_MEM_IADDR_SYMBOL , +}; +struct sort_entry sort_mem_daddr_dso = { .se_header ="Data Object" , .se_cmp = sort__dso_daddr_cmp,
@@ -1299,6 +1335,7 @@ static struct sort_dimension bstack_sort_dimensions[] = {static struct sort_dimension memory_sort_dimensions[] = {DIM (SORT_MEM_DADDR_SYMBOL ,"symbol_daddr" , sort_mem_daddr_sym), +DIM (SORT_MEM_IADDR_SYMBOL ,"symbol_iaddr" , sort_mem_iaddr_sym),DIM (SORT_MEM_DADDR_DSO ,"dso_daddr" , sort_mem_daddr_dso),DIM (SORT_MEM_LOCKED ,"locked" , sort_mem_locked),DIM (SORT_MEM_TLB ,"tlb" , sort_mem_tlb),
tools/perf/util/sort.h +1 -0
@@ -201,6 +201,7 @@ enum sort_type {SORT_MEM_LVL ,SORT_MEM_SNOOP ,SORT_MEM_DCACHELINE , + SORT_MEM_IADDR_SYMBOL, };/*
Signature · 1 line
2.4.3
tip-bot for Don Zickus
merge bot[tip:perf/core] perf tools: Add support for sorting on the iaddr
perf tools: Add support for sorting on the iaddr
Commit-ID: 28e6db205b3ed3f1d86a00c69b3304190377da5f Gitweb: http://git.kernel.org/tip/28e6db205b3ed3f1d86a00c69b3304190377da5f Author: Don Zickus <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:07 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:32:00 -0300
perf tools: Add support for sorting on the iaddr
Sorting on 'symbol' gives to broad a resolution as it can cover a range of IP address. Use the iaddr instead to get proper sorting on IP addresses. Need to use the 'mem_sort' feature of perf record.
New sort option is: symbol_iaddr, header label is 'Code Symbol'.
$ perf mem report --stdio -F +symbol_iaddr
# Overhead Samples Code Symbol Local Weight
# ........ ............ ........................ ............
#
54.08% 1 [k] nmi_handle 192
4.51% 1 [k] finish_task_switch 16
3.66% 1 [.] malloc 13
3.10% 1 [.] __strcoll_l 11--- tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 37 +++++++++++++++++++++++++++++++++++++ tools/perf/util/sort.h | 1 + 3 files changed, 39 insertions(+)
tools/perf/util/hist.h +1 -0
@@ -49,6 +49,7 @@ enum hist_column {HISTC_MEM_LVL ,HISTC_MEM_SNOOP ,HISTC_MEM_DCACHELINE , +HISTC_MEM_IADDR_SYMBOL ,HISTC_TRANSACTION ,HISTC_CYCLES , HISTC_NR_COLS, /* Last entry */
tools/perf/util/sort.c +37 -0
@@ -655,6 +655,35 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf, }static int64_t +sort__iaddr_cmp (struct hist_entry *left,struct hist_entry *right) +{ +uint64_t l =0 , r =0 ; + +if (left->mem_info) + l = left->mem_info->iaddr.addr; +if (right->mem_info) + r = right->mem_info->iaddr.addr; + +return (int64_t )(r - l); +} + +static int hist_entry__iaddr_snprintf (struct hist_entry *he,char *bf, +size_t size,unsigned int width) +{ +uint64_t addr =0 ; +struct map *map =NULL ; +struct symbol *sym =NULL ; + +if (he->mem_info) { + addr = he->mem_info->iaddr.addr; + map = he->mem_info->iaddr.map; + sym = he->mem_info->iaddr.sym; + } +return _hist_entry__sym_snprintf (map, sym, addr, he->level, bf, size, + width); +} + +static int64_t sort__dso_daddr_cmp (struct hist_entry *left,struct hist_entry *right) {struct map *map_l =NULL ;
@@ -1077,6 +1106,13 @@ struct sort_entry sort_mem_daddr_sym = { .se_width_idx = HISTC_MEM_DADDR_SYMBOL, }; +struct sort_entry sort_mem_iaddr_sym = { + .se_header ="Code Symbol" , + .se_cmp = sort__iaddr_cmp, + .se_snprintf = hist_entry__iaddr_snprintf, + .se_width_idx =HISTC_MEM_IADDR_SYMBOL , +}; +struct sort_entry sort_mem_daddr_dso = { .se_header ="Data Object" , .se_cmp = sort__dso_daddr_cmp,
@@ -1299,6 +1335,7 @@ static struct sort_dimension bstack_sort_dimensions[] = {static struct sort_dimension memory_sort_dimensions[] = {DIM (SORT_MEM_DADDR_SYMBOL ,"symbol_daddr" , sort_mem_daddr_sym), +DIM (SORT_MEM_IADDR_SYMBOL ,"symbol_iaddr" , sort_mem_iaddr_sym),DIM (SORT_MEM_DADDR_DSO ,"dso_daddr" , sort_mem_daddr_dso),DIM (SORT_MEM_LOCKED ,"locked" , sort_mem_locked),DIM (SORT_MEM_TLB ,"tlb" , sort_mem_tlb),
tools/perf/util/sort.h +1 -0
@@ -201,6 +201,7 @@ enum sort_type {SORT_MEM_LVL ,SORT_MEM_SNOOP ,SORT_MEM_DCACHELINE , + SORT_MEM_IADDR_SYMBOL, };/*
Jiri Olsa
reviewerPATCH 8/9 perf tools: Setup proper width for symbol_iaddr field
In reply to Jiri OlsaWe need to properly initialize column width for symbol_iaddr field, so all symbols could fit in the column.
--- tools/perf/util/hist.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tools/perf/util/hist.c +13 -0
@@ -132,6 +132,18 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen); } + +if (h->mem_info->iaddr.sym) { + symlen = (int )h->mem_info->iaddr.sym->namelen +4 + + unresolved_col_width +2 ; +hists__new_col_len (hists,HISTC_MEM_IADDR_SYMBOL , + symlen); + }else { + symlen = unresolved_col_width +4 +2 ; +hists__new_col_len (hists,HISTC_MEM_IADDR_SYMBOL , + symlen); + } +if (h->mem_info->daddr.map) { symlen =dso__name_len (h->mem_info->daddr.map->dso); hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
@@ -143,6 +155,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) }else { symlen = unresolved_col_width +4 +2 ;hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen); +hists__new_col_len (hists,HISTC_MEM_IADDR_SYMBOL , symlen);hists__set_unres_dso_col_len (hists,HISTC_MEM_DADDR_DSO ); }
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Setup proper width for symbol_iaddr field
perf tools: Setup proper width for symbol_iaddr field
Commit-ID: b34b3bf0798633cc248b682f5b4f6509739ce234 Gitweb: http://git.kernel.org/tip/b34b3bf0798633cc248b682f5b4f6509739ce234 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:08 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:33:41 -0300
perf tools: Setup proper width for symbol_iaddr field
We need to properly initialize column width for symbol_iaddr field, so all symbols could fit in the column.
--- tools/perf/util/hist.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tools/perf/util/hist.c +13 -0
@@ -132,6 +132,18 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen); } + +if (h->mem_info->iaddr.sym) { + symlen = (int )h->mem_info->iaddr.sym->namelen +4 + + unresolved_col_width +2 ; +hists__new_col_len (hists,HISTC_MEM_IADDR_SYMBOL , + symlen); + }else { + symlen = unresolved_col_width +4 +2 ; +hists__new_col_len (hists,HISTC_MEM_IADDR_SYMBOL , + symlen); + } +if (h->mem_info->daddr.map) { symlen =dso__name_len (h->mem_info->daddr.map->dso); hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
@@ -143,6 +155,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) }else { symlen = unresolved_col_width +4 +2 ;hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen); +hists__new_col_len (hists,HISTC_MEM_IADDR_SYMBOL , symlen);hists__set_unres_dso_col_len (hists,HISTC_MEM_DADDR_DSO ); }
Jiri Olsa
reviewerPATCH 9/9 perf tools: Handle -h and -v options
In reply to Jiri OlsaAdding handling for '-h' and '-v' options to invoke help and version command respectively.
Current behaviour is:
$ perf -v Unknown option: -v
Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
$ perf -h Unknown option: -h
Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
New behaviour:
$ perf -h
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites...
$ perf -v perf version 4.3.rc3.gc99e32
Updated man page.
--- tools/perf/Documentation/perf.txt | 8 ++++++++ tools/perf/perf.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+)
tools/perf/Documentation/perf.txt +8 -0
@@ -27,6 +27,14 @@ OPTIONS Setup buildid cache directory. It has higher priority than buildid.dir config file option. +-v:: +--version:: + Display perf version. + +-h:: +--help:: + Run perf help command. + DESCRIPTION ----------- Performance counters for Linux are a new kernel-based subsystem
tools/perf/perf.c +14 -0
@@ -162,6 +162,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)break ;/* +* Shortcut for '-h' and '-v' options to invoke help +* and version command. +*/ +if (!strcmp (cmd,"-h" )) { + (*argv)[0 ] ="--help" ; +break ; + } + +if (!strcmp (cmd,"-v" )) { + (*argv)[0 ] ="--version" ; +break ; + } + +/* * Check remaining flags. */ if (!prefixcmp (cmd,CMD_EXEC_PATH )) {
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Handle -h and -v options
perf tools: Handle -h and -v options
Commit-ID: a1853e2c6f8ed488adcd84fb162c5b3f0b674d9b Gitweb: http://git.kernel.org/tip/a1853e2c6f8ed488adcd84fb162c5b3f0b674d9b Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 20:06:09 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 16:36:18 -0300
perf tools: Handle -h and -v options
Adding handling for '-h' and '-v' options to invoke help and version command respectively.
Current behaviour is:
$ perf -v Unknown option: -v
Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
$ perf -h Unknown option: -h
Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
New behaviour:
$ perf -h
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites...
$ perf -v perf version 4.3.rc3.gc99e32
Updated man page.
--- tools/perf/Documentation/perf.txt | 8 ++++++++ tools/perf/perf.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+)
tools/perf/Documentation/perf.txt +8 -0
@@ -27,6 +27,14 @@ OPTIONS Setup buildid cache directory. It has higher priority than buildid.dir config file option. +-v:: +--version:: + Display perf version. + +-h:: +--help:: + Run perf help command. + DESCRIPTION ----------- Performance counters for Linux are a new kernel-based subsystem
tools/perf/perf.c +14 -0
@@ -162,6 +162,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)break ;/* +* Shortcut for '-h' and '-v' options to invoke help +* and version command. +*/ +if (!strcmp (cmd,"-h" )) { + (*argv)[0 ] ="--help" ; +break ; + } + +if (!strcmp (cmd,"-v" )) { + (*argv)[0 ] ="--version" ; +break ; + } + +/* * Check remaining flags. */ if (!prefixcmp (cmd,CMD_EXEC_PATH )) {