Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 15 messages Aug 21, 2017 – Aug 22, 2017

Subsystems (3)
lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit 9881223c6cc0644cc3aeea41e1f19ea7e3041f33:

Merge tag 'perf-core-for-mingo-4.14-20170816' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-08-17 09:41:56 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.14-20170821

for you to fetch changes up to 3a555c7799de69d73826eccc9a21948a5775d4d3:

perf annotate browser: Circulate percent, total-period and nr-samples view (2017-08-18 11:23:20 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

- Support --show-nr-samples in annotate's --stdio and --tui, using the existing 't' toggle to circulate 'percent', 'total-period' and 'nr-samples' as the first column (Taeung Song)

- Support FCMask and PortMask in JSON vendor events (Andi Kleen)

- Fix off by one string allocation problem in 'perf trace' (Arnaldo Carvalho de Melo)

- Use just one parse events state struct in yyparse(), fixing one reported segfault when a routine received a different data struct, smaller than the one it expected to use (Arnaldo Carvalho de Melo)

- Remove unused cpu_relax() macros, they stopped being used when tools/perf lived in Documentation/ (Arnaldo Carvalho de Melo)

- Fix double file test in libbpf's Makefile (Daniel Díaz):

----------------------------------------------------------------
Andi Kleen (1):
perf jevents: Support FCMask and PortMask

Arnaldo Carvalho de Melo (7):
perf trace: Fix off by one string allocation problem perf events parse: Remove some needless local variables perf events parse: Rename parsing state struct to clearer name perf events parse: Use just one parse events state struct perf events parse: Rename parse_events_parse arguments perf tools: Remove unused cpu_relax() macros
perf tools: Use default CPUINFO_PROC where it fits

Daniel Díaz (1):
tools lib bpf: Fix double file test in Makefile

Taeung Song (4):
perf annotate stdio: Support --show-nr-samples option
perf annotate: Document --show-total-period option
perf annotate browser: Support --show-nr-samples option
perf annotate browser: Circulate percent, total-period and nr-samples view

 tools/lib/bpf/Makefile                     |  4 +-
 tools/perf/Documentation/perf-annotate.txt |  6 ++
 tools/perf/builtin-annotate.c              | 16 ++++-
 tools/perf/builtin-trace.c                 |  2 +-
 tools/perf/perf-sys.h                      | 28 +--------
 tools/perf/pmu-events/jevents.c            |  2 +
 tools/perf/tests/bpf.c                     | 16 ++---
 tools/perf/ui/browsers/annotate.c          | 25 ++++++--
 tools/perf/util/annotate.c                 |  6 +-
 tools/perf/util/header.c                   |  3 -
 tools/perf/util/parse-events.c             | 96 +++++++++++++++---------------
 tools/perf/util/parse-events.h             | 19 +++---
 tools/perf/util/parse-events.y             | 94 ++++++++++++++---------------
 13 files changed, 159 insertions(+), 158 deletions(-)

Test results:

The first ones are container (docker) based builds of tools/perf with and without libelf support, objtool where it is supported and samples/bpf/, ditto. Where clang is available, it is also used to build perf with/without libelf.

Several are cross builds, the ones with -x-ARCH, and the android one, and those may not have all the features built, due to lack of multi-arch devel packages, available and being used so far on just a few, like debian:experimental-x-{arm64,mipsel}.

The 'perf test' one will perform a variety of tests exercising tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands with a variety of command line event specifications to then intercept the sys_perf_event syscall to check that the perf_event_attr fields are set up as expected, among a variety of other unit tests.

The 'perf test' also runs shell scripts exercising the tools, checking if they affect the system in certain ways, like setting up kprobes and uprobes, request callchains for well known programs and check that they are the expected ones, see if 'perf trace' beautifies system call arguments correctly, etc.

Additionally, a new set of tests, script based, runs the tools in a live system, setting probes in place that then gets used by 'perf trace', with its output compared against expected results.

Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/ with a variety of feature sets, exercising the build with an incomplete set of features as well as with a complete one. It is planned to have it run on each of the containers mentioned above, using some container orchestration infrastructure. Get in contact if interested in helping having this in place.

  # dm
   1 alpine:3.4: Ok
   2 alpine:3.5: Ok
   3 alpine:3.6: Ok
   4 alpine:edge: Ok
   5 android-ndk:r12b-arm: Ok
   6 archlinux:latest: Ok
   7 centos:5: Ok
   8 centos:6: Ok
   9 centos:7: Ok
  10 debian:7: Ok
  11 debian:8: Ok
  12 debian:9: Ok
  13 debian:experimental: Ok
  14 debian:experimental-x-arm64: Ok
  15 debian:experimental-x-mips: Ok
  16 debian:experimental-x-mips64: Ok
  17 debian:experimental-x-mipsel: Ok
  18 fedora:20: Ok
  19 fedora:21: Ok
  20 fedora:22: Ok
  21 fedora:23: Ok
  22 fedora:24: Ok
  23 fedora:24-x-ARC-uClibc: Ok
  24 fedora:25: Ok
  25 fedora:26: Ok
  26 fedora:rawhide: Ok
  27 mageia:5: Ok
  28 opensuse:13.2: Ok
  29 opensuse:42.1: Ok
  30 opensuse:42.2: Ok
  31 opensuse:tumbleweed: Ok
  32 oraclelinux:6: Ok
  33 oraclelinux:7: Ok
  34 ubuntu:12.04.5: Ok
  35 ubuntu:14.04.4: Ok
  36 ubuntu:14.04.4-x-linaro-arm64: Ok
  37 ubuntu:15.10: Ok
  38 ubuntu:16.04: Ok
  39 ubuntu:16.04-x-arm: Ok
  40 ubuntu:16.04-x-arm64: Ok
  41 ubuntu:16.04-x-powerpc: Ok
  42 ubuntu:16.04-x-powerpc64: Ok
  43 ubuntu:16.04-x-powerpc64el: Ok
  44 ubuntu:16.04-x-s390: Ok
  45 ubuntu:16.10: Ok
  46 ubuntu:17.04: Ok
  47 ubuntu:17.10: Ok
  #
  # uname -a
  Linux jouet 4.13.0-rc4+ #2 SMP Fri Aug 11 12:39:09 -03 2017 x86_64 x86_64 x86_64 GNU/Linux
  # perf test
   1: vmlinux symtab matches kallsyms                       : Ok
   2: Detect openat syscall event                           : Ok
   3: Detect openat syscall event on all cpus               : Ok
   4: Read samples using the mmap interface                 : Ok
   5: Parse event definition strings                        : Ok
   6: Simple expression parser                              : Ok
   7: PERF_RECORD_* events & perf_sample fields             : Ok
   8: Parse perf pmu format                                 : Ok
   9: DSO data read                                         : Ok
  10: DSO data cache                                        : Ok
  11: DSO data reopen                                       : Ok
  12: Roundtrip evsel->name                                 : Ok
  13: Parse sched tracepoints fields                        : Ok
  14: syscalls:sys_enter_openat event fields                : Ok
  15: Setup struct perf_event_attr                          : Ok
  16: Match and link multiple hists                         : Ok
  17: 'import perf' in python                               : Ok
  18: Breakpoint overflow signal handler                    : Ok
  19: Breakpoint overflow sampling                          : Ok
  20: Number of exit events of a simple workload            : Ok
  21: Software clock events period values                   : Ok
  22: Object code reading                                   : Ok
  23: Sample parsing                                        : Ok
  24: Use a dummy software event to keep tracking           : Ok
  25: Parse with no sample_id_all bit set                   : Ok
  26: Filter hist entries                                   : Ok
  27: Lookup mmap thread                                    : Ok
  28: Share thread mg                                       : Ok
  29: Sort output of hist entries                           : Ok
  30: Cumulate child hist entries                           : Ok
  31: Track with sched_switch                               : Ok
  32: Filter fds with revents mask in a fdarray             : Ok
  33: Add fd to a fdarray, making it autogrow               : Ok
  34: kmod_path__parse                                      : Ok
  35: Thread map                                            : Ok
  36: LLVM search and compile                               :
  36.1: Basic BPF llvm compile                              : Ok
  36.2: kbuild searching                                    : Ok
  36.3: Compile source for BPF prologue generation          : Ok
  36.4: Compile source for BPF relocation                   : Ok
  37: Session topology                                      : Ok
  38: BPF filter                                            :
  38.1: Basic BPF filtering                                 : Ok
  38.2: BPF pinning                                         : Ok
  38.3: BPF prologue generation                             : Ok
  38.4: BPF relocation checker                              : Ok
  39: Synthesize thread map                                 : Ok
  40: Remove thread map                                     : Ok
  41: Synthesize cpu map                                    : Ok
  42: Synthesize stat config                                : Ok
  43: Synthesize stat                                       : Ok
  44: Synthesize stat round                                 : Ok
  45: Synthesize attr update                                : Ok
  46: Event times                                           : Ok
  47: Read backward ring buffer                             : Ok
  48: Print cpu map                                         : Ok
  49: Probe SDT events                                      : Ok
  50: is_printable_array                                    : Ok
  51: Print bitmap                                          : Ok
  52: perf hooks                                            : Ok
  53: builtin clang support                                 : Skip (not compiled in)
  54: unit_number__scnprintf                                : Ok
  55: x86 rdpmc                                             : Ok
  56: Convert perf time to TSC                              : Ok
  57: DWARF unwind                                          : Ok
  58: x86 instruction decoder - new instructions            : Ok
  59: Intel cqm nmi context read                            : Skip
  60: Use vfs_getname probe to get syscall args filenames   : Ok
  61: probe libc's inet_pton & backtrace it with ping       : Ok
  62: Check open filename arg using perf trace + vfs_getname: Ok
  63: Add vfs_getname probe to get syscall args filenames   : Ok
  #
  $ make -C tools/perf build-test
  make: Entering directory '/home/acme/git/linux/tools/perf'
  - tarpkg: ./tests/perf-targz-src-pkg .
             make_util_map_o_O: make util/map.o
           make_no_libbionic_O: make NO_LIBBIONIC=1
                make_install_O: make install
                   make_tags_O: make tags
                   make_pure_O: make
            make_no_auxtrace_O: make NO_AUXTRACE=1
             make_no_libperl_O: make NO_LIBPERL=1
       make_util_pmu_bison_o_O: make util/pmu-bison.o
                    make_doc_O: make doc
              make_no_libelf_O: make NO_LIBELF=1
               make_no_slang_O: make NO_SLANG=1
                   make_help_O: make help
            make_no_libaudit_O: make NO_LIBAUDIT=1
                 make_perf_o_O: make perf.o
                  make_debug_O: make DEBUG=1
                make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
                  make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
             make_no_libnuma_O: make NO_LIBNUMA=1
         make_install_prefix_O: make install prefix=/tmp/krava
        make_with_babeltrace_O: make LIBBABELTRACE=1
           make_no_libpython_O: make NO_LIBPYTHON=1
   make_install_prefix_slash_O: make install prefix=/tmp/krava/
           make_no_libunwind_O: make NO_LIBUNWIND=1
            make_install_bin_O: make install-bin
             make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
  make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
              make_no_libbpf_O: make NO_LIBBPF=1
                make_no_gtk2_O: make NO_GTK2=1
         make_with_clangllvm_O: make LIBCLANGLLVM=1
              make_clean_all_O: make clean all
            make_no_demangle_O: make NO_DEMANGLE=1
                make_no_newt_O: make NO_NEWT=1
           make_no_backtrace_O: make NO_BACKTRACE=1
  OK
  make: Leaving directory '/home/acme/git/linux/tools/perf'
  $
author maintainer
#1 lore raw

PATCH 1/13 tools lib bpf: Fix double file test in Makefile

From: Daniel Díaz <[email protected]>

The Makefile verifies the same file exists twice:

  test -f ../../../include/uapi/linux/bpf.h -a \
       -f ../../../include/uapi/linux/bpf.h

The purpose of the check is to ensure the diff (immediately after the test) doesn't fail with these two files:

tools/include/uapi/linux/bpf.h
include/uapi/linux/bpf.h

Same recipe for bpf_common:

  test -f ../../../include/uapi/linux/bpf_common.h -a \
       -f ../../../include/uapi/linux/bpf_common.h

This corrects the location of the tests.

---
 tools/lib/bpf/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/Makefile +2 -2
index e87b5903f4bb..4ed0257dc1f3 100644
@@ -154,10 +154,10 @@ all: fixdep $(VERSION_FILES) all_cmd
 all_cmd: $(CMD_TARGETS)
 
 $(BPF_IN): force elfdep bpfdep
-	@(test -f ../../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
+	@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
 	(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
 	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
-	@(test -f ../../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
+	@(test -f ../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
 	(diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linux/bpf_common.h >/dev/null) || \
 	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf_common.h' differs from latest version at 'include/uapi/linux/bpf_common.h'" >&2 )) || true
 	$(Q)$(MAKE) $(build)=libbpf
Signature · 1 line
2.13.5
author maintainer
#2 lore raw

PATCH 2/13 perf jevents: Support FCMask and PortMask

In reply to Arnaldo Carvalho de Melo

From: Andi Kleen <[email protected]>

Skylake server uncore IIO events need new FCMask/PortMask fields. Support those in the json parser and pass it through as a filter.

---
 tools/perf/pmu-events/jevents.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 2350f6099a46..d51dc9ca8861 100644
@@ -137,6 +137,8 @@ static struct field {
 	{ "AnyThread",	"any=" },
 	{ "EdgeDetect",	"edge=" },
 	{ "SampleAfterValue", "period=" },
+	{ "FCMask",	"fc_mask=" },
+	{ "PortMask",	"ch_mask=" },
 	{ NULL, NULL }
 };
 
Signature · 1 line
2.13.5
author maintainer
#3 lore raw

PATCH 3/13 perf trace: Fix off by one string allocation problem

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

We need to consider the null terminator, oops, fix it.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Fixes 017037ff3d0b ("perf trace: Allow specifying list of syscalls and events in -e/--expr/--event")
---
 tools/perf/builtin-trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
index de02413a25d3..91905839e386 100644
@@ -2806,7 +2806,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
 	struct trace *trace = (struct trace *)opt->value;
 	const char *s = str;
 	char *sep = NULL, *lists[2] = { NULL, NULL, };
-	int len = strlen(str), err = -1, list;
+	int len = strlen(str) + 1, err = -1, list;
 	char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
 	char group_name[PATH_MAX];
 
Signature · 1 line
2.13.5
author maintainer
#4 lore raw

PATCH 4/13 perf events parse: Remove some needless local variables

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Those are just casting a void pointer to a struct to then pass them to functions, i.e. remove the local variables and pass the void pointer directly, the casting will be done and the code will be shorter.

---
 tools/perf/util/parse-events.y | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
tools/perf/util/parse-events.y +7 -13
index 04fd8c9af9f9..96c0fa59aa8f 100644
@@ -225,14 +225,13 @@ event_def: event_pmu |
 event_pmu:
 PE_NAME opt_event_config
 {
-	struct parse_events_evlist *data = _data;
 	struct list_head *list, *orig_terms, *terms;
 
 	if (parse_events_copy_term_list($2, &orig_terms))
 		YYABORT;
 
 	ALLOC_LIST(list);
-	if (parse_events_add_pmu(data, list, $1, $2)) {
+	if (parse_events_add_pmu(_data, list, $1, $2)) {
 		struct perf_pmu *pmu = NULL;
 		int ok = 0;
 
@@ -245,7 +244,7 @@ PE_NAME opt_event_config
 			if (!strncmp($1, name, strlen($1))) {
 				if (parse_events_copy_term_list(orig_terms, &terms))
 					YYABORT;
-				if (!parse_events_add_pmu(data, list, pmu->name, terms))
+				if (!parse_events_add_pmu(_data, list, pmu->name, terms))
 					ok++;
 				parse_events_terms__delete(terms);
 			}
@@ -286,26 +285,24 @@ PE_VALUE_SYM_SW
 event_legacy_symbol:
 value_sym '/' event_config '/'
 {
-	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 	int type = $1 >> 16;
 	int config = $1 & 255;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(data, list, type, config, $3));
+	ABORT_ON(parse_events_add_numeric(_data, list, type, config, $3));
 	parse_events_terms__delete($3);
 	$$ = list;
 }
 |
 value_sym sep_slash_dc
 {
-	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 	int type = $1 >> 16;
 	int config = $1 & 255;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL));
+	ABORT_ON(parse_events_add_numeric(_data, list, type, config, NULL));
 	$$ = list;
 }
 
@@ -432,11 +429,10 @@ PE_NAME ':' PE_NAME
 event_legacy_numeric:
 PE_VALUE ':' PE_VALUE opt_event_config
 {
-	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4));
+	ABORT_ON(parse_events_add_numeric(_data, list, (u32)$1, $3, $4));
 	parse_events_terms__delete($4);
 	$$ = list;
 }
@@ -444,11 +440,10 @@ PE_VALUE ':' PE_VALUE opt_event_config
 event_legacy_raw:
 PE_RAW opt_event_config
 {
-	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2));
+	ABORT_ON(parse_events_add_numeric(_data, list, PERF_TYPE_RAW, $1, $2));
 	parse_events_terms__delete($2);
 	$$ = list;
 }
@@ -468,11 +463,10 @@ PE_BPF_OBJECT opt_event_config
 |
 PE_BPF_SOURCE opt_event_config
 {
-	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_load_bpf(data, list, $1, true, $2));
+	ABORT_ON(parse_events_load_bpf(_data, list, $1, true, $2));
 	parse_events_terms__delete($2);
 	$$ = list;
 }
