Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL In review Arnaldo Carvalho de Melo 8 participants 55 messages Oct 5, 2015 – Oct 22, 2015 1 message not in the archive perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit e3b0ac1b7a8a590440a2030e7d10d48c59ab8a2a:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-10-03 08:20:14 +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

for you to fetch changes up to 27bf90bf0690f55c3679bcc4c325823cf1cfd19d:

perf tools: Fail properly in case pattern matching fails to find tracepoint (2015-10-05 17:59:50 -0300)

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

User visible:

- Switch the default callchain output mode to 'graph,0.5,caller', to make it look like the default for other tools, reducing the learning curve for people used to 'caller' based viewing (Arnaldo Carvalho de Melo)

- Implement column based horizontal scrolling in the hists browser (top, report), making it possible to use the TUI for things like 'perf mem report' where there are many more columns than can fit in a terminal (Arnaldo Carvalho de Melo)

- Support sorting by symbol_iaddr with perf.data files produced by 'perf mem record' (Don Zickus)

- Display DATA_SRC sample type bit, i.e. when running 'perf evlist -v' the "DATA_SRC" wasn't appearing when set, fix it to look like: (Jiri Olsa)

cpu/mem-loads/pp: ...SNIP... sample_type: IP|TID|TIME|ADDR|CPU|PERIOD|DATA_SRC

- Introduce 'P' event modified, meaning 'max precision level, please', i.e.:

   $ perf record -e cycles:P usleep 1

Is now similar to:

   $ perf record usleep 1

Useful, for instance, when specifying multiple events (Jiri Olsa)

- Make 'perf -v' and 'perf -h' work (Jiri Olsa)

- Fail properly when pattern matching fails to find a tracepoint, i.e. '-e non:existent' was being correctly handled, with a proper error message about that not being a valid event, but '-e non:existent*' wasn't, fix it (Jiri Olsa)

Infrastructure:

- Separate arch specific entries in 'perf test' and add an 'Intel CQM' one to be fun on x86 only (Matt Fleming)

----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf callchain: Switch default to 'graph,0.5,caller' perf ui browser: Optional horizontal scrolling key binding perf hists browser: Implement horizontal scrolling

Don Zickus (1):
perf tools: Add support for sorting on the iaddr

Jiri Olsa (9):
tools lib api fs: No need to use PATH_MAX + 1
perf evlist: Display DATA_SRC sample type bit
perf annotate: Fix sizeof_sym_hist overflow issue
perf tools: Export perf_event_attr__set_max_precise_ip()
perf tools: Introduce 'P' modifier to request max precision perf tests: Add parsing test for 'P' modifier
perf tools: Setup proper width for symbol_iaddr field
perf tools: Handle -h and -v options
perf tools: Fail properly in case pattern matching fails to find tracepoint

Matt Fleming (3):
perf tests: Add arch tests
perf tests: Move x86 tests into arch directory perf tests: Add Intel CQM test

 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-report.txt           |   2 +-
 tools/perf/Documentation/perf.txt                  |   8 ++
 tools/perf/arch/x86/Build                          |   2 +-
 tools/perf/arch/x86/include/arch-tests.h           |  19 ++++
 tools/perf/arch/x86/tests/Build                    |  10 +-
 tools/perf/arch/x86/tests/arch-tests.c             |  34 ++++++
 tools/perf/arch/x86/tests/dwarf-unwind.c           |   1 +
 .../perf/{ => arch/x86}/tests/gen-insn-x86-dat.awk |   0
 .../perf/{ => arch/x86}/tests/gen-insn-x86-dat.sh  |   0
 tools/perf/{ => arch/x86}/tests/insn-x86-dat-32.c  |   0
 tools/perf/{ => arch/x86}/tests/insn-x86-dat-64.c  |   0
 tools/perf/{ => arch/x86}/tests/insn-x86-dat-src.c |   0
 tools/perf/{ => arch/x86}/tests/insn-x86.c         |   3 +-
 tools/perf/arch/x86/tests/intel-cqm.c              | 124 +++++++++++++++++++++
 tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   4 +-
 tools/perf/{ => arch/x86}/tests/rdpmc.c            |   7 +-
 tools/perf/builtin-report.c                        |   4 +-
 tools/perf/perf.c                                  |  14 +++
 tools/perf/tests/Build                             |   6 -
 tools/perf/tests/builtin-test.c                    |  56 ++++------
 tools/perf/tests/dwarf-unwind.c                    |   4 +
 tools/perf/tests/parse-events.c                    |  16 +++
 tools/perf/tests/tests.h                           |  10 +-
 tools/perf/ui/browser.c                            |  14 +++
 tools/perf/ui/browser.h                            |   2 +-
 tools/perf/ui/browsers/hists.c                     |  22 +++-
 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                     |  17 ++-
 tools/perf/util/parse-events.l                     |   2 +-
 tools/perf/util/sort.c                             |  37 ++++++
 tools/perf/util/sort.h                             |   1 +
 tools/perf/util/util.c                             |   4 +-
 41 files changed, 381 insertions(+), 77 deletions(-)
 create mode 100644 tools/perf/arch/x86/include/arch-tests.h
 create mode 100644 tools/perf/arch/x86/tests/arch-tests.c
 rename tools/perf/{ => arch/x86}/tests/gen-insn-x86-dat.awk (100%)
 rename tools/perf/{ => arch/x86}/tests/gen-insn-x86-dat.sh (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86-dat-32.c (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86-dat-64.c (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86-dat-src.c (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86.c (98%)
 create mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
 rename tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c (98%)
 rename tools/perf/{ => arch/x86}/tests/rdpmc.c (97%)
author maintainer
#1 lore raw

PATCH 1/16 tools lib api fs: No need to use PATH_MAX + 1

From: Jiri Olsa <[email protected]>

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
index 732dbef588b0..459599d1b6c4 100644
@@ -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
index 0406a7d5c891..a26bb5ea8283 100644
@@ -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.1.0
author maintainer
#2 lore raw

PATCH 2/16 perf evlist: Display DATA_SRC sample type bit

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index 58890044d835..0b1c289da36d 100644
@@ -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.1.0
author maintainer
#3 lore raw

PATCH 3/16 perf annotate: Fix sizeof_sym_hist overflow issue

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index e9996092a093..cea323d9ee7e 100644
@@ -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.1.0
author maintainer
#4 lore raw

PATCH 4/16 perf tools: Export perf_event_attr__set_max_precise_ip()

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index e7e195d867ea..d1392194a9a9 100644
@@ -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
index 66bc9d4c0869..a459fe71b452 100644
@@ -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.1.0
author maintainer
#5 lore raw

PATCH 5/16 perf tools: Introduce 'P' modifier to request max precision

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index ad60c6ea1997..79483f40e991 100644
@@ -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
index 0b1c289da36d..8be867ccefe9 100644
@@ -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
index 7906666580da..02a5fed8d924 100644
@@ -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
index 5d0cfce2599b..3ed8bf175163 100644
@@ -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
index c29832bce496..be244573a02e 100644
@@ -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.1.0
author maintainer
#6 lore raw

PATCH 6/16 perf tests: Add parsing test for 'P' modifier

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index 3a2ebe666192..0648b84a9171 100644
@@ -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.1.0
author maintainer
#7 lore raw

PATCH 7/16 perf tools: Add support for sorting on the iaddr

In reply to Arnaldo Carvalho de Melo

From: 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
index 8c20a8f6b214..a48a2078d288 100644
@@ -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
index 6b9556d298c9..ee94b728fca4 100644
@@ -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
index c06b75746613..33b3d30e18d3 100644
@@ -201,6 +201,7 @@ enum sort_type {
 	SORT_MEM_LVL,
 	SORT_MEM_SNOOP,
 	SORT_MEM_DCACHELINE,
+	SORT_MEM_IADDR_SYMBOL,
 };
 
 /*
Signature · 1 line
2.1.0
author maintainer
#8 lore raw

PATCH 8/16 perf tools: Setup proper width for symbol_iaddr field

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index c346b331b892..4fd37d6708cb 100644
@@ -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.1.0
author maintainer
#9 lore raw

PATCH 9/16 perf tools: Handle -h and -v options

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

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
index 2b131776363e..864e37597252 100644
@@ -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
index 1fded922bcc8..543713422d14 100644
@@ -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.1.0
author maintainer
#10 lore raw

PATCH 10/16 perf tests: Add arch tests

In reply to Arnaldo Carvalho de Melo

From: Matt Fleming <[email protected]>

Tests that only make sense for some architectures currently live in the same place as the generic tests. Move out the x86-specific tests into tools/perf/arch/x86/tests and define an 'arch_tests' array, which is the list of tests that only apply to the build architecture.

The main idea is to encourage developers to add arch tests to build out perf's test coverage, without dumping everything in tools/perf/tests.

---
 tools/perf/arch/x86/Build                |  2 +-
 tools/perf/arch/x86/include/arch-tests.h |  6 ++++++
 tools/perf/arch/x86/tests/Build          |  6 ++++--
 tools/perf/arch/x86/tests/arch-tests.c   | 10 ++++++++++
 tools/perf/tests/builtin-test.c          | 28 ++++++++++++++++++++--------
 tools/perf/tests/tests.h                 |  5 +++++
 6 files changed, 46 insertions(+), 11 deletions(-)
 create mode 100644 tools/perf/arch/x86/include/arch-tests.h
 create mode 100644 tools/perf/arch/x86/tests/arch-tests.c
tools/perf/arch/x86/Build +1 -1
index 41bf61da476a..db52fa22d3a1 100644
@@ -1,2 +1,2 @@
 libperf-y += util/
-libperf-$(CONFIG_DWARF_UNWIND) += tests/
+libperf-y += tests/
tools/perf/arch/x86/include/arch-tests.h new file +6 -0
new file mode 100644
index 000000000000..4bd41d8e1ca4
@@ -0,0 +1,6 @@
+#ifndef ARCH_TESTS_H
+#define ARCH_TESTS_H
+
+extern struct test arch_tests[];
+
+#endif
tools/perf/arch/x86/tests/Build +4 -2
index b30eff9bcc83..d827ef384b33 100644
@@ -1,2 +1,4 @@
-libperf-y += regs_load.o
-libperf-y += dwarf-unwind.o
+libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o
+libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
+
+libperf-y += arch-tests.o
tools/perf/arch/x86/tests/arch-tests.c new file +10 -0
new file mode 100644
index 000000000000..fca9eb9d39a2
@@ -0,0 +1,10 @@
+#include <string.h>
+#include "tests/tests.h"
+#include "arch-tests.h"
+
+struct test arch_tests[] = {
+	{
+		.func = NULL,
+	},
+
+};
tools/perf/tests/builtin-test.c +20 -8
index d9bf51dc8cf5..2b6c1bf13456 100644
@@ -14,10 +14,13 @@
 #include "parse-options.h"
 #include "symbol.h"
 
-static struct test {
-	const char *desc;
-	int (*func)(void);
-} tests[] = {
+struct test __weak arch_tests[] = {
+	{
+		.func = NULL,
+	},
+};
+
+static struct test generic_tests[] = {
 	{
 		.desc = "vmlinux symtab matches kallsyms",
 		.func = test__vmlinux_matches_kallsyms,
@@ -195,6 +198,11 @@ static struct test {
 	},
 };
 
+static struct test *tests[] = {
+	generic_tests,
+	arch_tests,
+};
+
 static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
 	int i;
@@ -249,22 +257,25 @@ static int run_test(struct test *test)
 	return err;
 }
 
-#define for_each_test(t)	 for (t = &tests[0]; t->func; t++)
+#define for_each_test(j, t)	 				\
+	for (j = 0; j < ARRAY_SIZE(tests); j++)	\
+		for (t = &tests[j][0]; t->func; t++)
 
 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 {
 	struct test *t;
+	unsigned int j;
 	int i = 0;
 	int width = 0;
 
-	for_each_test(t) {
+	for_each_test(j, t) {
 		int len = strlen(t->desc);
 
 		if (width < len)
 			width = len;
 	}
 
-	for_each_test(t) {
+	for_each_test(j, t) {
 		int curr = i++, err;
 
 		if (!perf_test__matches(t, curr, argc, argv))
@@ -300,10 +311,11 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 
 static int perf_test__list(int argc, const char **argv)
 {
+	unsigned int j;
 	struct test *t;
 	int i = 0;
 
-	for_each_test(t) {
+	for_each_test(j, t) {
 		if (argc > 1 && !strstr(t->desc, argv[1]))
 			continue;
 
tools/perf/tests/tests.h +5 -0
index 0b3549672c16..b1cb1c081e3c 100644
@@ -24,6 +24,11 @@ enum {
 	TEST_SKIP = -2,
 };
 
+struct test {
+	const char *desc;
+	int (*func)(void);
+};
+
 /* Tests */
 int test__vmlinux_matches_kallsyms(void);
 int test__openat_syscall_event(void);
Signature · 1 line
2.1.0
author maintainer
#11 lore raw

PATCH 11/16 perf tests: Move x86 tests into arch directory

In reply to Arnaldo Carvalho de Melo

From: Matt Fleming <[email protected]>

Move out the x86-specific tests into tools/perf/arch/x86/tests and define an 'arch_tests' array, which is the list of tests that only apply to the build architecture.

We can also now begin to get rid of some of the #ifdef code that is present in the generic perf tests.

---
 tools/perf/arch/x86/include/arch-tests.h       |  12 +
 tools/perf/arch/x86/tests/Build                |   3 +
 tools/perf/arch/x86/tests/arch-tests.c         |  20 +
 tools/perf/arch/x86/tests/dwarf-unwind.c       |   1 +
 tools/perf/arch/x86/tests/gen-insn-x86-dat.awk |  75 +++
 tools/perf/arch/x86/tests/gen-insn-x86-dat.sh  |  43 ++
 tools/perf/arch/x86/tests/insn-x86-dat-32.c    | 658 +++++++++++++++++++
 tools/perf/arch/x86/tests/insn-x86-dat-64.c    | 768 ++++++++++++++++++++++
 tools/perf/arch/x86/tests/insn-x86-dat-src.c   | 877 +++++++++++++++++++++++++
 tools/perf/arch/x86/tests/insn-x86.c           | 185 ++++++
 tools/perf/arch/x86/tests/perf-time-to-tsc.c   | 164 +++++
 tools/perf/arch/x86/tests/rdpmc.c              | 174 +++++
 tools/perf/tests/Build                         |   6 -
 tools/perf/tests/builtin-test.c                |  28 -
 tools/perf/tests/dwarf-unwind.c                |   4 +
 tools/perf/tests/gen-insn-x86-dat.awk          |  75 ---
 tools/perf/tests/gen-insn-x86-dat.sh           |  43 --
 tools/perf/tests/insn-x86-dat-32.c             | 658 -------------------
 tools/perf/tests/insn-x86-dat-64.c             | 768 ----------------------
 tools/perf/tests/insn-x86-dat-src.c            | 877 -------------------------
 tools/perf/tests/insn-x86.c                    | 184 ------
 tools/perf/tests/perf-time-to-tsc.c            | 162 -----
 tools/perf/tests/rdpmc.c                       | 177 -----
 tools/perf/tests/tests.h                       |   5 +-
 24 files changed, 2985 insertions(+), 2982 deletions(-)
 create mode 100644 tools/perf/arch/x86/tests/gen-insn-x86-dat.awk
 create mode 100755 tools/perf/arch/x86/tests/gen-insn-x86-dat.sh
 create mode 100644 tools/perf/arch/x86/tests/insn-x86-dat-32.c
 create mode 100644 tools/perf/arch/x86/tests/insn-x86-dat-64.c
 create mode 100644 tools/perf/arch/x86/tests/insn-x86-dat-src.c
 create mode 100644 tools/perf/arch/x86/tests/insn-x86.c
 create mode 100644 tools/perf/arch/x86/tests/perf-time-to-tsc.c
 create mode 100644 tools/perf/arch/x86/tests/rdpmc.c
 delete mode 100644 tools/perf/tests/gen-insn-x86-dat.awk
 delete mode 100755 tools/perf/tests/gen-insn-x86-dat.sh
 delete mode 100644 tools/perf/tests/insn-x86-dat-32.c
 delete mode 100644 tools/perf/tests/insn-x86-dat-64.c
 delete mode 100644 tools/perf/tests/insn-x86-dat-src.c
 delete mode 100644 tools/perf/tests/insn-x86.c
 delete mode 100644 tools/perf/tests/perf-time-to-tsc.c
 delete mode 100644 tools/perf/tests/rdpmc.c
tools/perf/arch/x86/include/arch-tests.h +12 -0
index 4bd41d8e1ca4..5927cf224325 100644
@@ -1,6 +1,18 @@
 #ifndef ARCH_TESTS_H
 #define ARCH_TESTS_H
 
+/* Tests */
+int test__rdpmc(void);
+int test__perf_time_to_tsc(void);
+int test__insn_x86(void);
+
+#ifdef HAVE_DWARF_UNWIND_SUPPORT
+struct thread;
+struct perf_sample;
+int test__arch_unwind_sample(struct perf_sample *sample,
+			     struct thread *thread);
+#endif
+
 extern struct test arch_tests[];
 
 #endif
tools/perf/arch/x86/tests/Build +3 -0
index d827ef384b33..8e2c5a38c3b9 100644
@@ -2,3 +2,6 @@ libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o
 libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 
 libperf-y += arch-tests.o
+libperf-y += rdpmc.o
+libperf-y += perf-time-to-tsc.o
+libperf-$(CONFIG_AUXTRACE) += insn-x86.o
tools/perf/arch/x86/tests/arch-tests.c +20 -0
index fca9eb9d39a2..d116c217af99 100644
@@ -4,6 +4,26 @@
 
 struct test arch_tests[] = {
 	{
+		.desc = "x86 rdpmc test",
+		.func = test__rdpmc,
+	},
+	{
+		.desc = "Test converting perf time to TSC",
+		.func = test__perf_time_to_tsc,
+	},
+#ifdef HAVE_DWARF_UNWIND_SUPPORT
+	{
+		.desc = "Test dwarf unwind",
+		.func = test__dwarf_unwind,
+	},
+#endif
+#ifdef HAVE_AUXTRACE_SUPPORT
+	{
+		.desc = "Test x86 instruction decoder - new instructions",
+		.func = test__insn_x86,
+	},
+#endif
+	{
 		.func = NULL,
 	},
 
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index d8bbf7ad1681..7f209ce827bf 100644
@@ -5,6 +5,7 @@
 #include "event.h"
 #include "debug.h"
 #include "tests/tests.h"
+#include "arch-tests.h"
 
 #define STACK_SIZE 8192
 
tools/perf/arch/x86/tests/gen-insn-x86-dat.awk new file +75 -0

75 lines not on this page · raw message

tools/perf/arch/x86/tests/gen-insn-x86-dat.sh new file +43 -0

43 lines not on this page · raw message

tools/perf/arch/x86/tests/insn-x86-dat-32.c new file +658 -0

658 lines not on this page · raw message

tools/perf/arch/x86/tests/insn-x86-dat-64.c new file +768 -0

768 lines not on this page · raw message

tools/perf/arch/x86/tests/insn-x86-dat-src.c new file +877 -0

877 lines not on this page · raw message

tools/perf/arch/x86/tests/insn-x86.c new file +185 -0

185 lines not on this page · raw message

tools/perf/arch/x86/tests/perf-time-to-tsc.c new file +164 -0

164 lines not on this page · raw message

tools/perf/arch/x86/tests/rdpmc.c new file +174 -0

173 lines not on this page · raw message

tools/perf/tests/Build +0 -6
index c6f198ae65fb..50de2253cff6 100644

Lines of this file are not shown. View the raw message.

tools/perf/tests/builtin-test.c +0 -28
index 2b6c1bf13456..66f72d3d6677 100644

Lines of this file are not shown. View the raw message.

tools/perf/tests/dwarf-unwind.c +4 -0
index 40b36c462427..07221793a3ac 100644

Lines of this file are not shown. View the raw message.

tools/perf/tests/gen-insn-x86-dat.awk deleted +0 -75

75 lines not on this page · raw message

tools/perf/tests/gen-insn-x86-dat.sh deleted +0 -43

43 lines not on this page · raw message

tools/perf/tests/insn-x86-dat-32.c deleted +0 -658

658 lines not on this page · raw message

tools/perf/tests/insn-x86-dat-64.c deleted +0 -768

768 lines not on this page · raw message

tools/perf/tests/insn-x86-dat-src.c deleted +0 -877

877 lines not on this page · raw message

tools/perf/tests/insn-x86.c deleted +0 -184

184 lines not on this page · raw message

tools/perf/tests/perf-time-to-tsc.c deleted +0 -162

162 lines not on this page · raw message

tools/perf/tests/rdpmc.c deleted +0 -177

177 lines not on this page · raw message

tools/perf/tests/tests.h +1 -4
index b1cb1c081e3c..c80486969f83 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.1.0

Part of the diff is not shown here. View the raw message.

author maintainer
#12 lore raw

PATCH 12/16 perf tests: Add Intel CQM test

In reply to Arnaldo Carvalho de Melo

From: Matt Fleming <[email protected]>

Peter reports that it's possible to trigger a WARN_ON_ONCE() in the Intel CQM code by combining a hardware event and an Intel CQM (software) event into a group. Unfortunately, the perf tools are not able to create this bundle and we need to manually construct a test case.

For posterity, record Peter's proof of concept test case in tools/perf so that it presents a model for how we can perform architecture specific tests, or "arch tests", in perf in the future.

The particular issue triggered in the test case is that when the counter for the hardware event overflows and triggers a PMI we'll read both the hardware event and the software event counters. Unfortunately, for CQM that involves performing an IPI to read the CQM event counters on all sockets, which in NMI context triggers the WARN_ON_ONCE().

---
 tools/perf/arch/x86/include/arch-tests.h |   1 +
 tools/perf/arch/x86/tests/Build          |   1 +
 tools/perf/arch/x86/tests/arch-tests.c   |   4 +
 tools/perf/arch/x86/tests/intel-cqm.c    | 124 +++++++++++++++++++++++++++++++
 4 files changed, 130 insertions(+)
 create mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
tools/perf/arch/x86/include/arch-tests.h +1 -0
index 5927cf224325..7ed00f4b0908 100644
@@ -5,6 +5,7 @@
 int test__rdpmc(void);
 int test__perf_time_to_tsc(void);
 int test__insn_x86(void);
+int test__intel_cqm_count_nmi_context(void);
 
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 struct thread;
tools/perf/arch/x86/tests/Build +1 -0
index 8e2c5a38c3b9..cbb7e978166b 100644
@@ -5,3 +5,4 @@ libperf-y += arch-tests.o
 libperf-y += rdpmc.o
 libperf-y += perf-time-to-tsc.o
 libperf-$(CONFIG_AUXTRACE) += insn-x86.o
+libperf-y += intel-cqm.o
tools/perf/arch/x86/tests/arch-tests.c +4 -0
index d116c217af99..2218cb64f840 100644
@@ -24,6 +24,10 @@ struct test arch_tests[] = {
 	},
 #endif
 	{
+		.desc = "Test intel cqm nmi context read",
+		.func = test__intel_cqm_count_nmi_context,
+	},
+	{
 		.func = NULL,
 	},
 
tools/perf/arch/x86/tests/intel-cqm.c new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.1.0
author maintainer
#13 lore raw

PATCH 13/16 perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

---
 tools/perf/Documentation/perf-report.txt | 2 +-
 tools/perf/builtin-report.c              | 4 ++--
 tools/perf/util/util.c                   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -1
index ce499035e6d8..e4fdeeb51123 100644
@@ -192,7 +192,7 @@ OPTIONS
 	when available. Usually more convenient to use --branch-history
 	for this.
 
-	Default: fractal,0.5,callee,function.
+	Default: graph,0.5,caller
 
 --children::
 	Accumulate callchain of children to parent entry so that then can
tools/perf/builtin-report.c +2 -2
index b5623639f67d..3b23b25d1589 100644
@@ -633,7 +633,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	bool has_br_stack = false;
 	int branch_mode = -1;
 	bool branch_call_mode = false;
-	char callchain_default_opt[] = "fractal,0.5,callee";
+	char callchain_default_opt[] = "graph,0.5,caller";
 	const char * const report_usage[] = {
 		"perf report [<options>]",
 		NULL
@@ -701,7 +701,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "Only display entries with parent-match"),
 	OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order[,branch]",
 		     "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches. "
-		     "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
+		     "Default: graph,0.5,caller", &report_parse_callchain_opt, callchain_default_opt),
 	OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
 		    "Accumulate callchains of children and show total overhead as well"),
 	OPT_INTEGER(0, "max-stack", &report.max_stack,
tools/perf/util/util.c +2 -2
index ce465b259e52..c1bf9ff210b0 100644
@@ -17,9 +17,9 @@
 #include "callchain.h"
 
 struct callchain_param	callchain_param = {
-	.mode	= CHAIN_GRAPH_REL,
+	.mode	= CHAIN_GRAPH_ABS,
 	.min_percent = 0.5,
-	.order  = ORDER_CALLEE,
+	.order  = ORDER_CALLER,
 	.key	= CCKEY_FUNCTION
 };
 
Signature · 1 line
2.1.0
#14 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

# perf report -n --stdio
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k]
copy_user_enhanced_fast_string
                     |
                     --- 0x7f0683ba1ccd
                         system_call_fastpath
                         sys_write
                         vfs_write
                         do_sync_write
                         sock_aio_write
                         do_sock_write.isra.10
                         inet_sendmsg
                         copy_user_enhanced_fast_string
[...]

That's upside down. The current default preserves ordering from the informational line onwards:

# perf report -n --stdio -g fractal,0.5,callee
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k]
copy_user_enhanced_fast_string
                     |
                     --- copy_user_enhanced_fast_string
                        |
                        |--64.37%-- inet_sendmsg
                        |          do_sock_write.isra.10
                        |          sock_aio_write
                        |          do_sync_write
                        |          vfs_write
                        |          sys_write
                        |          system_call_fastpath
                        |          0x7f0683ba1ccd

... Those are just short examples. Another profile I'm working on now gets really messy on "perf report -n --stdio"; eg:

perf report -n --stdio -g graph,0.5,caller

    94.80%     0.10%             2  iperf     [kernel.vmlinux]    [k]
entry_SYSCALL_64_fastpath
               |
               |--94.70%-- entry_SYSCALL_64_fastpath
               |          |
               |          |--55.76%-- sys_write
               |          |          |
               |          |          |--55.10%-- vfs_write
               |          |          |          |
               |          |          |          |--54.39%-- __vfs_write
               |          |          |          |          |
               |          |          |          |           --54.34%--
sock_write_iter
               |          |          |          |                     |
               |          |          |          |
|--54.19%-- sock_sendmsg
               |          |          |          |
|          |
               |          |          |          |
|          |--53.99%-- inet_sendmsg
               |          |          |          |
|          |          |
               |          |          |          |
|          |          |--53.08%-- tcp_sendmsg
               |          |          |          |
|          |          |          |
               |          |          |          |
|          |          |          |--17.27%--
copy_user_enhanced_fast_string
               |          |          |          |
|          |          |          |
               |          |          |          |
|          |          |          |--11.41%-- tcp_push_one
               |          |          |          |
|          |          |          |          |
               |          |          |          |
|          |          |          |          |--11.31%-- tcp_write_xmit
               |          |          |          |
|          |          |          |          |          |
               |          |          |          |
|          |          |          |          |          |--10.00%--
tcp_transmit_skb
               |          |          |          |
|          |          |          |          |          |          |
               |          |          |          |
|          |          |          |          |          |
|--9.29%-- ip_queue_xmit
               |          |          |          |
|          |          |          |          |          |          |
      |
               |          |          |          |
|          |          |          |          |          |          |
      |--8.69%-- ip_local_out_sk
               |          |          |          |
|          |          |          |          |          |          |
      |          |
               |          |          |          |
|          |          |          |          |          |          |
      |          |--8.64%-- ip_output
               |          |          |          |
|          |          |          |          |          |          |
      |          |          ip_finish_output
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |--8.43%-- ip_finish_output2
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |--6.97%-- __local_bh_enable_ip
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |          |
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |          |--6.82%--
do_softirq
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |          |          |
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |          |
--6.77%-- do_softirq_own_stack
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |          |
 |
               |          |          |          |
|          |          |          |          |          |          |
      |          |          |          |          |
 |--6.46%-- __do_softirq

[...]

The current default never gets beyond 5 levels deep. The new default goes to 25 levels. At least with perf report I can override the default using "-g". perf script doesn't support that.

Can this patch please preserve the callee ordering for non-interactive output? (perf script, perf report -n --stdio). Thanks,

Brendan

author maintainer
#15 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 5 lines
Quoted 3 lines · Arnaldo Carvalho de Melo

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

Quoted 7 lines
Quoted 1 line

Which is the most common default found in other similar tools.

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 44 lines
# perf report -n --stdio
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k] copy_user_enhanced_fast_string
                     |
                     --- 0x7f0683ba1ccd
                         system_call_fastpath
                         sys_write
                         vfs_write
                         do_sync_write
                         sock_aio_write
                         do_sock_write.isra.10
                         inet_sendmsg
                         copy_user_enhanced_fast_string
[...]

That's upside down. The current default preserves ordering from the informational line onwards:

# perf report -n --stdio -g fractal,0.5,callee
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k] copy_user_enhanced_fast_string
                     |
                     --- copy_user_enhanced_fast_string
                        |
                        |--64.37%-- inet_sendmsg
                        |          do_sock_write.isra.10
                        |          sock_aio_write
                        |          do_sync_write
                        |          vfs_write
                        |          sys_write
                        |          system_call_fastpath
                        |          0x7f0683ba1ccd

... Those are just short examples. Another profile I'm working on now gets really messy on "perf report -n --stdio"; eg:

perf report -n --stdio -g graph,0.5,caller

    94.80%     0.10%             2  iperf     [kernel.vmlinux]    [k]
entry_SYSCALL_64_fastpath
               |
               |--94.70%-- entry_SYSCALL_64_fastpath
               |          |
Quoted 3 lines

The current default never gets beyond 5 levels deep. The new default goes to 25 levels. At least with perf report I can override the default using "-g". perf script doesn't support that.

Ok, so changing defaults is not nice, but in this case looked sensible, ends up not being for you...

Quoted 2 lines

Can this patch please preserve the callee ordering for non-interactive output? (perf script, perf report -n --stdio). Thanks,

If this is because you do scripting on it? Wouldn't it be better to not depend on defaults, always specify what you want and then the bug would be constrained to 'perf script' where we need to provide a way to change the default?

- Arnaldo

#16 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 9 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 7 lines
Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

But it's not just scripting; We often email around "perf report -n --stdio" output, or attach it to tickets, when working on an issue. Easier than trying to grab the right TUI screenshot.

Quoted 45 lines
Quoted 45 lines
# perf report -n --stdio
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k] copy_user_enhanced_fast_string
                     |
                     --- 0x7f0683ba1ccd
                         system_call_fastpath
                         sys_write
                         vfs_write
                         do_sync_write
                         sock_aio_write
                         do_sock_write.isra.10
                         inet_sendmsg
                         copy_user_enhanced_fast_string
[...]

That's upside down. The current default preserves ordering from the informational line onwards:

# perf report -n --stdio -g fractal,0.5,callee
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k] copy_user_enhanced_fast_string
                     |
                     --- copy_user_enhanced_fast_string
                        |
                        |--64.37%-- inet_sendmsg
                        |          do_sock_write.isra.10
                        |          sock_aio_write
                        |          do_sync_write
                        |          vfs_write
                        |          sys_write
                        |          system_call_fastpath
                        |          0x7f0683ba1ccd

... Those are just short examples. Another profile I'm working on now gets really messy on "perf report -n --stdio"; eg:

perf report -n --stdio -g graph,0.5,caller

    94.80%     0.10%             2  iperf     [kernel.vmlinux]    [k]
entry_SYSCALL_64_fastpath
               |
               |--94.70%-- entry_SYSCALL_64_fastpath
               |          |
Quoted 6 lines
Quoted 3 lines

The current default never gets beyond 5 levels deep. The new default goes to 25 levels. At least with perf report I can override the default using "-g". perf script doesn't support that.

Ok, so changing defaults is not nice, but in this case looked sensible, ends up not being for you...

I'm pretty sure this would surprise anyone looking at dumped stacks, where the convention is caller. pstack, jstack, gdb, systemtap, dtrace, oops message, etc. I get that we want this for the TUI, but not dumped stacks.

Quoted 8 lines
Quoted 3 lines

Can this patch please preserve the callee ordering for non-interactive output? (perf script, perf report -n --stdio). Thanks,

If this is because you do scripting on it? Wouldn't it be better to not depend on defaults, always specify what you want and then the bug would be constrained to 'perf script' where we need to provide a way to change the default?

Actually, for my flame graphs we should really have perf report have a --folded output to emit folded output (I emailed perf-users), callee.

For scripting we can always specify -g.

I'm thinking of others who use perf report/script at the CLI, and expect callee output.

Brendan

#17 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Fri, Oct 09, 2015 at 03:10:29PM -0700, Brendan Gregg escreveu:

Quoted 19 lines
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 7 lines
Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 8 lines

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

Should've already, guess there are things to merge and save you some time :)

Quoted 3 lines

But it's not just scripting; We often email around "perf report -n --stdio" output, or attach it to tickets, when working on an issue. Easier than trying to grab the right TUI screenshot.

Well, that is something we need to change... But then, are you aware of 'P' in the TUI? It allows you to go, expand whatever callchains you deem necessary and then press P and the current state of the UI will be dumped to a perf.hist.<N> file. I.e. no need to get a png screenshot nor to copy things with gpm like stuff.

Maybe that is a digression, you tell me :)

Quoted 60 lines
Quoted 45 lines
Quoted 45 lines
# perf report -n --stdio
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k] copy_user_enhanced_fast_string
                     |
                     --- 0x7f0683ba1ccd
                         system_call_fastpath
                         sys_write
                         vfs_write
                         do_sync_write
                         sock_aio_write
                         do_sock_write.isra.10
                         inet_sendmsg
                         copy_user_enhanced_fast_string
[...]

That's upside down. The current default preserves ordering from the informational line onwards:

# perf report -n --stdio -g fractal,0.5,callee
[...]
    16.87%        334           iperf  [kernel.kallsyms]     [k] copy_user_enhanced_fast_string
                     |
                     --- copy_user_enhanced_fast_string
                        |
                        |--64.37%-- inet_sendmsg
                        |          do_sock_write.isra.10
                        |          sock_aio_write
                        |          do_sync_write
                        |          vfs_write
                        |          sys_write
                        |          system_call_fastpath
                        |          0x7f0683ba1ccd

... Those are just short examples. Another profile I'm working on now gets really messy on "perf report -n --stdio"; eg:

perf report -n --stdio -g graph,0.5,caller

    94.80%     0.10%             2  iperf     [kernel.vmlinux]    [k]
entry_SYSCALL_64_fastpath
               |
               |--94.70%-- entry_SYSCALL_64_fastpath
               |          |
Quoted 6 lines
Quoted 3 lines

The current default never gets beyond 5 levels deep. The new default goes to 25 levels. At least with perf report I can override the default using "-g". perf script doesn't support that.

Ok, so changing defaults is not nice, but in this case looked sensible, ends up not being for you...

I'm pretty sure this would surprise anyone looking at dumped stacks, where the convention is caller. pstack, jstack, gdb, systemtap, dtrace, oops message, etc. I get that we want this for the TUI, but not dumped stacks.

Quoted 3 lines
Quoted 2 lines

Can this patch please preserve the callee ordering for non-interactive output? (perf script, perf report -n --stdio). Thanks,

Quoted 7 lines
Quoted 4 lines

If this is because you do scripting on it? Wouldn't it be better to not depend on defaults, always specify what you want and then the bug would be constrained to 'perf script' where we need to provide a way to change the default?

Actually, for my flame graphs we should really have perf report have a --folded output to emit folded output (I emailed perf-users), callee.

I'll search that message, but feel free to be more blunt when you think its appropriate.

Quoted 4 lines

For scripting we can always specify -g.

I'm thinking of others who use perf report/script at the CLI, and expect callee output.

- Arnaldo

#18 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 36 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 03:10:29PM -0700, Brendan Gregg escreveu:

Quoted 19 lines
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 7 lines
Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 8 lines

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

Should've already, guess there are things to merge and save you some time :)

Quoted 3 lines

But it's not just scripting; We often email around "perf report -n --stdio" output, or attach it to tickets, when working on an issue. Easier than trying to grab the right TUI screenshot.

Quoted 6 lines

Well, that is something we need to change... But then, are you aware of 'P' in the TUI? It allows you to go, expand whatever callchains you deem necessary and then press P and the current state of the UI will be dumped to a perf.hist.<N> file. I.e. no need to get a png screenshot nor to copy things with gpm like stuff.
[...]

I didn't know about 'P', thanks. I still find it quicker to "perf report -n --stdio", then browse with my eyes and the scroll wheel. (Then use a flame graph if the output isn't trivial to understand.)

... Just to express a callee order preference differently (at least for the text dumping outputs), it's showing what's running (first few frames) followed by how we got there. And that's the order I'm usually wanting to know them... I still think it's the order printed by most other text-based tools, although GUIs (like those with tree views) are probably more usually caller order.

Brendan

#19 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:

Quoted 47 lines
Quoted 34 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 03:10:29PM -0700, Brendan Gregg escreveu:

Quoted 17 lines
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 5 lines
Quoted 3 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 8 lines

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

Should've already, guess there are things to merge and save you some time :)

Quoted 3 lines

But it's not just scripting; We often email around "perf report -n --stdio" output, or attach it to tickets, when working on an issue. Easier than trying to grab the right TUI screenshot.

Quoted 6 lines

Well, that is something we need to change... But then, are you aware of 'P' in the TUI? It allows you to go, expand whatever callchains you deem necessary and then press P and the current state of the UI will be dumped to a perf.hist.<N> file. I.e. no need to get a png screenshot nor to copy things with gpm like stuff.
[...]

I didn't know about 'P', thanks. I still find it quicker to "perf report -n --stdio", then browse with my eyes and the scroll wheel. (Then use a flame graph if the output isn't trivial to understand.)

Quoted 6 lines

... Just to express a callee order preference differently (at least for the text dumping outputs), it's showing what's running (first few frames) followed by how we got there. And that's the order I'm usually wanting to know them... I still think it's the order printed by most other text-based tools, although GUIs (like those with tree views) are probably more usually caller order.

So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

This is all configurable via ~/.perfconfig :-\

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Ingo, what do you think?

- Arnaldo

#20 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 8 lines · Arnaldo Carvalho de Melo

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

This is all configurable via ~/.perfconfig :-\

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

IMHO changing that order is not a good idea. Unless many users complained about it.

Quoted 4 lines

Ingo, what do you think?

- Arnaldo

#21 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Tue, Oct 20, 2015 at 02:19:50PM +0200, Frederic Weisbecker escreveu:

Quoted 5 lines · Arnaldo Carvalho de Melo
Quoted 3 lines

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

Quoted 7 lines
Quoted 4 lines

This is all configurable via ~/.perfconfig :-\

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

A good chunk of that was because that was the default?

Quoted 2 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

Anedoctally, he tweeted about it and people seemed to like it.

Quoted 1 line
Quoted 1 line

Ingo, what do you think?

What about providing a hotkey, in the tui, to toggle caller/callee views, and another hotkey to save that in ~/.perfconfig so that becomes the new default?

In the --stdio mode we need to add a warning in the first lines, something like:

# This is caller (or callee) based, please use --callchain ... to change it

One way or the other people will disagree, so making it easy to switch to the preferred way would be nice to have?

- Arnaldo

#22 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 8 lines · Arnaldo Carvalho de Melo

Em Tue, Oct 20, 2015 at 02:19:50PM +0200, Frederic Weisbecker escreveu:

Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 5 lines

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

This is all configurable via ~/.perfconfig :-\

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

A good chunk of that was because that was the default?

I doubt it. When you need to find the culprit of a syscall of IRQ performance issue, you don't care much to see __libc_start_main() / main() on the top of your callchain.

Quoted 11 lines
Quoted 3 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

Anedoctally, he tweeted about it and people seemed to like it.

Well, I would prefer to hear from regular users than random twitter followers. I could be wrong so lets ask some users first.

Quoted 5 lines
Quoted 1 line
Quoted 1 line

Ingo, what do you think?

What about providing a hotkey, in the tui, to toggle caller/callee views, and another hotkey to save that in ~/.perfconfig so that becomes the new default?

That means rebuilding the whole tree, it might be costly and events need to be processed again.

Quoted 8 lines

In the --stdio mode we need to add a warning in the first lines, something like:

# This is caller (or callee) based, please use --callchain ... to change it

One way or the other people will disagree, so making it easy to switch to the preferred way would be nice to have?

Agreed.

Thanks!

#23 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Tue, Oct 20, 2015 at 07:21:16PM +0200, Frederic Weisbecker escreveu:

Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 11 lines

Em Tue, Oct 20, 2015 at 02:19:50PM +0200, Frederic Weisbecker escreveu:

Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 8 lines

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

This is all configurable via ~/.perfconfig :-\

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

A good chunk of that was because that was the default?

I doubt it. When you need to find the culprit of a syscall of IRQ performance issue, you don't care much to see __libc_start_main() / main() on the top of your callchain.

And I noticed some other shortcoming of this ordering (caller) the stack closer to userspace in a typical perf.data with callchains (perf record -g) can have bogus addresses (-fomit-frame-pointer) :-\

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Quoted 7 lines
Quoted 4 lines

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

Anedoctally, he tweeted about it and people seemed to like it.

Well, I would prefer to hear from regular users than random twitter followers. I could be wrong so lets ask some users first.

That is why I put the "anedoctaly" :-)

Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Ingo, what do you think?

What about providing a hotkey, in the tui, to toggle caller/callee views, and another hotkey to save that in ~/.perfconfig so that becomes the new default?

That means rebuilding the whole tree, it might be costly and events need to be processed again.

I never tried to reimplement that with going to/from caller/caller in mind, should do at some point, but yeah, reprocessing all entries can be way costly.

Quoted 9 lines
Quoted 7 lines

In the --stdio mode we need to add a warning in the first lines, something like:

# This is caller (or callee) based, please use --callchain ... to change it

One way or the other people will disagree, so making it easy to switch to the preferred way would be nice to have?

Agreed.

I'll probably revert this change in default and provide some way to change it dynamically, just waiting a some more time for more comments.

- Arnaldo

maintainer
#24 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Hi Arnaldo,

Quoted 16 lines · Arnaldo Carvalho de Melo

Em Tue, Oct 20, 2015 at 07:21:16PM +0200, Frederic Weisbecker escreveu:

Quoted 15 lines · Arnaldo Carvalho de Melo
Quoted 14 lines

Em Tue, Oct 20, 2015 at 02:19:50PM +0200, Frederic Weisbecker escreveu:

Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 8 lines

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

This is all configurable via ~/.perfconfig :-\

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

A good chunk of that was because that was the default?

I doubt it. When you need to find the culprit of a syscall of IRQ performance issue, you don't care much to see __libc_start_main() / main() on the top of your callchain.

And I noticed some other shortcoming of this ordering (caller) the stack closer to userspace in a typical perf.data with callchains (perf record -g) can have bogus addresses (-fomit-frame-pointer) :-\

Maybe we need to add an option to ignore unresolved callchains?

Quoted 23 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Quoted 7 lines
Quoted 4 lines

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

Anedoctally, he tweeted about it and people seemed to like it.

Well, I would prefer to hear from regular users than random twitter followers. I could be wrong so lets ask some users first.

That is why I put the "anedoctaly" :-)

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Ingo, what do you think?

What about providing a hotkey, in the tui, to toggle caller/callee views, and another hotkey to save that in ~/.perfconfig so that becomes the new default?

Quoted 6 lines
Quoted 2 lines

That means rebuilding the whole tree, it might be costly and events need to be processed again.

I never tried to reimplement that with going to/from caller/caller in mind, should do at some point, but yeah, reprocessing all entries can be way costly.

Right. Anyway it seems useful to update config dynamically. I really need to take a look at Taeung's config patchset..

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

In the --stdio mode we need to add a warning in the first lines, something like:

# This is caller (or callee) based, please use --callchain ... to change it

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

One way or the other people will disagree, so making it easy to switch to the preferred way would be nice to have?

Agreed.

I'll probably revert this change in default and provide some way to change it dynamically, just waiting a some more time for more comments.

Agreed.

Thanks,
Namhyung

#25 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Wed, Oct 21, 2015 at 10:21:36AM +0900, Namhyung Kim escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 5 lines

Em Tue, Oct 20, 2015 at 07:21:16PM +0200, Frederic Weisbecker escreveu:

Quoted 1 line · Arnaldo Carvalho de Melo

And I noticed some other shortcoming of this ordering (caller) the stack closer to userspace in a typical perf.data with callchains (perf record -g) can have bogus addresses (-fomit-frame-pointer) :-\

Maybe we need to add an option to ignore unresolved callchains?

We have:

-U, --hide-unresolved
Only display entries resolved to a symbol

But I think the problem here is different, its not about unresolved stuff, its about invalid addresses, no?

- Arnaldo

maintainer
#26 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Frederic Weisbecker

Hi Frederic,

Quoted 27 lines · Frederic Weisbecker
Quoted 8 lines · Arnaldo Carvalho de Melo

Em Tue, Oct 20, 2015 at 02:19:50PM +0200, Frederic Weisbecker escreveu:

Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 5 lines

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?

This is all configurable via ~/.perfconfig :-\

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

A good chunk of that was because that was the default?

I doubt it. When you need to find the culprit of a syscall of IRQ performance issue, you don't care much to see __libc_start_main() / main() on the top of your callchain.

Quoted 7 lines
Quoted 3 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Quoted 7 lines
Quoted 4 lines

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

Anedoctally, he tweeted about it and people seemed to like it.

Well, I would prefer to hear from regular users than random twitter followers. I could be wrong so lets ask some users first.

Just a question. Do you often use --children and/or '--g caller' options?

I guess that for most kernel developers, --children is not that useful as you said. But I think it can be useful for many userspace developers and with '-g caller' it can be even more useful. :)

When '-g caller' is used, the callchains shown in a (self) entry are less important IMHO. However callchains in entries generated by --children will show which functions are called by the entry (since it's reversed!) and will be more important.

Thanks,
Namhyung

#27 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 25 lines · Namhyung Kim

Hi Frederic,

Quoted 22 lines · Frederic Weisbecker
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Tue, Oct 20, 2015 at 02:19:50PM +0200, Frederic Weisbecker escreveu:

Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 6 lines

Em Mon, Oct 19, 2015 at 05:16:53PM -0700, Brendan Gregg escreveu:
So are you advocating different defaults, one for --stdio (callee), another for --tui, --gtk (caller)?
This is all configurable via ~/.perfconfig :-\
Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Quoted 3 lines
Quoted 2 lines

Most uses I've seen on LKML by the past involved callee because people mostly look at the precise point where a performance issue is.

A good chunk of that was because that was the default?

I doubt it. When you need to find the culprit of a syscall of IRQ performance issue, you don't care much to see __libc_start_main() / main() on the top of your callchain.

Quoted 6 lines
Quoted 3 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

Anedoctally, he tweeted about it and people seemed to like it.

Well, I would prefer to hear from regular users than random twitter followers. I could be wrong so lets ask some users first.

Just a question. Do you often use --children and/or '--g caller' options?

For me, I always use --no-children. However, I think it is because I have used to --no-children and no one teach me how to utilize the additional information --children provided. In case when result of --no-children hard to explain I use Brendan's flame graph tool.

Thank you.

Quoted 11 lines

I guess that for most kernel developers, --children is not that useful as you said. But I think it can be useful for many userspace developers and with '-g caller' it can be even more useful. :)

When '-g caller' is used, the callchains shown in a (self) entry are less important IMHO. However callchains in entries generated by --children will show which functions are called by the entry (since it's reversed!) and will be more important.

Thanks,
Namhyung

#28 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Namhyung Kim
Quoted 5 lines · Namhyung Kim
Quoted 2 lines · Frederic Weisbecker

Well, I would prefer to hear from regular users than random twitter followers. I could be wrong so lets ask some users first.

Just a question. Do you often use --children and/or '--g caller' options?

I must confess I haven't used perf much for some time now. So I never really used --children but I'm fairly convinced it's a very useful option.

Quoted 3 lines

I guess that for most kernel developers, --children is not that useful as you said.

Not sure about that. It provides a good overview.

Quoted 7 lines

But I think it can be useful for many userspace developers and with '-g caller' it can be even more useful. :)

When '-g caller' is used, the callchains shown in a (self) entry are less important IMHO. However callchains in entries generated by --children will show which functions are called by the entry (since it's reversed!) and will be more important.

Right and in fact the ever growing adoption of perf by userland developers makes we start to understand why people are interested in caller based callchains. Callee-based zoom into low level details that many people are not interested in.

I think that if people could filter the callchain to only keep the part concerning their binary, callee may suddenly become interesting for them.

A message that is not in the archive (sent off-list or not yet received): CAAwGriEtYeBytGt9x24=uUqSEy5oJ2HigfA2KXnKyrAioKrtNg@mail.gmail.com

#30 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 24 lines · Chandler Carruth
Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

IMHO changing that order is not a good idea. Unless many users complained about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

So, first and foremost, thanks for fixing some of my gripes about the usability of the perf tool, I'm super excited about the changes you're making, even if this one isn't among them.

I think the default of caller vs. callee is probably the hardest judgement call to make about the right defaults. I can see it going both ways.

When profiling my *system*, or a diverse group of programs or tasks, I often find callee useful. Were I a kernel developer, I suspect callee would be *dramatically* more common than caller.

Quoted 6 lines

For me, what makes the caller view much more frequently desired is that I'm usually profiling a fairly isolated application, or benchmark for an isolated library. While I always start off with some more system-level performance problem, I rarely need a detailed profile to get a reasonable idea of what subsystem to stare at, and then I spend days looking at a relatively isolated reproduction.

I understand it that way: callee based is good when you look for a specific issue to resolve and caller based is better when you want an overview of an object.

That makes sense.

Quoted 3 lines

Anyways, for profiling user-land applications, I suspect from my conversations with users that "caller" is the more common expectation.

I wonder what would be the result if people were to use callchains that only involve the user part. Maybe they prefer caller based because they don't care about the kernel part.

Quoted 8 lines
Quoted 4 lines

What about providing a hotkey, in the tui, to toggle caller/callee views, and another hotkey to save that in ~/.perfconfig so that becomes the new default?

OMG, being able to toggle between caller and callee in the tui would be *awesome*. Regardless of which default you end up with, I'd love to have this feature.

Indeed it could be interesting.

I we want that toggling to be fast enough, we need to process both callee and caller trees on hists processing, and not rebuild the entire tree each time we toggle (which would be costly). That's fairly possible to do and it might not even impact much the loading time if we do this in multithread.

Thanks!

#31 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to a message not in the archive
Quoted 35 lines · Chandler Carruth

Since Arnaldo asked, I thought I should actually try to respond specifically to the question of why I favor the 'caller' view as the default.

Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 4 lines

IMHO changing that order is not a good idea. Unless many users complained
about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

So, first and foremost, thanks for fixing some of my gripes about the usability of the perf tool, I'm super excited about the changes you're making, even if this one isn't among them.

I think the default of caller vs. callee is probably the hardest judgement call to make about the right defaults. I can see it going both ways.

When profiling my *system*, or a diverse group of programs or tasks, I often find callee useful. Were I a kernel developer, I suspect callee would be *dramatically* more common than caller.

For me, what makes the caller view much more frequently desired is that I'm usually profiling a fairly isolated application, or benchmark for an isolated library. While I always start off with some more system-level performance problem, I rarely need a detailed profile to get a reasonable idea of what subsystem to stare at, and then I spend days looking at a relatively isolated reproduction.

Quoted 2 lines

Anyways, for profiling user-land applications, I suspect from my conversations with users that "caller" is the more common expectation.

[...]

I would have said callee is the more common expectation, certainly for system profilers. I quickly checked various tools to see what their defaults are:

callee:

gdb
lldb
pstack
jstack
perf
stap
ktap
dtrace
kernel oops message
jvm crash
node.js/v8 crash

caller:

python traceback

Python was the only one I knew off-hand that is caller by default (and it includes the text "most recent call last", suggesting the developers thought it was necessary to point out that it was different). Do you know what tools/profilers/debuggers these users are using?

I really think people will be surprised if by default perf prints stacks differently to gdb, lldb, oops messages, etc, etc. That may be true for a specific developer community (eg, Python), but not for system profilers.

Brendan

#32 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Wed, Oct 21, 2015 at 11:28:54AM -0700, Brendan Gregg escreveu:

Quoted 58 lines · Chandler Carruth
Quoted 35 lines

Since Arnaldo asked, I thought I should actually try to respond specifically to the question of why I favor the 'caller' view as the default.

Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 4 lines

IMHO changing that order is not a good idea. Unless many users complained
about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

So, first and foremost, thanks for fixing some of my gripes about the usability of the perf tool, I'm super excited about the changes you're making, even if this one isn't among them.

I think the default of caller vs. callee is probably the hardest judgement call to make about the right defaults. I can see it going both ways.

When profiling my *system*, or a diverse group of programs or tasks, I often find callee useful. Were I a kernel developer, I suspect callee would be *dramatically* more common than caller.

For me, what makes the caller view much more frequently desired is that I'm usually profiling a fairly isolated application, or benchmark for an isolated library. While I always start off with some more system-level performance problem, I rarely need a detailed profile to get a reasonable idea of what subsystem to stare at, and then I spend days looking at a relatively isolated reproduction.

Quoted 2 lines

Anyways, for profiling user-land applications, I suspect from my conversations with users that "caller" is the more common expectation.

[...]

I would have said callee is the more common expectation, certainly for system profilers. I quickly checked various tools to see what their defaults are:

callee:

gdb
lldb
pstack
jstack
perf
stap
ktap
dtrace
kernel oops message
jvm crash
node.js/v8 crash

Quoted 3 lines

caller:

python traceback

sysprof -> http://sysprof.com/screen-shot-4.png

Quoted 13 lines

Python was the only one I knew off-hand that is caller by default (and it includes the text "most recent call last", suggesting the developers thought it was necessary to point out that it was different). Do you know what tools/profilers/debuggers these users are using?

I really think people will be surprised if by default perf prints stacks differently to gdb, lldb, oops messages, etc, etc. That may be true for a specific developer community (eg, Python), but not for system profilers.

Brendan

#33 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 59 lines · Arnaldo Carvalho de Melo

Em Wed, Oct 21, 2015 at 11:28:54AM -0700, Brendan Gregg escreveu:

Quoted 58 lines · Chandler Carruth
Quoted 35 lines

Since Arnaldo asked, I thought I should actually try to respond specifically to the question of why I favor the 'caller' view as the default.

Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 4 lines

IMHO changing that order is not a good idea. Unless many users complained
about it.

Perhaps there are not that many users of callchains because the default is not what they're used to see?

Motivation for the change came from a video from Chandler, that resurfaced the callchain default issue, Chandler?

So, first and foremost, thanks for fixing some of my gripes about the usability of the perf tool, I'm super excited about the changes you're making, even if this one isn't among them.

I think the default of caller vs. callee is probably the hardest judgement call to make about the right defaults. I can see it going both ways.

When profiling my *system*, or a diverse group of programs or tasks, I often find callee useful. Were I a kernel developer, I suspect callee would be *dramatically* more common than caller.

For me, what makes the caller view much more frequently desired is that I'm usually profiling a fairly isolated application, or benchmark for an isolated library. While I always start off with some more system-level performance problem, I rarely need a detailed profile to get a reasonable idea of what subsystem to stare at, and then I spend days looking at a relatively isolated reproduction.

Quoted 2 lines

Anyways, for profiling user-land applications, I suspect from my conversations with users that "caller" is the more common expectation.

[...]

I would have said callee is the more common expectation, certainly for system profilers. I quickly checked various tools to see what their defaults are:

callee:

gdb
lldb
pstack
jstack
perf
stap
ktap
dtrace
kernel oops message
jvm crash
node.js/v8 crash

Quoted 5 lines
Quoted 3 lines

caller:

python traceback

sysprof -> http://sysprof.com/screen-shot-4.png

Right, GUIs with tree views do this.

I've thought about it more, and how does the following 3 changes sound?:

1. perf top: change to caller default

- Since it's dumping a tree view, this ordering is intuitive, and this is the convention from other interactive GUIs that do tree views. Optionally add a hotkey to change it live. Could also add -G from perf report (--inverted) to easily call the old behavior.

2. perf report: change to caller default

- I'd like to leave it callee, but as Ingo said, "top" and "report" should be unified. I can always run -G, or -g, or edit ~/.perfconfig.

3. perf script: leave callee default.

- Since it's dumping a full stack, that's the convention with other tools that dump full stacks (as I listed), and I think that's useful ordering anyway when reading a full stack: show me event context first, followed by history next. "perf script" should have -G and -g added, to adjust behavior.

I'd also like different UIs from perf report (folded and json), but that's a different thread. :)

Brendan

#34 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo
Quoted 4 lines · Arnaldo Carvalho de Melo

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Ingo, what do you think?

So I think the new default is a lot more intuitive, because it starts with a high level top-down 'overview' kind of output, allowing one to drill down to the details.

That's what most other tools do as well by default, and people migrating to perf found it pretty confusing that we do a bottom-up kind of callgraph.

To people using perf for the first time it does not matter nearly as much, but intuitiveness is still a factor.

The new default requires good call-chains and good symbol resolution to be maximally effective, but we want perfect callchains and symbols in any case, right?

Thanks,

Ingo

#35 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Wed, Oct 21, 2015 at 10:06:45AM +0200, Ingo Molnar escreveu:

Quoted 13 lines · Arnaldo Carvalho de Melo
Quoted 4 lines

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Ingo, what do you think?

So I think the new default is a lot more intuitive, because it starts with a high level top-down 'overview' kind of output, allowing one to drill down to the details.

That's what most other tools do as well by default, and people migrating to perf found it pretty confusing that we do a bottom-up kind of callgraph.

Quoted 6 lines

To people using perf for the first time it does not matter nearly as much, but intuitiveness is still a factor.

The new default requires good call-chains and good symbol resolution to be maximally effective, but we want perfect callchains and symbols in any case, right?

Sure, but in hindsight, we could've fixed those problems before flipping the switch :-)

And also we didn't care about it that much because for callee based callchains they are far from the focus point.

- Arnaldo

#36 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Ingo Molnar
Quoted 12 lines · Ingo Molnar
Quoted 4 lines · Arnaldo Carvalho de Melo

Indeed, finding a default that is deemed adequate for most people is, ho-hum, difficult 8-)

Ingo, what do you think?

So I think the new default is a lot more intuitive, because it starts with a high level top-down 'overview' kind of output, allowing one to drill down to the details.

Yes, it may be more intuitive.

Quoted 3 lines

That's what most other tools do as well by default, and people migrating to perf found it pretty confusing that we do a bottom-up kind of callgraph. [...]

But I don't think it's commonplace. Which other tools do this? Java Flight Recorder? GUIs? Certainly not text-based system profilers or debuggers (I made a list in another email).

Although, these are usually printing entire stacks. So the most alien change would be to flip the "perf script" order (please don't do this). You could argue that the perf report/top tree view is not commonplace from other text-based profilers or debuggers, so changing it won't be as confusing. In fact, it's like a sideways flame graph (except it doesn't fit on the screen!).

Brendan

#37 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Brendan Gregg
Quoted 19 lines · Brendan Gregg
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 7 lines
Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 8 lines

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

So I tried it:

triton:~/s/FlameGraph> ls -l flame.svg -rw-rw-r-- 1 mingo mingo 1022870 Oct 10 09:06 flame.svg

but when I tried to view it via ImageMagick, it first showed an empty screen:

triton:~/s/FlameGraph> display flame.svg

then when exiting it said:

display: non-conforming drawing primitive definition `text-anchor' @ error/draw.c/DrawImage/3182.

although I guess that latter is an unrealted ImageMagick problem, not caused by the SVG.

Thanks,

Ingo

#38 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 38 lines · Ingo Molnar
Quoted 19 lines · Brendan Gregg
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 7 lines
Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 8 lines

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

So I tried it:

triton:~/s/FlameGraph> ls -l flame.svg -rw-rw-r-- 1 mingo mingo 1022870 Oct 10 09:06 flame.svg

but when I tried to view it via ImageMagick, it first showed an empty screen:

Quoted 9 lines

triton:~/s/FlameGraph> display flame.svg

then when exiting it said:

display: non-conforming drawing primitive definition `text-anchor' @ error/draw.c/DrawImage/3182.

although I guess that latter is an unrealted ImageMagick problem, not caused by the SVG.

Sorry, I should have said to open it in a browser (Chrome/Firefox); the SVG contains some (entirely embedded) JavaScript to provide interactivity (click to zoom, Ctrl-F to search).

I think it used to work in ImageMagick (without JavaScript interactivity), but I haven't tried in a long time. I'll have to check it again.

Brendan

#39 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 45 lines · Brendan Gregg
Quoted 44 lines · Ingo Molnar
Quoted 19 lines · Brendan Gregg
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Fri, Oct 09, 2015 at 01:34:33PM -0700, Brendan Gregg escreveu:

Quoted 7 lines
Quoted 4 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 7 lines
Quoted 5 lines

Interactive tools, sure, like the perf report TUI.

But this also changes the ordering of the non-interactive tools which dump stacks: "perf report -n --stdio" and "perf script". The most common default for dumping stacks is caller. Eg:

And you use that for scripting?

Quoted 8 lines

Yes; how I typically CPU profile:

git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl | /flamegraph.pl > flame.svg

Then open flame.svg in a browser and click around. Try it. :)

So I tried it:

triton:~/s/FlameGraph> ls -l flame.svg -rw-rw-r-- 1 mingo mingo 1022870 Oct 10 09:06 flame.svg

but when I tried to view it via ImageMagick, it first showed an empty screen:

triton:~/s/FlameGraph> display flame.svg

then when exiting it said:

display: non-conforming drawing primitive definition `text-anchor' @ error/draw.c/DrawImage/3182.

Quoted 7 lines
Quoted 3 lines

although I guess that latter is an unrealted ImageMagick problem, not caused by the SVG.

Sorry, I should have said to open it in a browser (Chrome/Firefox); the SVG contains some (entirely embedded) JavaScript to provide interactivity (click to zoom, Ctrl-F to search).

aw, very nice output!

Thanks,

Ingo

#40 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo
Quoted 41 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

---
 tools/perf/Documentation/perf-report.txt | 2 +-
 tools/perf/builtin-report.c              | 4 ++--
 tools/perf/util/util.c                   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -1
index ce499035e6d8..e4fdeeb51123 100644
@@ -192,7 +192,7 @@ OPTIONS
 	when available. Usually more convenient to use --branch-history
 	for this.
 
-	Default: fractal,0.5,callee,function.
+	Default: graph,0.5,caller
 
 --children::
 	Accumulate callchain of children to parent entry so that then can
tools/perf/builtin-report.c +0 -0
index b5623639f67d..3b23b25d1589 100644

tools/perf/builtin-report.c int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) · line 636

Quoted 5 lines
tools/perf/builtin-report.c +1 -1
@@ -633,7 +633,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	bool has_br_stack = false;
 	int branch_mode = -1;
 	bool branch_call_mode = false;
-	char callchain_default_opt[] = "fractal,0.5,callee";
+	char callchain_default_opt[] = "graph,0.5,caller";

I'm a bit worried about that. I find callee order usually useful in most cases. People tend to run perf to zoom in the culprit of a performance issue.

Quoted 17 lines
tools/perf/builtin-report.c +1 -1
 	const char * const report_usage[] = {
 		"perf report [<options>]",
 		NULL
@@ -701,7 +701,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "Only display entries with parent-match"),
 	OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order[,branch]",
 		     "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches. "
-		     "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
+		     "Default: graph,0.5,caller", &report_parse_callchain_opt, callchain_default_opt),
 	OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
 		    "Accumulate callchains of children and show total overhead as well"),
 	OPT_INTEGER(0, "max-stack", &report.max_stack,
tools/perf/util/util.c +0 -0
index ce465b259e52..c1bf9ff210b0 100644

tools/perf/util/util.c line 20

Quoted 5 lines
tools/perf/util/util.c +1 -1
@@ -17,9 +17,9 @@
 #include "callchain.h"
 
 struct callchain_param	callchain_param = {
-	.mode	= CHAIN_GRAPH_REL,
+	.mode	= CHAIN_GRAPH_ABS,

And this worries me as well :-)

Quoted 9 lines
tools/perf/util/util.c +1 -1
 	.min_percent = 0.5,
-	.order  = ORDER_CALLEE,
+	.order  = ORDER_CALLER,
 	.key	= CCKEY_FUNCTION
 };
 
Signature · 1 line
2.1.0
maintainer
#41 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo
Quoted 3 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

I think it's more useful to change the default only when --children is used. And there's a related issue too - please see below link:

https://lkml.org/lkml/2014/8/14/49

Thanks,
Namhyung

Quoted 74 lines
---
 tools/perf/Documentation/perf-report.txt | 2 +-
 tools/perf/builtin-report.c              | 4 ++--
 tools/perf/util/util.c                   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -1
index ce499035e6d8..e4fdeeb51123 100644
@@ -192,7 +192,7 @@ OPTIONS
 	when available. Usually more convenient to use --branch-history
 	for this.
 
-	Default: fractal,0.5,callee,function.
+	Default: graph,0.5,caller
 
 --children::
 	Accumulate callchain of children to parent entry so that then can
tools/perf/builtin-report.c +2 -2
index b5623639f67d..3b23b25d1589 100644
@@ -633,7 +633,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	bool has_br_stack = false;
 	int branch_mode = -1;
 	bool branch_call_mode = false;
-	char callchain_default_opt[] = "fractal,0.5,callee";
+	char callchain_default_opt[] = "graph,0.5,caller";
 	const char * const report_usage[] = {
 		"perf report [<options>]",
 		NULL
@@ -701,7 +701,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "Only display entries with parent-match"),
 	OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order[,branch]",
 		     "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches. "
-		     "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
+		     "Default: graph,0.5,caller", &report_parse_callchain_opt, callchain_default_opt),
 	OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
 		    "Accumulate callchains of children and show total overhead as well"),
 	OPT_INTEGER(0, "max-stack", &report.max_stack,
tools/perf/util/util.c +2 -2
index ce465b259e52..c1bf9ff210b0 100644
@@ -17,9 +17,9 @@
 #include "callchain.h"
 
 struct callchain_param	callchain_param = {
-	.mode	= CHAIN_GRAPH_REL,
+	.mode	= CHAIN_GRAPH_ABS,
 	.min_percent = 0.5,
-	.order  = ORDER_CALLEE,
+	.order  = ORDER_CALLER,
 	.key	= CCKEY_FUNCTION
 };
 
Signature · 1 line
2.1.0
#42 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 9 lines · Namhyung Kim
Quoted 3 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

I think it's more useful to change the default only when --children is used. And there's a related issue too - please see below link:

https://lkml.org/lkml/2014/8/14/49

--children is default for things like "perf report --stdio" and (implied) "perf script", so any change to --children is a change to default.

Brendan

maintainer
#43 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Hi Brendan,

Quoted 6 lines · Brendan Gregg
Quoted 5 lines · Namhyung Kim
Quoted 3 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Quoted 8 lines
Quoted 4 lines

I think it's more useful to change the default only when --children is used. And there's a related issue too - please see below link:

https://lkml.org/lkml/2014/8/14/49

--children is default for things like "perf report --stdio" and (implied) "perf script", so any change to --children is a change to default.

Hmm.. right. It should change the default only when --children is actually used in "perf report" or "perf top" so that "perf script" or other commands should not be changed.

Thanks,
Namhyung

#44 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo

Hi Arnaldo,

Quoted 3 lines · Arnaldo Carvalho de Melo

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

Which is the most common default found in other similar tools.

Could you please show me some example about "other similar tools"? For me, in most of the case I prefer callee order because most of my task is to explain the reason why some code get executed too much times than expected.

Also, I think changing default settings should be careful.

This is my story: after switching to new version of perf, in a period of time there are plenty of perf users in my company be confused by the first column of 'perf report' because the sum of the percentage listed there is much higher than 100%. They find me because they think this is a bug in perf which breaks their routinely profiling work. The "problem" is caused by the adding of "--children". New perf makes '--children' as the default behavior at the first time it support that option, but the old perf shows things similar to '--no-children'. However, it is hard to explain the principle of call stack accumulation and why we need '--children' to those perf users (they learned perf's command line from others, and don't have enought to read perf documentations or even help output. Althought the title of the first column is changed to 'Children', I don't think they can understand the meaning of it. I think some of them didn't even notice there's an addition column in their output. They just confused and angry). Also, and as you can expect, this change breaks some scripts. In those days I have to make our IM tool response the information of "--no-children" automatically.

This patch changes the default output again. Similar thing will happen another time. I think this time I can make some preparation, for example, prepare new script to restore old behavior?

Thank you.

Quoted 70 lines
---
  tools/perf/Documentation/perf-report.txt | 2 +-
  tools/perf/builtin-report.c              | 4 ++--
  tools/perf/util/util.c                   | 4 ++--
  3 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -1
index ce499035e6d8..e4fdeeb51123 100644
@@ -192,7 +192,7 @@ OPTIONS
  	when available. Usually more convenient to use --branch-history
  	for this.
 
-	Default: fractal,0.5,callee,function.
+	Default: graph,0.5,caller
 
  --children::
  	Accumulate callchain of children to parent entry so that then can
tools/perf/builtin-report.c +2 -2
index b5623639f67d..3b23b25d1589 100644
@@ -633,7 +633,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
  	bool has_br_stack = false;
  	int branch_mode = -1;
  	bool branch_call_mode = false;
-	char callchain_default_opt[] = "fractal,0.5,callee";
+	char callchain_default_opt[] = "graph,0.5,caller";
  	const char * const report_usage[] = {
  		"perf report [<options>]",
  		NULL
@@ -701,7 +701,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
  		    "Only display entries with parent-match"),
  	OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order[,branch]",
  		     "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches. "
-		     "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
+		     "Default: graph,0.5,caller", &report_parse_callchain_opt, callchain_default_opt),
  	OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
  		    "Accumulate callchains of children and show total overhead as well"),
  	OPT_INTEGER(0, "max-stack", &report.max_stack,
tools/perf/util/util.c +2 -2
index ce465b259e52..c1bf9ff210b0 100644
@@ -17,9 +17,9 @@
  #include "callchain.h"
 
  struct callchain_param	callchain_param = {
-	.mode	= CHAIN_GRAPH_REL,
+	.mode	= CHAIN_GRAPH_ABS,
  	.min_percent = 0.5,
-	.order  = ORDER_CALLEE,
+	.order  = ORDER_CALLER,
  	.key	= CCKEY_FUNCTION
  };
 
#45 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Tue, Oct 20, 2015 at 09:23:12PM +0800, Wangnan (F) escreveu:

Quoted 30 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

From: Arnaldo Carvalho de Melo <[email protected]> Which is the most common default found in other similar tools.

Could you please show me some example about "other similar tools"? For me, in most of the case I prefer callee order because most of my task is to explain the reason why some code get executed too much times than expected.

Also, I think changing default settings should be careful.

This is my story: after switching to new version of perf, in a period of time there are plenty of perf users in my company be confused by the first column of 'perf report' because the sum of the percentage listed there is much higher than 100%. They find me because they think this is a bug in perf which breaks their routinely profiling work. The "problem" is caused by the adding of "--children". New perf makes '--children' as the default behavior at the first time it support that option, but the old perf shows things similar to '--no-children'. However, it is hard to explain the principle of call stack accumulation and why we need '--children' to those perf users (they learned perf's command line from others, and don't have enought to read perf documentations or even help output. Althought the title of the first column is changed to 'Children', I don't think they can understand the meaning of it. I think some of them didn't even notice there's an addition column in their output. They just confused and angry). Also, and as you can expect, this change breaks some scripts. In those days I have to make our IM tool response the information of "--no-children" automatically.

Quoted 3 lines

This patch changes the default output again. Similar thing will happen another time. I think this time I can make some preparation, for example, prepare new script to restore old behavior?

I was bitten by the --children thing and took some time to get used to it, so I can relate to that...

I think we should revert this change in callchain default, enough complaints... Ingo, since you suggested that change, what are your thoughts?

Changing defaults is hard, there is also the horizontal scrolling that made we repurpose the right and left arrows, sigh, that one will cause some confusion as well...

It seems we'll need way more preparation for such changes, more infrastructure to ease the transition, questioning if the user wants that, etc, growing pains :-\

- Arnaldo

Quoted 69 lines

Thank you.

Quoted 66 lines
---
 tools/perf/Documentation/perf-report.txt | 2 +-
 tools/perf/builtin-report.c              | 4 ++--
 tools/perf/util/util.c                   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -1
index ce499035e6d8..e4fdeeb51123 100644
@@ -192,7 +192,7 @@ OPTIONS
 	when available. Usually more convenient to use --branch-history
 	for this.
-	Default: fractal,0.5,callee,function.
+	Default: graph,0.5,caller
 --children::
 	Accumulate callchain of children to parent entry so that then can
tools/perf/builtin-report.c +2 -2
index b5623639f67d..3b23b25d1589 100644
@@ -633,7 +633,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	bool has_br_stack = false;
 	int branch_mode = -1;
 	bool branch_call_mode = false;
-	char callchain_default_opt[] = "fractal,0.5,callee";
+	char callchain_default_opt[] = "graph,0.5,caller";
 	const char * const report_usage[] = {
 		"perf report [<options>]",
 		NULL
@@ -701,7 +701,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "Only display entries with parent-match"),
 	OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order[,branch]",
 		     "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches. "
-		     "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
+		     "Default: graph,0.5,caller", &report_parse_callchain_opt, callchain_default_opt),
 	OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
 		    "Accumulate callchains of children and show total overhead as well"),
 	OPT_INTEGER(0, "max-stack", &report.max_stack,
tools/perf/util/util.c +2 -2
index ce465b259e52..c1bf9ff210b0 100644
@@ -17,9 +17,9 @@
 #include "callchain.h"
 struct callchain_param	callchain_param = {
-	.mode	= CHAIN_GRAPH_REL,
+	.mode	= CHAIN_GRAPH_ABS,
 	.min_percent = 0.5,
-	.order  = ORDER_CALLEE,
+	.order  = ORDER_CALLER,
 	.key	= CCKEY_FUNCTION
 };
maintainer
#46 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 31 lines · Arnaldo Carvalho de Melo

Em Tue, Oct 20, 2015 at 09:23:12PM +0800, Wangnan (F) escreveu:

Quoted 30 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

From: Arnaldo Carvalho de Melo <[email protected]> Which is the most common default found in other similar tools.

Could you please show me some example about "other similar tools"? For me, in most of the case I prefer callee order because most of my task is to explain the reason why some code get executed too much times than expected.

Also, I think changing default settings should be careful.

This is my story: after switching to new version of perf, in a period of time there are plenty of perf users in my company be confused by the first column of 'perf report' because the sum of the percentage listed there is much higher than 100%. They find me because they think this is a bug in perf which breaks their routinely profiling work. The "problem" is caused by the adding of "--children". New perf makes '--children' as the default behavior at the first time it support that option, but the old perf shows things similar to '--no-children'. However, it is hard to explain the principle of call stack accumulation and why we need '--children' to those perf users (they learned perf's command line from others, and don't have enought to read perf documentations or even help output. Althought the title of the first column is changed to 'Children', I don't think they can understand the meaning of it. I think some of them didn't even notice there's an addition column in their output. They just confused and angry). Also, and as you can expect, this change breaks some scripts. In those days I have to make our IM tool response the information of "--no-children" automatically.

Quoted 6 lines
Quoted 3 lines

This patch changes the default output again. Similar thing will happen another time. I think this time I can make some preparation, for example, prepare new script to restore old behavior?

I was bitten by the --children thing and took some time to get used to it, so I can relate to that...

I feel sorry about that. I did worry about the existing users when making the --children default and actually I didn't agree with making it default at first. :-(

Quoted 8 lines

I think we should revert this change in callchain default, enough complaints... Ingo, since you suggested that change, what are your thoughts?

Changing defaults is hard, there is also the horizontal scrolling that made we repurpose the right and left arrows, sigh, that one will cause some confusion as well...

Yeah, it worries me too. That's why I used '<' and '>' key for scrolling in my patch. Maybe it's worth adding those keys again, reverting arrows key actions, and show some message that it'll be changed later?

Quoted 4 lines

It seems we'll need way more preparation for such changes, more infrastructure to ease the transition, questioning if the user wants that, etc, growing pains :-\

Yes, it reminds me of changing default push behavior in git 2.0. We need to provide info and wait for enough time before changing some behavior IMHO.

Thanks,
Namhyung

#47 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo
Quoted 5 lines · Arnaldo Carvalho de Melo

I was bitten by the --children thing and took some time to get used to it, so I can relate to that...

I think we should revert this change in callchain default, enough complaints... Ingo, since you suggested that change, what are your thoughts?

Btw., one side note, I noticed that the call-graph options to 'perf top' do not match that of perf report. I tried for a couple of minutes to figure out why this doesn't work:

perf top -g graph,0.5,caller

... only to notice that it's perf report options.

A couple of thoughts about defaults:

1)

I think 'perf top' and 'perf report' should provide the very same output by default. The two tools are unified, and we should think of 'perf top' more of a rolling, continuously updated perf report, with some dynamic runtime features that go beyond a simple perf report. Making them diverge only creates confusion.

2) min-percentage

I suspect the '0.5%' part of the default is not contested by anyone?

3) 'graph' vs. 'fractal'

The 'graph' part of the default: I think 'graph' (absolute percentages) is more intuitive in general than 'fractal' (relative percentages), especially when drilling down deep into more complex call graphs.

For example, if you look at this output:

                    |          |          |          |--41.61%-- local_apic_timer_interrupt
                    |          |          |          |          |          
                    |          |          |          |           --100.00%-- hrtimer_interrupt
                    |          |          |          |                     __run_hrtimer
                    |          |          |          |                     |          
                    |          |          |          |                     |--72.98%-- hrtimer_wakeup
                    |          |          |          |                     |          wake_up_process
                    |          |          |          |                     |          |          
                    |          |          |          |                     |           --100.00%-- try_to_wake_up
                    |          |          |          |                     |                     ttwu_do_activate.constprop.93
                    |          |          |          |                     |                     activate_task
                    |          |          |          |                     |                     enqueue_task
                    |          |          |          |                     |                     enqueue_task_fair
                    |          |          |          |                     |                     enqueue_entity
                    |          |          |          |                     |          
                    |          |          |          |                      --27.02%-- ehci_hrtimer_func

Would you have guessed that its relevance in reality is:

                    |          |          |          |          
                    |          |          |          |--0.11%-- local_apic_timer_interrupt
                    |          |          |          |          |          
                    |          |          |          |           --0.10%-- hrtimer_interrupt
                    |          |          |          |                     __run_hrtimer
                    |          |          |          |                     |          
                    |          |          |          |                     |--0.07%-- hrtimer_wakeup
                    |          |          |          |                     |          wake_up_process
                    |          |          |          |                     |          |          
                    |          |          |          |                     |           --0.01%-- try_to_wake_up
                    |          |          |          |                     |                     ttwu_do_activate.constprop.93
                    |          |          |          |                     |                     activate_task
                    |          |          |          |                     |                     enqueue_task
                    |          |          |          |                     |                     enqueue_task_fair
                    |          |          |          |                     |                     enqueue_entity
                    |          |          |          |                     |          
                    |          |          |          |                      --0.03%-- ehci_hrtimer_func
                    |          |          |          |          

?

I think the 'big picture' should always be apparent, even when looking at a small detail. Also, it's not _that_ hard to see the relative weight of each entry even if they are small numbers.

Fractal output can be useful if you are trying to drill down really, really deep and only concentrate on that aspect - but that kind of workflow is probably best served via a search option in any case:

  perf report --call-graph fractal,0.5,caller --stdio --symbol-filter local_apic_timer_interrupt

In which case fractal output is the more intuitive one I suspect:

# To display the perf.data header info, please use --header/--header-only options. #
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:pp'
# Event count (approx.): 1155803425
#

  # Children      Self  Command  Shared Object      Symbol                        
  # ........  ........  .......  .................  ..............................

#
0.11% 0.01% swapper [kernel.kallsyms] [k] local_apic_timer_interrupt
|
|--89.19%-- local_apic_timer_interrupt
| hrtimer_interrupt
| __run_hrtimer
| |
| |--72.98%-- hrtimer_wakeup
| | wake_up_process
| | |
| | --100.00%-- try_to_wake_up
| | ttwu_do_activate.constprop.93
| | activate_task
| | enqueue_task
| | enqueue_task_fair
| | enqueue_entity
| |
| --27.02%-- ehci_hrtimer_func
|
--10.81%-- start_secondary
cpu_startup_entry cpuidle_enter apic_timer_interrupt smp_apic_timer_interrupt local_apic_timer_interrupt

#
# (For a higher level overview, try: perf report --sort comm,dso) #

Btw., I noticed an oddity, why doesn't "-S local_apic_timer_interrupt" produce any output? It was the first option I tried, and it only gave me:

triton:~/tip> perf report --call-graph fractal,0.5,caller --stdio -S local_apic_timer_interrupt [nv] with build id 744b5b4279152a54e61208989daf5d3d6b375aa3 not found, continuing without symbols Failed to open /tmp/perf-6650.map, continuing without symbols
# To display the perf.data header info, please use --header/--header-only options. #
# symbol: local_apic_timer_interrupt
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:pp'
# Event count (approx.): 1155803425
#

  # Children      Self  Command  Shared Object
  # ........  ........  .......  .............

#

#
# (For a higher level overview, try: perf report --sort comm,dso) #

some symbols could not be found - but the output is pretty confusing and misleading in outputing just empty headers, plus it doesn't explain why it does so.

4) 'caller' vs. 'callee'.

If I change 'caller' to 'callee' in the above example, I get this output:

triton:~/tip> perf report --call-graph fractal,0.5,callee --stdio --symbol-filter local_apic_timer_interrupt [nv] with build id 744b5b4279152a54e61208989daf5d3d6b375aa3 not found, continuing without symbols Failed to open /tmp/perf-6650.map, continuing without symbols
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:pp'
# Event count (approx.): 1155803425
#

  # Children      Self  Command  Shared Object      Symbol                        
  # ........  ........  .......  .................  ..............................

#
0.11% 0.01% swapper [kernel.kallsyms] [k] local_apic_timer_interrupt
|
---local_apic_timer_interrupt
smp_apic_timer_interrupt
apic_timer_interrupt
cpuidle_enter
cpu_startup_entry
start_secondary

#
# (For a higher level overview, try: perf report --sort comm,dso) #

That does not look very helpful, does it?

Now I tried to test caller vs. callee in perf top - but couldn't find a command line option to do it - is there any?

5) --no-children

I agree that 'perf top -g --no-children' looks more intuitive than 'perf top -g'.

Thanks,

Ingo

#48 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Wed, Oct 21, 2015 at 10:48:16AM +0200, Ingo Molnar escreveu:

Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 6 lines

I was bitten by the --children thing and took some time to get used to it, so I can relate to that...

I think we should revert this change in callchain default, enough complaints... Ingo, since you suggested that change, what are your thoughts?

Quoted 7 lines

Btw., one side note, I noticed that the call-graph options to 'perf top' do not match that of perf report. I tried for a couple of minutes to figure out why this doesn't work:

perf top -g graph,0.5,caller

... only to notice that it's perf report options.

Right, 'perf top' needs 'record' and 'report' knobs, so, for -g, it uses the 'record' semantics where its parameters specify how to _collect_ the callchains, not how to _present_ them, i.e.:

perf report:
-g, --call-graph <output_type,min_percent[,print_limit],call_order[,branch]>
Display callchains using output_type (graph, flat, fractal or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches.
Default: graph,0.5,caller

perf record:

-g enables call-graph recording
--call-graph <mode[,dump_size]>
setup and enables call-graph (stack chain/backtrace)
recording: fp dwarf lbr

perf top:
-g enables call-graph recording
--call-graph <mode[,dump_size]>
setup and enables call-graph (stack chain/backtrace)
recording: fp dwarf lbr

Possibly we could make it smart and accept both cases, interpreting 'report' like parameters if starting with one of (graph, flat, fractal or none) having as a separator one of (fp, dwarf or lbr).

This way one could specify both how to collect and how to present callchains in one --call-graph call.

Quoted 8 lines

A couple of thoughts about defaults:

1)

I think 'perf top' and 'perf report' should provide the very same output by default. The two tools are unified, and we should think of 'perf top' more of a rolling, continuously updated perf report, with some dynamic runtime features that go beyond a simple perf report. Making them diverge only creates confusion.

That is the idea, now with 'f' (Enable/Disable events) in the TUI it is one step closer to that, i.e. it moves to/from top/dynamic to/from report/static,we need more code to ask it to start collecting into a perf.data so that it gets 'record', but the general idea is to have it all integrated.

Quoted 9 lines

2) min-percentage

I suspect the '0.5%' part of the default is not contested by anyone?

3) 'graph' vs. 'fractal'

The 'graph' part of the default: I think 'graph' (absolute percentages) is more intuitive in general than 'fractal' (relative percentages), especially when drilling down deep into more complex call graphs.

Here I'm more worried about polishing the invalid entries in callchains so that we can have sane caller based output.

With some work we could go to/from caller/callee without a huge impact, i.e. without the need to reprocess everything.

Quoted 92 lines

For example, if you look at this output:

                    |          |          |          |--41.61%-- local_apic_timer_interrupt
                    |          |          |          |          |          
                    |          |          |          |           --100.00%-- hrtimer_interrupt
                    |          |          |          |                     __run_hrtimer
                    |          |          |          |                     |          
                    |          |          |          |                     |--72.98%-- hrtimer_wakeup
                    |          |          |          |                     |          wake_up_process
                    |          |          |          |                     |          |          
                    |          |          |          |                     |           --100.00%-- try_to_wake_up
                    |          |          |          |                     |                     ttwu_do_activate.constprop.93
                    |          |          |          |                     |                     activate_task
                    |          |          |          |                     |                     enqueue_task
                    |          |          |          |                     |                     enqueue_task_fair
                    |          |          |          |                     |                     enqueue_entity
                    |          |          |          |                     |          
                    |          |          |          |                      --27.02%-- ehci_hrtimer_func

Would you have guessed that its relevance in reality is:

                    |          |          |          |          
                    |          |          |          |--0.11%-- local_apic_timer_interrupt
                    |          |          |          |          |          
                    |          |          |          |           --0.10%-- hrtimer_interrupt
                    |          |          |          |                     __run_hrtimer
                    |          |          |          |                     |          
                    |          |          |          |                     |--0.07%-- hrtimer_wakeup
                    |          |          |          |                     |          wake_up_process
                    |          |          |          |                     |          |          
                    |          |          |          |                     |           --0.01%-- try_to_wake_up
                    |          |          |          |                     |                     ttwu_do_activate.constprop.93
                    |          |          |          |                     |                     activate_task
                    |          |          |          |                     |                     enqueue_task
                    |          |          |          |                     |                     enqueue_task_fair
                    |          |          |          |                     |                     enqueue_entity
                    |          |          |          |                     |          
                    |          |          |          |                      --0.03%-- ehci_hrtimer_func
                    |          |          |          |          

?

I think the 'big picture' should always be apparent, even when looking at a small detail. Also, it's not _that_ hard to see the relative weight of each entry even if they are small numbers.

Fractal output can be useful if you are trying to drill down really, really deep and only concentrate on that aspect - but that kind of workflow is probably best served via a search option in any case:

  perf report --call-graph fractal,0.5,caller --stdio --symbol-filter local_apic_timer_interrupt

In which case fractal output is the more intuitive one I suspect:

# To display the perf.data header info, please use --header/--header-only options. #
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:pp'
# Event count (approx.): 1155803425
#

  # Children      Self  Command  Shared Object      Symbol                        
  # ........  ........  .......  .................  ..............................

#
0.11% 0.01% swapper [kernel.kallsyms] [k] local_apic_timer_interrupt
|
|--89.19%-- local_apic_timer_interrupt
| hrtimer_interrupt
| __run_hrtimer
| |
| |--72.98%-- hrtimer_wakeup
| | wake_up_process
| | |
| | --100.00%-- try_to_wake_up
| | ttwu_do_activate.constprop.93
| | activate_task
| | enqueue_task
| | enqueue_task_fair
| | enqueue_entity
| |
| --27.02%-- ehci_hrtimer_func
|
--10.81%-- start_secondary
cpu_startup_entry cpuidle_enter apic_timer_interrupt smp_apic_timer_interrupt local_apic_timer_interrupt

Quoted 6 lines

#
# (For a higher level overview, try: perf report --sort comm,dso) #

Btw., I noticed an oddity, why doesn't "-S local_apic_timer_interrupt" produce any output? It was the first option I tried, and it only gave me:

I'll check that

Quoted 17 lines

triton:~/tip> perf report --call-graph fractal,0.5,caller --stdio -S local_apic_timer_interrupt [nv] with build id 744b5b4279152a54e61208989daf5d3d6b375aa3 not found, continuing without symbols Failed to open /tmp/perf-6650.map, continuing without symbols
# To display the perf.data header info, please use --header/--header-only options. #
# symbol: local_apic_timer_interrupt
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:pp'
# Event count (approx.): 1155803425
#

  # Children      Self  Command  Shared Object
  # ........  ........  .......  .............

#

Quoted 7 lines

#
# (For a higher level overview, try: perf report --sort comm,dso) #

some symbols could not be found - but the output is pretty confusing and misleading in outputing just empty headers, plus it doesn't explain why it does so.

Needs fixing, will check

Quoted 33 lines

4) 'caller' vs. 'callee'.

If I change 'caller' to 'callee' in the above example, I get this output:

triton:~/tip> perf report --call-graph fractal,0.5,callee --stdio --symbol-filter local_apic_timer_interrupt [nv] with build id 744b5b4279152a54e61208989daf5d3d6b375aa3 not found, continuing without symbols Failed to open /tmp/perf-6650.map, continuing without symbols
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:pp'
# Event count (approx.): 1155803425
#

  # Children      Self  Command  Shared Object      Symbol                        
  # ........  ........  .......  .................  ..............................

#
0.11% 0.01% swapper [kernel.kallsyms] [k] local_apic_timer_interrupt
|
---local_apic_timer_interrupt
smp_apic_timer_interrupt
apic_timer_interrupt
cpuidle_enter
cpu_startup_entry
start_secondary

#
# (For a higher level overview, try: perf report --sort comm,dso) #

Quoted 8 lines

That does not look very helpful, does it?

Now I tried to test caller vs. callee in perf top - but couldn't find a command line option to do it - is there any?

5) --no-children

I agree that 'perf top -g --no-children' looks more intuitive than 'perf top -g'.

So, what do you propose, to switch back the default to --no-children, for both tools, top and report? Now that I am getting used to it... ;-)

- Arnaldo

#49 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Em Wed, Oct 21, 2015 at 10:43:48AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Wed, Oct 21, 2015 at 10:48:16AM +0200, Ingo Molnar escreveu:

Quoted 3 lines

5) --no-children

I agree that 'perf top -g --no-children' looks more intuitive than 'perf top -g'.

So, what do you propose, to switch back the default to --no-children, for both tools, top and report? Now that I am getting used to it... ;-)

And for this one, having a hotkey to toggle children/no-children, in 'top', using a big hammer (perhaps the only one possible since we have no perf.data file?) we could just trow away the existing hist_entries, and flip the relevant flag, the new samples would then use the new mode, etc.

For 'report' it would involve, at first sight, reprocessing everything, possibly saving some work because we already did symbol resolution, etc, i.e. the struct machine with its threads, etc will be all there.

- Arnaldo

#50 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

In reply to Arnaldo Carvalho de Melo
Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 3 lines

5) --no-children

I agree that 'perf top -g --no-children' looks more intuitive than 'perf top -g'.

So, what do you propose, to switch back the default to --no-children, for both tools, top and report? Now that I am getting used to it... ;-)

Heh ;-) So I'm only thinking out loud, trying to find the most intuitive initial screen to display. Expert users can configure their output any which way they want it to be, I'm not worried about them.

It's casual and in particular first-time users we should be worried about most - if they try the '-g' option in record, what will they first see in 'perf report' output?

I think the best output method would be to include only the 'highest level' parent symbols, with all children summed up under the parent's entry. Isn't the new 'graph,0.5,caller' default very close to that?

But what confuses me about the output is the same that confused Wangnan's users:

"This is my story: after switching to new version of perf, in a period of time
there are plenty of perf users in my company be confused by the first column of 'perf report' because the sum of the percentage listed there is much higher than 100%. They find me because they think this is a bug in perf which breaks their routinely profiling work."

So this is suboptimal.

The first column is 'Children', which should show the sum of all child overhead - but if a child overhead was already included under a parent, it should never show up under another parent's entry. I.e. the first column should only contain the highest level entries, no sub-entries.

But what we do currently is:

  Children      Self  Command        Shared Object       Symbol
-   70.41%     0.00%  cc1            cc1                 [.] toplev_main

- toplev_main
+ __libc_start_main
- 70.38% 0.00% cc1 libc-2.20.so [.] __libc_start_main
+ __libc_start_main

i.e. even though '__libc_start_main' is a child of 'toplev_main', it's still included on the 'overview' page.

Is there an output method that can do what I suggest above?

( Having both 'children' and 'self' columns in itself is intuitive IMHO: it shows
that an entry that is shown does not directly have overhead at that level, a child call of it has that overhead. )

Thanks,

Ingo

maintainer
#51 lore raw

Re: [PATCH 13/16] perf callchain: Switch default to 'graph,0.5,caller'

Quoted 5 lines · Ingo Molnar
Quoted 2 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

5) --no-children

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I agree that 'perf top -g --no-children' looks more intuitive than 'perf top -g'.

So, what do you propose, to switch back the default to --no-children, for both tools, top and report? Now that I am getting used to it... ;-)

Heh ;-) So I'm only thinking out loud, trying to find the most intuitive initial screen to display. Expert users can configure their output any which way they want it to be, I'm not worried about them.

:)

Quoted 8 lines

It's casual and in particular first-time users we should be worried about most - if they try the '-g' option in record, what will they first see in 'perf report' output?

I think the best output method would be to include only the 'highest level' parent symbols, with all children summed up under the parent's entry. Isn't the new 'graph,0.5,caller' default very close to that?

Hmm.. not sure I'm following well. what do you mean by 'highest level parent'? Do you want single depth callchains for each entry?

Quoted 9 lines

But what confuses me about the output is the same that confused Wangnan's users:

"This is my story: after switching to new version of perf, in a period of time
there are plenty of perf users in my company be confused by the first column of 'perf report' because the sum of the percentage listed there is much higher than 100%. They find me because they think this is a bug in perf which breaks their routinely profiling work."

Quoted 6 lines

So this is suboptimal.

The first column is 'Children', which should show the sum of all child overhead - but if a child overhead was already included under a parent, it should never show up under another parent's entry. I.e. the first column should only contain the highest level entries, no sub-entries.

Again, I don't understand. Could you elaborate it more probably with example below?

Quoted 10 lines

But what we do currently is:

Children Self Command Shared Object Symbol

(quoted diff) +0 -2
-   70.41%     0.00%  cc1            cc1                 [.] toplev_main
   - toplev_main
      + __libc_start_main
-   70.38%     0.00%  cc1            libc-2.20.so        [.] __libc_start_main
   + __libc_start_main
Quoted 2 lines

i.e. even though '__libc_start_main' is a child of 'toplev_main', it's still included on the 'overview' page.

Strange. AFAIK 'toplev_main' is a child of '__libc_start_main'. Are you using 'caller' ordering?

Also I think 'main' should be shown between 'toplev_main' and '__libc_start_main' but maybe it's a different issue.

Thanks,
Namhyung

Quoted 10 lines

Is there an output method that can do what I suggest above?

( Having both 'children' and 'self' columns in itself is intuitive IMHO: it shows
that an entry that is shown does not directly have overhead at that level, a child call of it has that overhead. )

Thanks,

Ingo

author maintainer
#52 lore raw

PATCH 14/16 perf ui browser: Optional horizontal scrolling key binding

In reply to Arnaldo Carvalho de Melo

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

If the classes derived from ui_browser want to do some sort of horizontal scrolling, they have just to set ui_browser->columns to the number of columns available.

Those columns can be the number of characters on the screen, if what is desired is to scroll character by character, or the number of columns in a spreadsheet like table.

This is what the hist_browser will do, skipping ui_browser->horiz_scroll columns when rendering each of its lines.

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/ui/browser.c | 14 ++++++++++++++
 tools/perf/ui/browser.h |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
tools/perf/ui/browser.c +14 -0
index c6c7e5189214..e9703c0829f1 100644
@@ -393,6 +393,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs)
 
 		if (browser->use_navkeypressed && !browser->navkeypressed) {
 			if (key == K_DOWN || key == K_UP ||
+			    (browser->columns && (key == K_LEFT || key == K_RIGHT)) ||
 			    key == K_PGDN || key == K_PGUP ||
 			    key == K_HOME || key == K_END ||
 			    key == ' ') {
@@ -421,6 +422,18 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs)
 				browser->seek(browser, -1, SEEK_CUR);
 			}
 			break;
+		case K_RIGHT:
+			if (!browser->columns)
+				goto out;
+			if (browser->horiz_scroll < browser->columns - 1)
+				++browser->horiz_scroll;
+			break;
+		case K_LEFT:
+			if (!browser->columns)
+				goto out;
+			if (browser->horiz_scroll != 0)
+				--browser->horiz_scroll;
+			break;
 		case K_PGDN:
 		case ' ':
 			if (browser->top_idx + browser->rows > browser->nr_entries - 1)
@@ -459,6 +472,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs)
 			browser->seek(browser, -offset, SEEK_END);
 			break;
 		default:
+		out:
 			return key;
 		}
 	}
tools/perf/ui/browser.h +1 -1
index f3cef564de02..01781de59532 100644
@@ -14,7 +14,7 @@
 struct ui_browser {
 	u64	      index, top_idx;
 	void	      *top, *entries;
-	u16	      y, x, width, height, rows;
+	u16	      y, x, width, height, rows, columns, horiz_scroll;
 	int	      current_color;
 	void	      *priv;
 	const char    *title;
Signature · 1 line
2.1.0
author maintainer
#53 lore raw

PATCH 15/16 perf hists browser: Implement horizontal scrolling

In reply to Arnaldo Carvalho de Melo

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

Do it using the recently introduced ui_brower scrolling mode, setting ui_browser.columns to the number of sort columns and then, when rendering each line, skipping as many initial columns as the user pressed the right arrow.

As the user presses the left arrow, the ui_browser code will remove the scrolling counter and the left scrolling takes place.

The right arrow key was an alias for ENTER, so people used to press it may get a bit annoyed at first, sorry! Ditto for ESC and the left key.

Callchains can be left as is or we can, when rendering the Symbol column, store the at what position on the screen it is and then using ui_browser__gotorc() to print it from there, i.e. the callchain would move around with the symbol.

Leaving it as is, i.e. at a fixed position, close to the left, saves precious screen real state for it, so I'm inclined to leave it as is now.

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Chandler Carruth <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/ui/browsers/hists.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
tools/perf/ui/browsers/hists.c +17 -5
index a4e9b370c037..9b7346a881cf 100644
@@ -784,11 +784,12 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 			.size		= sizeof(s),
 			.ptr		= &arg,
 		};
+		int column = 0;
 
 		hist_browser__gotorc(browser, row, 0);
 
 		perf_hpp__for_each_format(fmt) {
-			if (perf_hpp__should_skip(fmt))
+			if (perf_hpp__should_skip(fmt) || column++ < browser->b.horiz_scroll)
 				continue;
 
 			if (current_entry && browser->b.navkeypressed) {
@@ -861,14 +862,16 @@ static int advance_hpp_check(struct perf_hpp *hpp, int inc)
 	return hpp->size <= 0;
 }
 
-static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)
+static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf, size_t size)
 {
+	struct hists *hists = browser->hists;
 	struct perf_hpp dummy_hpp = {
 		.buf    = buf,
 		.size   = size,
 	};
 	struct perf_hpp_fmt *fmt;
 	size_t ret = 0;
+	int column = 0;
 
 	if (symbol_conf.use_callchain) {
 		ret = scnprintf(buf, size, "  ");
@@ -877,7 +880,7 @@ static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)
 	}
 
 	perf_hpp__for_each_format(fmt) {
-		if (perf_hpp__should_skip(fmt))
+		if (perf_hpp__should_skip(fmt)  || column++ < browser->b.horiz_scroll)
 			continue;
 
 		ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
@@ -896,7 +899,7 @@ static void hist_browser__show_headers(struct hist_browser *browser)
 {
 	char headers[1024];
 
-	hists__scnprintf_headers(headers, sizeof(headers), browser->hists);
+	hists_browser__scnprintf_headers(browser, headers, sizeof(headers));
 	ui_browser__gotorc(&browser->b, 0, 0);
 	ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
 	ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
@@ -1806,8 +1809,17 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	memset(options, 0, sizeof(options));
 	memset(actions, 0, sizeof(actions));
 
-	perf_hpp__for_each_format(fmt)
+	perf_hpp__for_each_format(fmt) {
 		perf_hpp__reset_width(fmt, hists);
+		/*
+		 * This is done just once, and activates the horizontal scrolling
+		 * code in the ui_browser code, it would be better to have a the
+		 * counter in the perf_hpp code, but I couldn't find doing it here
+		 * works, FIXME by setting this in hist_browser__new, for now, be
+		 * clever 8-)
+		 */
+		++browser->b.columns;
+	}
 
 	if (symbol_conf.col_width_list_str)
 		perf_hpp__set_user_width(symbol_conf.col_width_list_str);
Signature · 1 line
2.1.0
author maintainer
#54 lore raw

PATCH 16/16 perf tools: Fail properly in case pattern matching fails to find tracepoint

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Currently we dont fail properly when pattern matching fails to find any tracepoint.

Current behaviour:

  $ perf record -e 'sched:krava*' sleep 1
  WARNING: event parser found nothinginvalid or unsupported event: 'sched:krava*'
  Run 'perf list' for a list of valid events

usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]

This patch change:

  $ perf record -e 'sched:krava*' sleep 1
  event syntax error: 'sched:krava*'
                       \___ unknown tracepoint

Error: File /sys/kernel/debug/tracing/events/sched/krava* not found.
Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?.

Run 'perf list' for a list of valid events

usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]

---
 tools/perf/util/parse-events.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/util/parse-events.c +8 -1
index 3ed8bf175163..991bbd469bea 100644
@@ -449,7 +449,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
 	char evt_path[MAXPATHLEN];
 	struct dirent *evt_ent;
 	DIR *evt_dir;
-	int ret = 0;
+	int ret = 0, found = 0;
 
 	snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
 	evt_dir = opendir(evt_path);
@@ -468,10 +468,17 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
 		if (!strglobmatch(evt_ent->d_name, evt_name))
 			continue;
 
+		found++;
+
 		ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name,
 				     err, head_config);
 	}
 
+	if (!found) {
+		tracepoint_error(err, ENOENT, sys_name, evt_name);
+		ret = -1;
+	}
+
 	closedir(evt_dir);
 	return ret;
 }
Signature · 1 line
2.1.0
#55 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 133 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit e3b0ac1b7a8a590440a2030e7d10d48c59ab8a2a:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-10-03 08:20:14 +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

for you to fetch changes up to 27bf90bf0690f55c3679bcc4c325823cf1cfd19d:

perf tools: Fail properly in case pattern matching fails to find tracepoint (2015-10-05 17:59:50 -0300)

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

User visible:

- Switch the default callchain output mode to 'graph,0.5,caller', to make it look like the default for other tools, reducing the learning curve for people used to 'caller' based viewing (Arnaldo Carvalho de Melo)

- Implement column based horizontal scrolling in the hists browser (top, report), making it possible to use the TUI for things like 'perf mem report' where there are many more columns than can fit in a terminal (Arnaldo Carvalho de Melo)

- Support sorting by symbol_iaddr with perf.data files produced by 'perf mem record' (Don Zickus)

- Display DATA_SRC sample type bit, i.e. when running 'perf evlist -v' the "DATA_SRC" wasn't appearing when set, fix it to look like: (Jiri Olsa)

cpu/mem-loads/pp: ...SNIP... sample_type: IP|TID|TIME|ADDR|CPU|PERIOD|DATA_SRC

- Introduce 'P' event modified, meaning 'max precision level, please', i.e.:

   $ perf record -e cycles:P usleep 1

Is now similar to:

   $ perf record usleep 1

Useful, for instance, when specifying multiple events (Jiri Olsa)

- Make 'perf -v' and 'perf -h' work (Jiri Olsa)

- Fail properly when pattern matching fails to find a tracepoint, i.e. '-e non:existent' was being correctly handled, with a proper error message about that not being a valid event, but '-e non:existent*' wasn't, fix it (Jiri Olsa)

Infrastructure:

- Separate arch specific entries in 'perf test' and add an 'Intel CQM' one to be fun on x86 only (Matt Fleming)

----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf callchain: Switch default to 'graph,0.5,caller' perf ui browser: Optional horizontal scrolling key binding perf hists browser: Implement horizontal scrolling

Don Zickus (1):
perf tools: Add support for sorting on the iaddr

Jiri Olsa (9):
tools lib api fs: No need to use PATH_MAX + 1
perf evlist: Display DATA_SRC sample type bit
perf annotate: Fix sizeof_sym_hist overflow issue
perf tools: Export perf_event_attr__set_max_precise_ip()
perf tools: Introduce 'P' modifier to request max precision perf tests: Add parsing test for 'P' modifier
perf tools: Setup proper width for symbol_iaddr field
perf tools: Handle -h and -v options
perf tools: Fail properly in case pattern matching fails to find tracepoint

Matt Fleming (3):
perf tests: Add arch tests
perf tests: Move x86 tests into arch directory perf tests: Add Intel CQM test

 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-report.txt           |   2 +-
 tools/perf/Documentation/perf.txt                  |   8 ++
 tools/perf/arch/x86/Build                          |   2 +-
 tools/perf/arch/x86/include/arch-tests.h           |  19 ++++
 tools/perf/arch/x86/tests/Build                    |  10 +-
 tools/perf/arch/x86/tests/arch-tests.c             |  34 ++++++
 tools/perf/arch/x86/tests/dwarf-unwind.c           |   1 +
 .../perf/{ => arch/x86}/tests/gen-insn-x86-dat.awk |   0
 .../perf/{ => arch/x86}/tests/gen-insn-x86-dat.sh  |   0
 tools/perf/{ => arch/x86}/tests/insn-x86-dat-32.c  |   0
 tools/perf/{ => arch/x86}/tests/insn-x86-dat-64.c  |   0
 tools/perf/{ => arch/x86}/tests/insn-x86-dat-src.c |   0
 tools/perf/{ => arch/x86}/tests/insn-x86.c         |   3 +-
 tools/perf/arch/x86/tests/intel-cqm.c              | 124 +++++++++++++++++++++
 tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   4 +-
 tools/perf/{ => arch/x86}/tests/rdpmc.c            |   7 +-
 tools/perf/builtin-report.c                        |   4 +-
 tools/perf/perf.c                                  |  14 +++
 tools/perf/tests/Build                             |   6 -
 tools/perf/tests/builtin-test.c                    |  56 ++++------
 tools/perf/tests/dwarf-unwind.c                    |   4 +
 tools/perf/tests/parse-events.c                    |  16 +++
 tools/perf/tests/tests.h                           |  10 +-
 tools/perf/ui/browser.c                            |  14 +++
 tools/perf/ui/browser.h                            |   2 +-
 tools/perf/ui/browsers/hists.c                     |  22 +++-
 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                     |  17 ++-
 tools/perf/util/parse-events.l                     |   2 +-
 tools/perf/util/sort.c                             |  37 ++++++
 tools/perf/util/sort.h                             |   1 +
 tools/perf/util/util.c                             |   4 +-
 41 files changed, 381 insertions(+), 77 deletions(-)
 create mode 100644 tools/perf/arch/x86/include/arch-tests.h
 create mode 100644 tools/perf/arch/x86/tests/arch-tests.c
 rename tools/perf/{ => arch/x86}/tests/gen-insn-x86-dat.awk (100%)
Quoted 8 lines
 rename tools/perf/{ => arch/x86}/tests/gen-insn-x86-dat.sh (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86-dat-32.c (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86-dat-64.c (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86-dat-src.c (100%)
 rename tools/perf/{ => arch/x86}/tests/insn-x86.c (98%)
 create mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
 rename tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c (98%)
 rename tools/perf/{ => arch/x86}/tests/rdpmc.c (97%)

Pulled, thanks a lot Arnaldo!

Ingo