Signature · 1 line
2.13.5
author maintainer
#5 lore raw

PATCH 5/13 perf events parse: Rename parsing state struct to clearer name

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Rename it from 'parse_events_evlist' to 'parse_events_state' to better state that this is parsing state that has to be passed around.

---
 tools/perf/tests/bpf.c         |  2 +-
 tools/perf/util/parse-events.c | 24 ++++++++++++------------
 tools/perf/util/parse-events.h | 14 +++++++-------
 tools/perf/util/parse-events.y | 22 +++++++++++-----------
 4 files changed, 31 insertions(+), 31 deletions(-)
tools/perf/tests/bpf.c +1 -1
index 4422ab636d30..45ad248e6ccd 100644
@@ -124,7 +124,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
 	struct perf_evlist *evlist;
 	int i, ret = TEST_FAIL, err = 0, count = 0;
 
-	struct parse_events_evlist parse_evlist;
+	struct parse_events_state parse_evlist;
 	struct parse_events_error parse_error;
 
 	bzero(&parse_error, sizeof(parse_error));
tools/perf/util/parse-events.c +12 -12
index 84e301073885..272eab7f5ac8 100644
@@ -589,7 +589,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
 }
 
 struct __add_bpf_event_param {
-	struct parse_events_evlist *data;
+	struct parse_events_state *data;
 	struct list_head *list;
 	struct list_head *head_config;
 };
@@ -599,7 +599,7 @@ static int add_bpf_event(const char *group, const char *event, int fd,
 {
 	LIST_HEAD(new_evsels);
 	struct __add_bpf_event_param *param = _param;
-	struct parse_events_evlist *evlist = param->data;
+	struct parse_events_state *parse_state = param->data;
 	struct list_head *list = param->list;
 	struct perf_evsel *pos;
 	int err;
@@ -607,8 +607,8 @@ static int add_bpf_event(const char *group, const char *event, int fd,
 	pr_debug("add bpf event %s:%s and attach bpf program %d\n",
 		 group, event, fd);
 
-	err = parse_events_add_tracepoint(&new_evsels, &evlist->idx, group,
-					  event, evlist->error,
+	err = parse_events_add_tracepoint(&new_evsels, &parse_state->idx, group,
+					  event, parse_state->error,
 					  param->head_config);
 	if (err) {
 		struct perf_evsel *evsel, *tmp;
@@ -632,7 +632,7 @@ static int add_bpf_event(const char *group, const char *event, int fd,
 	return 0;
 }
 
-int parse_events_load_bpf_obj(struct parse_events_evlist *data,
+int parse_events_load_bpf_obj(struct parse_events_state *data,
 			      struct list_head *list,
 			      struct bpf_object *obj,
 			      struct list_head *head_config)
@@ -686,7 +686,7 @@ int parse_events_load_bpf_obj(struct parse_events_evlist *data,
 }
 
 static int
-parse_events_config_bpf(struct parse_events_evlist *data,
+parse_events_config_bpf(struct parse_events_state *data,
 			struct bpf_object *obj,
 			struct list_head *head_config)
 {
@@ -762,7 +762,7 @@ split_bpf_config_terms(struct list_head *evt_head_config,
 			list_move_tail(&term->list, obj_head_config);
 }
 
-int parse_events_load_bpf(struct parse_events_evlist *data,
+int parse_events_load_bpf(struct parse_events_state *data,
 			  struct list_head *list,
 			  char *bpf_file_name,
 			  bool source,
@@ -1184,7 +1184,7 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
 					    err, head_config);
 }
 
-int parse_events_add_numeric(struct parse_events_evlist *data,
+int parse_events_add_numeric(struct parse_events_state *data,
 			     struct list_head *list,
 			     u32 type, u64 config,
 			     struct list_head *head_config)
@@ -1209,7 +1209,7 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
 			 get_config_name(head_config), &config_terms);
 }
 
-int parse_events_add_pmu(struct parse_events_evlist *data,
+int parse_events_add_pmu(struct parse_events_state *data,
 			 struct list_head *list, char *name,
 			 struct list_head *head_config)
 {
@@ -1267,7 +1267,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
 	return evsel ? 0 : -ENOMEM;
 }
 
-int parse_events_multi_pmu_add(struct parse_events_evlist *data,
+int parse_events_multi_pmu_add(struct parse_events_state *data,
 			       char *str, struct list_head **listp)
 {
 	struct list_head *head;
@@ -1675,7 +1675,7 @@ int parse_events_terms(struct list_head *terms, const char *str)
 int parse_events(struct perf_evlist *evlist, const char *str,
 		 struct parse_events_error *err)
 {
-	struct parse_events_evlist data = {
+	struct parse_events_state data = {
 		.list   = LIST_HEAD_INIT(data.list),
 		.idx    = evlist->nr_entries,
 		.error  = err,
@@ -2520,7 +2520,7 @@ void parse_events__clear_array(struct parse_events_array *a)
 	zfree(&a->ranges);
 }
 
-void parse_events_evlist_error(struct parse_events_evlist *data,
+void parse_events_evlist_error(struct parse_events_state *data,
 			       int idx, const char *str)
 {
 	struct parse_events_error *err = data->error;
tools/perf/util/parse-events.h +7 -7
index a235f4d6d5e5..8fff8423469b 100644
@@ -108,7 +108,7 @@ struct parse_events_error {
 	char *help;	/* optional help string */
 };
 
-struct parse_events_evlist {
+struct parse_events_state {
 	struct list_head	   list;
 	int			   idx;
 	int			   nr_groups;
@@ -143,18 +143,18 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
 				const char *sys, const char *event,
 				struct parse_events_error *error,
 				struct list_head *head_config);
-int parse_events_load_bpf(struct parse_events_evlist *data,
+int parse_events_load_bpf(struct parse_events_state *data,
 			  struct list_head *list,
 			  char *bpf_file_name,
 			  bool source,
 			  struct list_head *head_config);
 /* Provide this function for perf test */
 struct bpf_object;
-int parse_events_load_bpf_obj(struct parse_events_evlist *data,
+int parse_events_load_bpf_obj(struct parse_events_state *data,
 			      struct list_head *list,
 			      struct bpf_object *obj,
 			      struct list_head *head_config);
-int parse_events_add_numeric(struct parse_events_evlist *data,
+int parse_events_add_numeric(struct parse_events_state *data,
 			     struct list_head *list,
 			     u32 type, u64 config,
 			     struct list_head *head_config);
@@ -164,11 +164,11 @@ int parse_events_add_cache(struct list_head *list, int *idx,
 			   struct list_head *head_config);
 int parse_events_add_breakpoint(struct list_head *list, int *idx,
 				void *ptr, char *type, u64 len);
-int parse_events_add_pmu(struct parse_events_evlist *data,
+int parse_events_add_pmu(struct parse_events_state *data,
 			 struct list_head *list, char *name,
 			 struct list_head *head_config);
 
-int parse_events_multi_pmu_add(struct parse_events_evlist *data,
+int parse_events_multi_pmu_add(struct parse_events_state *data,
 			       char *str,
 			       struct list_head **listp);
 
@@ -180,7 +180,7 @@ perf_pmu__parse_check(const char *name);
 void parse_events__set_leader(char *name, struct list_head *list);
 void parse_events_update_lists(struct list_head *list_event,
 			       struct list_head *list_all);
-void parse_events_evlist_error(struct parse_events_evlist *data,
+void parse_events_evlist_error(struct parse_events_state *data,
 			       int idx, const char *str);
 
 void print_events(const char *event_glob, bool name_only, bool quiet,
tools/perf/util/parse-events.y +11 -11
index 96c0fa59aa8f..403a221266b8 100644
@@ -33,7 +33,7 @@ do { \
 } while (0)
 
 static void inc_group_count(struct list_head *list,
-		       struct parse_events_evlist *data)
+		       struct parse_events_state *data)
 {
 	/* Count groups only have more than 1 members */
 	if (!list_is_last(list->next, list))
@@ -115,7 +115,7 @@ PE_START_TERMS  start_terms
 
 start_events: groups
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 
 	parse_events_update_lists($1, &data->list);
 }
@@ -309,7 +309,7 @@ value_sym sep_slash_dc
 event_legacy_cache:
 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct parse_events_error *error = data->error;
 	struct list_head *list;
 
@@ -321,7 +321,7 @@ PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_e
 |
 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct parse_events_error *error = data->error;
 	struct list_head *list;
 
@@ -333,7 +333,7 @@ PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
 |
 PE_NAME_CACHE_TYPE opt_event_config
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct parse_events_error *error = data->error;
 	struct list_head *list;
 
@@ -346,7 +346,7 @@ PE_NAME_CACHE_TYPE opt_event_config
 event_legacy_mem:
 PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
@@ -357,7 +357,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
 |
 PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
@@ -368,7 +368,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
 |
 PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
@@ -379,7 +379,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
 |
 PE_PREFIX_MEM PE_VALUE sep_dc
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
@@ -391,7 +391,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc
 event_legacy_tracepoint:
 tracepoint_name opt_event_config
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct parse_events_error *error = data->error;
 	struct list_head *list;
 
@@ -451,7 +451,7 @@ PE_RAW opt_event_config
 event_bpf_file:
 PE_BPF_OBJECT opt_event_config
 {
-	struct parse_events_evlist *data = _data;
+	struct parse_events_state *data = _data;
 	struct parse_events_error *error = data->error;
 	struct list_head *list;
 
Signature · 1 line
2.13.5
author maintainer
#6 lore raw

PATCH 6/13 perf events parse: Use just one parse events state struct

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Andi reported problems when parse errors were detected with vendor events (json), because in the yyparse/parse_events_parse function we dereferenced the _data parameter to two different structs, with different layouts, which ended up making parse_events_evlist->error to point to random stack addresses.

Fix it by making _data to always be struct parse_events_state, changing the only place where 'struct parse_events_term' was used in parse_events.y.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Fixes 90e2b22dee90 ("perf/tool: Add support to reuse event grammar to parse out terms")
---
 tools/perf/util/parse-events.c | 2 +-
 tools/perf/util/parse-events.h | 5 +----
 tools/perf/util/parse-events.y | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)
tools/perf/util/parse-events.c +1 -1
index 272eab7f5ac8..d4fcf048aa9e 100644
@@ -1656,7 +1656,7 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
  */
 int parse_events_terms(struct list_head *terms, const char *str)
 {
-	struct parse_events_terms data = {
+	struct parse_events_state data = {
 		.terms = NULL,
 	};
 	int ret;
tools/perf/util/parse-events.h +1 -4
index 8fff8423469b..2a3617937894 100644
@@ -114,10 +114,7 @@ struct parse_events_state {
 	int			   nr_groups;
 	struct parse_events_error *error;
 	struct perf_evlist	  *evlist;
-};
-
-struct parse_events_terms {
-	struct list_head *terms;
+	struct list_head	  *terms;
 };
 
 void parse_events__shrink_config_terms(void);
tools/perf/util/parse-events.y +1 -1
index 403a221266b8..4b37546e4914 100644
@@ -488,7 +488,7 @@ opt_event_config:
 
 start_terms: event_config
 {
-	struct parse_events_terms *data = _data;
+	struct parse_events_state *data = _data;
 	data->terms = $1;
 }
 
Signature · 1 line
2.13.5
author maintainer
#7 lore raw

PATCH 7/13 perf events parse: Rename parse_events_parse arguments

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Calling them just "data" is too vague, call it 'perf_state', to make it clearer, for instance, when looking at patch hunks.

---
 tools/perf/tests/bpf.c         | 16 ++++----
 tools/perf/util/parse-events.c | 92 +++++++++++++++++++++---------------------
 tools/perf/util/parse-events.h | 12 +++---
 tools/perf/util/parse-events.y | 88 ++++++++++++++++++++--------------------
 4 files changed, 104 insertions(+), 104 deletions(-)
tools/perf/tests/bpf.c +8 -8
index 45ad248e6ccd..34c22cdf4d5d 100644
@@ -124,16 +124,16 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
 	struct perf_evlist *evlist;
 	int i, ret = TEST_FAIL, err = 0, count = 0;
 
-	struct parse_events_state parse_evlist;
+	struct parse_events_state parse_state;
 	struct parse_events_error parse_error;
 
 	bzero(&parse_error, sizeof(parse_error));
-	bzero(&parse_evlist, sizeof(parse_evlist));
-	parse_evlist.error = &parse_error;
-	INIT_LIST_HEAD(&parse_evlist.list);
+	bzero(&parse_state, sizeof(parse_state));
+	parse_state.error = &parse_error;
+	INIT_LIST_HEAD(&parse_state.list);
 
-	err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj, NULL);
-	if (err || list_empty(&parse_evlist.list)) {
+	err = parse_events_load_bpf_obj(&parse_state, &parse_state.list, obj, NULL);
+	if (err || list_empty(&parse_state.list)) {
 		pr_debug("Failed to add events selected by BPF\n");
 		return TEST_FAIL;
 	}
@@ -155,8 +155,8 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
 		goto out_delete_evlist;
 	}
 
-	perf_evlist__splice_list_tail(evlist, &parse_evlist.list);
-	evlist->nr_groups = parse_evlist.nr_groups;
+	perf_evlist__splice_list_tail(evlist, &parse_state.list);
+	evlist->nr_groups = parse_state.nr_groups;
 
 	perf_evlist__config(evlist, &opts, NULL);
 
tools/perf/util/parse-events.c +46 -46

275 lines not on this page · raw message

tools/perf/util/parse-events.h +6 -6
index 2a3617937894..635135125111 100644
@@ -140,18 +140,18 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
 				const char *sys, const char *event,
 				struct parse_events_error *error,
 				struct list_head *head_config);
-int parse_events_load_bpf(struct parse_events_state *data,
+int parse_events_load_bpf(struct parse_events_state *parse_state,
 			  struct list_head *list,
 			  char *bpf_file_name,
 			  bool source,
 			  struct list_head *head_config);
 /* Provide this function for perf test */
 struct bpf_object;
-int parse_events_load_bpf_obj(struct parse_events_state *data,
+int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
 			      struct list_head *list,
 			      struct bpf_object *obj,
 			      struct list_head *head_config);
-int parse_events_add_numeric(struct parse_events_state *data,
+int parse_events_add_numeric(struct parse_events_state *parse_state,
 			     struct list_head *list,
 			     u32 type, u64 config,
 			     struct list_head *head_config);
@@ -161,11 +161,11 @@ int parse_events_add_cache(struct list_head *list, int *idx,
 			   struct list_head *head_config);
 int parse_events_add_breakpoint(struct list_head *list, int *idx,
 				void *ptr, char *type, u64 len);
-int parse_events_add_pmu(struct parse_events_state *data,
+int parse_events_add_pmu(struct parse_events_state *parse_state,
 			 struct list_head *list, char *name,
 			 struct list_head *head_config);
 
-int parse_events_multi_pmu_add(struct parse_events_state *data,
+int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
 			       char *str,
 			       struct list_head **listp);
 
@@ -177,7 +177,7 @@ perf_pmu__parse_check(const char *name);
 void parse_events__set_leader(char *name, struct list_head *list);
 void parse_events_update_lists(struct list_head *list_event,
 			       struct list_head *list_all);
-void parse_events_evlist_error(struct parse_events_state *data,
+void parse_events_evlist_error(struct parse_events_state *parse_state,
 			       int idx, const char *str);
 
 void print_events(const char *event_glob, bool name_only, bool quiet,
tools/perf/util/parse-events.y +44 -44

277 lines not on this page · raw message

Signature · 1 line
2.13.5
author maintainer
#8 lore raw

PATCH 8/13 perf tools: Remove unused cpu_relax() macros

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Since 195564390210 ("perf_counter: kerneltop: simplify data_head read") we do not use it, and this was way back in 2009, remove it before some other arch maintainer adds its implementation, like so many did, needlessly :-)

---
 tools/perf/perf-sys.h | 9 ---------
 1 file changed, 9 deletions(-)
tools/perf/perf-sys.h +0 -9
index e4b717e9eb6c..2aaa7366cdc2 100644
@@ -10,12 +10,10 @@
 #include <asm/barrier.h>
 
 #if defined(__i386__)
-#define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 #define CPUINFO_PROC	{"model name"}
 #endif
 
 #if defined(__x86_64__)
-#define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 #define CPUINFO_PROC	{"model name"}
 #endif
 
@@ -44,7 +42,6 @@
 #endif
 
 #ifdef __ia64__
-#define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
 #define CPUINFO_PROC	{"model name"}
 #endif
 
@@ -53,7 +50,6 @@
 #endif
 
 #ifdef __aarch64__
-#define cpu_relax()	asm volatile("yield" ::: "memory")
 #endif
 
 #ifdef __mips__
@@ -73,14 +69,9 @@
 #endif
 
 #ifdef __tile__
-#define cpu_relax()	asm volatile ("mfspr zero, PASS" ::: "memory")
 #define CPUINFO_PROC    {"model name"}
 #endif
 
-#ifndef cpu_relax
-#define cpu_relax() barrier()
-#endif
-
 static inline int
 sys_perf_event_open(struct perf_event_attr *attr,
 		      pid_t pid, int cpu, int group_fd,
Signature · 1 line
2.13.5
author maintainer
#9 lore raw

PATCH 9/13 perf tools: Use default CPUINFO_PROC where it fits

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Several architectures don't need to define it since the string is the same as the default one, so nuke them.

---
 tools/perf/perf-sys.h    | 19 ++-----------------
 tools/perf/util/header.c |  3 ---
 2 files changed, 2 insertions(+), 20 deletions(-)
tools/perf/perf-sys.h +2 -17
index 2aaa7366cdc2..c11f0c76e90c 100644
@@ -9,14 +9,6 @@
 #include <linux/perf_event.h>
 #include <asm/barrier.h>
 
-#if defined(__i386__)
-#define CPUINFO_PROC	{"model name"}
-#endif
-
-#if defined(__x86_64__)
-#define CPUINFO_PROC	{"model name"}
-#endif
-
 #ifdef __powerpc__
 #define CPUINFO_PROC	{"cpu"}
 #endif
@@ -41,17 +33,10 @@
 #define CPUINFO_PROC	{"cpu model"}
 #endif
 
-#ifdef __ia64__
-#define CPUINFO_PROC	{"model name"}
-#endif
-
 #ifdef __arm__
 #define CPUINFO_PROC	{"model name", "Processor"}
 #endif
 
-#ifdef __aarch64__
-#endif
-
 #ifdef __mips__
 #define CPUINFO_PROC	{"cpu model"}
 #endif
@@ -68,8 +53,8 @@
 #define CPUINFO_PROC	{"core ID"}
 #endif
 
-#ifdef __tile__
-#define CPUINFO_PROC    {"model name"}
+#ifndef CPUINFO_PROC
+#define CPUINFO_PROC	{ "model name", }
 #endif
 
 static inline int
tools/perf/util/header.c +0 -3
index 28bf4442d577..605bbd5404fb 100644
@@ -380,9 +380,6 @@ static int __write_cpudesc(struct feat_fd *ff, const char *cpuinfo_proc)
 static int write_cpudesc(struct feat_fd *ff,
 		       struct perf_evlist *evlist __maybe_unused)
 {
-#ifndef CPUINFO_PROC
-#define CPUINFO_PROC {"model name", }
-#endif
 	const char *cpuinfo_procs[] = CPUINFO_PROC;
 	unsigned int i;
 
Signature · 1 line
2.13.5
author maintainer
#10 lore raw

PATCH 10/13 perf annotate stdio: Support --show-nr-samples option

In reply to Arnaldo Carvalho de Melo

From: Taeung Song <[email protected]>

Add --show-nr-samples option to "perf annotate" so that it matches "perf report".

Committer note:

Note that it can't be used together with --show-total-period, which seems like a silly limitation, that can be lifted at some point.

Made it bail out if not on --stdio.

---
 tools/perf/Documentation/perf-annotate.txt |  4 ++++
 tools/perf/builtin-annotate.c              | 16 ++++++++++++++--
 tools/perf/util/annotate.c                 |  6 +++++-
 3 files changed, 23 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-annotate.txt +4 -0
index a89273d8e744..2a5975c91cbd 100644
@@ -43,6 +43,10 @@ OPTIONS
 --quiet::
 	Do not show any message.  (Suppress -v)
 
+-n::
+--show-nr-samples::
+	Show the number of samples for each symbol
+
 -D::
 --dump-raw-trace::
         Dump raw trace in ASCII.
tools/perf/builtin-annotate.c +14 -2
index 658c920d74b9..89fc0389dc76 100644
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
 	struct perf_data_file file = {
 		.mode  = PERF_DATA_MODE_READ,
 	};
-	const struct option options[] = {
+	struct option options[] = {
 	OPT_STRING('i', "input", &input_name, "file",
 		    "input file name"),
 	OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
@@ -445,13 +445,20 @@ int cmd_annotate(int argc, const char **argv)
 		    "Show event group information together"),
 	OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
 		    "Show a column with the sum of periods"),
+	OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
+		    "Show a column with the number of samples"),
 	OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 			     "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
 			     stdio__config_color, "always"),
 	OPT_END()
 	};
-	int ret = hists__init();
+	int ret;
+
+	set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+	set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
+
 
+	ret = hists__init();
 	if (ret < 0)
 		return ret;
 
@@ -467,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
 		annotate.sym_hist_filter = argv[0];
 	}
 
+	if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
+		pr_err("--show-nr-samples is only available in --stdio mode at this time\n");
+		return ret;
+	}
+
 	if (quiet)
 		perf_quiet_option();
 
tools/perf/util/annotate.c +5 -1
index 2dab0e5a7f2f..4397a8b6e6cd 100644
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
 			if (symbol_conf.show_total_period)
 				color_fprintf(stdout, color, " %11" PRIu64,
 					      sample.period);
+			else if (symbol_conf.show_nr_samples)
+				color_fprintf(stdout, color, " %7" PRIu64,
+					      sample.nr_samples);
 			else
 				color_fprintf(stdout, color, " %7.2f", percent);
 		}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 		width *= evsel->nr_members;
 
 	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
-				  width, width, symbol_conf.show_total_period ? "Event count" : "Percent",
+				  width, width, symbol_conf.show_total_period ? "Period" :
+				  symbol_conf.show_nr_samples ? "Samples" : "Percent",
 				  d_filename, evsel_name, h->nr_samples);
 
 	printf("%-*.*s----\n",
Signature · 1 line
2.13.5
author maintainer
#11 lore raw

PATCH 11/13 perf annotate: Document --show-total-period option

In reply to Arnaldo Carvalho de Melo

From: Taeung Song <[email protected]>

When the --show-total-period option was introduced we forgot to add an entry in the man page, fix it.

Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Martin Liška <[email protected]>
Fixes 0c4a5bcea460 ("perf annotate: Display total number of samples with --show-total-period")
---
 tools/perf/Documentation/perf-annotate.txt | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/Documentation/perf-annotate.txt +2 -0
index 2a5975c91cbd..c635eab6af54 100644
@@ -92,6 +92,8 @@ OPTIONS
 --asm-raw::
 	Show raw instruction encoding of assembly instructions.
 
+--show-total-period:: Show a column with the sum of periods.
+
 --source::
 	Interleave source code with assembly code. Enabled by default,
 	disable with --no-source.
Signature · 1 line
2.13.5
author maintainer
#12 lore raw

PATCH 12/13 perf annotate browser: Support --show-nr-samples option

In reply to Arnaldo Carvalho de Melo

From: Taeung Song <[email protected]>

Support the --show-nr-samples in the TUI browser.

Committer notes:

Lift the restriction about --tui but leave it for --gtk:

  $ export LD_LIBRARY_PATH=~/lib64
  $ perf annotate --gtk --show-nr-samples --show-nr-samples is not available in --gtk mode at this time
  $
---
 tools/perf/builtin-annotate.c     |  4 ++--
 tools/perf/ui/browsers/annotate.c | 14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
tools/perf/builtin-annotate.c +2 -2
index 89fc0389dc76..c38373195c4a 100644
@@ -474,8 +474,8 @@ int cmd_annotate(int argc, const char **argv)
 		annotate.sym_hist_filter = argv[0];
 	}
 
-	if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
-		pr_err("--show-nr-samples is only available in --stdio mode at this time\n");
+	if (symbol_conf.show_nr_samples && annotate.use_gtk) {
+		pr_err("--show-nr-samples is not available in --gtk mode at this time\n");
 		return ret;
 	}
 
tools/perf/ui/browsers/annotate.c +11 -3
index 80f38dab9c3a..faca1b94496e 100644
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 	     jump_arrows,
 	     show_linenr,
 	     show_nr_jumps,
+	     show_nr_samples,
 	     show_total_period;
 } annotate_browser__opts = {
 	.use_offset	= true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
 			if (annotate_browser__opts.show_total_period) {
 				ui_browser__printf(browser, "%11" PRIu64 " ",
 						   bdl->samples[i].he.period);
+			} else if (annotate_browser__opts.show_nr_samples) {
+				ui_browser__printf(browser, "%6" PRIu64 " ",
+						   bdl->samples[i].he.nr_samples);
 			} else {
 				ui_browser__printf(browser, "%6.2f ",
 						   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
 			ui_browser__write_nstring(browser, " ", pcnt_width);
 		else {
 			ui_browser__printf(browser, "%*s", pcnt_width,
-					   annotate_browser__opts.show_total_period ? "Period" : "Percent");
+					   annotate_browser__opts.show_total_period ? "Period" :
+					   annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
 		}
 	}
 	if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser *browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 			     struct hist_browser_timer *hbt)
 {
-	/* Set default value for show_total_period.  */
+	/* Set default value for show_total_period and show_nr_samples  */
 	annotate_browser__opts.show_total_period =
-	  symbol_conf.show_total_period;
+		symbol_conf.show_total_period;
+	annotate_browser__opts.show_nr_samples =
+		symbol_conf.show_nr_samples;
 
 	return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
 	ANNOTATE_CFG(jump_arrows),
 	ANNOTATE_CFG(show_linenr),
 	ANNOTATE_CFG(show_nr_jumps),
+	ANNOTATE_CFG(show_nr_samples),
 	ANNOTATE_CFG(show_total_period),
 	ANNOTATE_CFG(use_offset),
 };
Signature · 1 line
2.13.5
author maintainer
#13 lore raw

PATCH 13/13 perf annotate browser: Circulate percent, total-period and nr-samples view

In reply to Arnaldo Carvalho de Melo

From: Taeung Song <[email protected]>

Using the existing 't' hotkey, support the three views: percent, total period and number of samples on the annotate TUI browser, circulating them like below:

Percent -> Total Period -> Nr Samples -> Percent ...

Committer notes:

Removed new 'e' hotkey, should be resubmitted as a separate patch, with proper justification for its inclusion.

---
 tools/perf/ui/browsers/annotate.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/annotate.c +8 -3
index faca1b94496e..ba0aee576a2b 100644
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
 		"n             Search next string\n"
 		"o             Toggle disassembler output/simplified view\n"
 		"s             Toggle source code view\n"
-		"t             Toggle total period view\n"
+		"t             Circulate percent, total period, samples view\n"
 		"/             Search string\n"
 		"k             Toggle line numbers\n"
 		"r             Run available scripts\n"
@@ -912,8 +912,13 @@ static int annotate_browser__run(struct annotate_browser *browser,
 			}
 			continue;
 		case 't':
-			annotate_browser__opts.show_total_period =
-			  !annotate_browser__opts.show_total_period;
+			if (annotate_browser__opts.show_total_period) {
+				annotate_browser__opts.show_total_period = false;
+				annotate_browser__opts.show_nr_samples = true;
+			} else if (annotate_browser__opts.show_nr_samples)
+				annotate_browser__opts.show_nr_samples = false;
+			else
+				annotate_browser__opts.show_total_period = true;
 			annotate_browser__update_addr_width(browser);
 			continue;
 		case K_LEFT:
Signature · 1 line
2.13.5
#14 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 64 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit 9881223c6cc0644cc3aeea41e1f19ea7e3041f33:

Merge tag 'perf-core-for-mingo-4.14-20170816' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-08-17 09:41:56 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.14-20170821

for you to fetch changes up to 3a555c7799de69d73826eccc9a21948a5775d4d3:

perf annotate browser: Circulate percent, total-period and nr-samples view (2017-08-18 11:23:20 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

- Support --show-nr-samples in annotate's --stdio and --tui, using the existing 't' toggle to circulate 'percent', 'total-period' and 'nr-samples' as the first column (Taeung Song)

- Support FCMask and PortMask in JSON vendor events (Andi Kleen)

- Fix off by one string allocation problem in 'perf trace' (Arnaldo Carvalho de Melo)

- Use just one parse events state struct in yyparse(), fixing one reported segfault when a routine received a different data struct, smaller than the one it expected to use (Arnaldo Carvalho de Melo)

- Remove unused cpu_relax() macros, they stopped being used when tools/perf lived in Documentation/ (Arnaldo Carvalho de Melo)

- Fix double file test in libbpf's Makefile (Daniel Díaz):

----------------------------------------------------------------
Andi Kleen (1):
perf jevents: Support FCMask and PortMask

Arnaldo Carvalho de Melo (7):
perf trace: Fix off by one string allocation problem perf events parse: Remove some needless local variables perf events parse: Rename parsing state struct to clearer name perf events parse: Use just one parse events state struct perf events parse: Rename parse_events_parse arguments perf tools: Remove unused cpu_relax() macros
perf tools: Use default CPUINFO_PROC where it fits

Daniel Díaz (1):
tools lib bpf: Fix double file test in Makefile

Taeung Song (4):
perf annotate stdio: Support --show-nr-samples option
perf annotate: Document --show-total-period option
perf annotate browser: Support --show-nr-samples option
perf annotate browser: Circulate percent, total-period and nr-samples view

Quoted 14 lines
 tools/lib/bpf/Makefile                     |  4 +-
 tools/perf/Documentation/perf-annotate.txt |  6 ++
 tools/perf/builtin-annotate.c              | 16 ++++-
 tools/perf/builtin-trace.c                 |  2 +-
 tools/perf/perf-sys.h                      | 28 +--------
 tools/perf/pmu-events/jevents.c            |  2 +
 tools/perf/tests/bpf.c                     | 16 ++---
 tools/perf/ui/browsers/annotate.c          | 25 ++++++--
 tools/perf/util/annotate.c                 |  6 +-
 tools/perf/util/header.c                   |  3 -
 tools/perf/util/parse-events.c             | 96 +++++++++++++++---------------
 tools/perf/util/parse-events.h             | 19 +++---
 tools/perf/util/parse-events.y             | 94 ++++++++++++++---------------
 13 files changed, 159 insertions(+), 158 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo