Skip to contentSkip to conversation

perf/urgent fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 12 messages Oct 29, 2014 – Oct 30, 2014 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 1776b10627e486dd431fe72d8d47e5a865cf65d1:

perf/x86/intel: Revert incomplete and undocumented Broadwell client support (2014-10-29 11:07:58 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo

for you to fetch changes up to 4cdcc33db2f0455f297b4e14e434ba311ec5ca06:

perf probe: Trivial typo fix for --demangle (2014-10-29 10:30:18 -0200)

----------------------------------------------------------------
perf/urgent fixes:

User visible:

* Fix report -F (abort, in_tx, mispredict, etc) segfaults for sample.data files without branch info (Jiri Olsa)

* Add patch that should have went in a previous patchkit to use global cache provided by libunwind (Namhyung Kim)

* Make CPUINFO_PROC an array to support different kernels, problem detected when the information reported via /proc/cpuinfo changed on ARM (Wang Nan)

* 'perf probe' --demangle typo fix and a new --quiet option (Masami Hiramatsu)

----------------------------------------------------------------
Jiri Olsa (7):
perf tools: Fix report -F abort for data without branch info perf tools: Fix report -F in_tx for data without branch info perf tools: Fix report -F mispredict for data without branch info perf tools: Fix report -F symbol_to for data without branch info perf tools: Fix report -F symbol_from for data without branch info perf tools: Fix report -F dso_to for data without branch info perf tools: Fix report -F dso_from for data without branch info

Masami Hiramatsu (1):
perf probe: Trivial typo fix for --demangle

Namhyung Kim (1):
perf callchain: Use global caching provided by libunwind

Wang Nan (1):
perf tools: Make CPUINFO_PROC an array to support different kernel versions

 tools/perf/builtin-probe.c         |   2 +-
 tools/perf/perf-sys.h              |  30 +++++------
 tools/perf/util/header.c           |  27 +++++++---
 tools/perf/util/sort.c             | 102 +++++++++++++++++++++++++++----------
 tools/perf/util/thread.c           |   3 ++
 tools/perf/util/unwind-libunwind.c |  12 +++++
 tools/perf/util/unwind.h           |   3 ++
 7 files changed, 131 insertions(+), 48 deletions(-)
author maintainer
#1 lore raw

PATCH 1/10 perf callchain: Use global caching provided by libunwind

From: Namhyung Kim <[email protected]>

The libunwind provides two caching policy which are global and per-thread. As perf unwinds callchains in a single thread, it'd sufficient to use global caching.

This speeds up my perf report from 14s to 7s on a ~260MB data file. Although the output sometimes contains a slight difference (~0.01% in terms of number of lines printed) on callchains which were not resolved.

---
 tools/perf/util/thread.c           |  3 +++
 tools/perf/util/unwind-libunwind.c | 12 ++++++++++++
 tools/perf/util/unwind.h           |  3 +++
 3 files changed, 18 insertions(+)
tools/perf/util/thread.c +3 -0
index 2b7b2d91c016..c41411726c7a 100644
@@ -117,6 +117,9 @@ int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp,
 		if (!new)
 			return -ENOMEM;
 		list_add(&new->list, &thread->comm_list);
+
+		if (exec)
+			unwind__flush_access(thread);
 	}
 
 	thread->comm_set = true;
tools/perf/util/unwind-libunwind.c +12 -0
index e060386165c5..4d45c0dfe343 100644
@@ -539,11 +539,23 @@ int unwind__prepare_access(struct thread *thread)
 		return -ENOMEM;
 	}
 
+	unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
 	thread__set_priv(thread, addr_space);
 
 	return 0;
 }
 
+void unwind__flush_access(struct thread *thread)
+{
+	unw_addr_space_t addr_space;
+
+	if (callchain_param.record_mode != CALLCHAIN_DWARF)
+		return;
+
+	addr_space = thread__priv(thread);
+	unw_flush_cache(addr_space, 0, 0);
+}
+
 void unwind__finish_access(struct thread *thread)
 {
 	unw_addr_space_t addr_space;
tools/perf/util/unwind.h +3 -0
index c17c4855bdbc..f50b737235eb 100644
@@ -23,6 +23,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 #ifdef HAVE_LIBUNWIND_SUPPORT
 int libunwind__arch_reg_id(int regnum);
 int unwind__prepare_access(struct thread *thread);
+void unwind__flush_access(struct thread *thread);
 void unwind__finish_access(struct thread *thread);
 #else
 static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
@@ -30,6 +31,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
 	return 0;
 }
 
+static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
 static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
 #endif
 #else
@@ -49,6 +51,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
 	return 0;
 }
 
+static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
 static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
 #endif /* HAVE_DWARF_UNWIND_SUPPORT */
 #endif /* __UNWIND_H */
Signature · 1 line
1.9.3
author maintainer
#2 lore raw

PATCH 2/10 perf tools: Make CPUINFO_PROC an array to support different kernel versions

In reply to Arnaldo Carvalho de Melo

From: Wang Nan <[email protected]>

After kernel 3.7 (commit b4b8f770eb10a1bccaf8aa0ec1956e2dd7ed1e0a), /proc/cpuinfo replaces 'Processor' to 'model name'.

This patch makes CPUINFO_PROC to an array and provides two choices for ARM, makes it compatible for different kernel version.

v1 -> v2: minor changes as suggested by Namhyung Kim:

- Doesn't pass @h and @evlist to __write_cpudesc;
- Coding style fix.

v2 -> v3:
- Rebase:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf/core

---
 tools/perf/perf-sys.h    | 30 +++++++++++++++---------------
 tools/perf/util/header.c | 27 +++++++++++++++++++++------
 2 files changed, 36 insertions(+), 21 deletions(-)
tools/perf/perf-sys.h +15 -15
index 937e4324ad94..a3b13d7dc1d4 100644
@@ -13,7 +13,7 @@
 #define wmb()		asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
 #define rmb()		asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
-#define CPUINFO_PROC	"model name"
+#define CPUINFO_PROC	{"model name"}
 #ifndef __NR_perf_event_open
 # define __NR_perf_event_open 336
 #endif
@@ -30,7 +30,7 @@
 #define wmb()		asm volatile("sfence" ::: "memory")
 #define rmb()		asm volatile("lfence" ::: "memory")
 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
-#define CPUINFO_PROC	"model name"
+#define CPUINFO_PROC	{"model name"}
 #ifndef __NR_perf_event_open
 # define __NR_perf_event_open 298
 #endif
@@ -47,14 +47,14 @@
 #define mb()		asm volatile ("sync" ::: "memory")
 #define wmb()		asm volatile ("sync" ::: "memory")
 #define rmb()		asm volatile ("sync" ::: "memory")
-#define CPUINFO_PROC	"cpu"
+#define CPUINFO_PROC	{"cpu"}
 #endif
 
 #ifdef __s390__
 #define mb()		asm volatile("bcr 15,0" ::: "memory")
 #define wmb()		asm volatile("bcr 15,0" ::: "memory")
 #define rmb()		asm volatile("bcr 15,0" ::: "memory")
-#define CPUINFO_PROC	"vendor_id"
+#define CPUINFO_PROC	{"vendor_id"}
 #endif
 
 #ifdef __sh__
@@ -67,14 +67,14 @@
 # define wmb()		asm volatile("" ::: "memory")
 # define rmb()		asm volatile("" ::: "memory")
 #endif
-#define CPUINFO_PROC	"cpu type"
+#define CPUINFO_PROC	{"cpu type"}
 #endif
 
 #ifdef __hppa__
 #define mb()		asm volatile("" ::: "memory")
 #define wmb()		asm volatile("" ::: "memory")
 #define rmb()		asm volatile("" ::: "memory")
-#define CPUINFO_PROC	"cpu"
+#define CPUINFO_PROC	{"cpu"}
 #endif
 
 #ifdef __sparc__
@@ -87,14 +87,14 @@
 #endif
 #define wmb()		asm volatile("":::"memory")
 #define rmb()		asm volatile("":::"memory")
-#define CPUINFO_PROC	"cpu"
+#define CPUINFO_PROC	{"cpu"}
 #endif
 
 #ifdef __alpha__
 #define mb()		asm volatile("mb" ::: "memory")
 #define wmb()		asm volatile("wmb" ::: "memory")
 #define rmb()		asm volatile("mb" ::: "memory")
-#define CPUINFO_PROC	"cpu model"
+#define CPUINFO_PROC	{"cpu model"}
 #endif
 
 #ifdef __ia64__
@@ -102,7 +102,7 @@
 #define wmb()		asm volatile ("mf" ::: "memory")
 #define rmb()		asm volatile ("mf" ::: "memory")
 #define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
-#define CPUINFO_PROC	"model name"
+#define CPUINFO_PROC	{"model name"}
 #endif
 
 #ifdef __arm__
@@ -113,7 +113,7 @@
 #define mb()		((void(*)(void))0xffff0fa0)()
 #define wmb()		((void(*)(void))0xffff0fa0)()
 #define rmb()		((void(*)(void))0xffff0fa0)()
-#define CPUINFO_PROC	"Processor"
+#define CPUINFO_PROC	{"model name", "Processor"}
 #endif
 
 #ifdef __aarch64__
@@ -133,28 +133,28 @@
 				: "memory")
 #define wmb()	mb()
 #define rmb()	mb()
-#define CPUINFO_PROC	"cpu model"
+#define CPUINFO_PROC	{"cpu model"}
 #endif
 
 #ifdef __arc__
 #define mb()		asm volatile("" ::: "memory")
 #define wmb()		asm volatile("" ::: "memory")
 #define rmb()		asm volatile("" ::: "memory")
-#define CPUINFO_PROC	"Processor"
+#define CPUINFO_PROC	{"Processor"}
 #endif
 
 #ifdef __metag__
 #define mb()		asm volatile("" ::: "memory")
 #define wmb()		asm volatile("" ::: "memory")
 #define rmb()		asm volatile("" ::: "memory")
-#define CPUINFO_PROC	"CPU"
+#define CPUINFO_PROC	{"CPU"}
 #endif
 
 #ifdef __xtensa__
 #define mb()		asm volatile("memw" ::: "memory")
 #define wmb()		asm volatile("memw" ::: "memory")
 #define rmb()		asm volatile("" ::: "memory")
-#define CPUINFO_PROC	"core ID"
+#define CPUINFO_PROC	{"core ID"}
 #endif
 
 #ifdef __tile__
@@ -162,7 +162,7 @@
 #define wmb()		asm volatile ("mf" ::: "memory")
 #define rmb()		asm volatile ("mf" ::: "memory")
 #define cpu_relax()	asm volatile ("mfspr zero, PASS" ::: "memory")
-#define CPUINFO_PROC    "model name"
+#define CPUINFO_PROC    {"model name"}
 #endif
 
 #define barrier() asm volatile ("" ::: "memory")
tools/perf/util/header.c +21 -6
index ce0de00399da..26f5b2fe5dc8 100644
@@ -579,16 +579,12 @@ static int write_version(int fd, struct perf_header *h __maybe_unused,
 	return do_write_string(fd, perf_version_string);
 }
 
-static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
-		       struct perf_evlist *evlist __maybe_unused)
+static int __write_cpudesc(int fd, const char *cpuinfo_proc)
 {
-#ifndef CPUINFO_PROC
-#define CPUINFO_PROC NULL
-#endif
 	FILE *file;
 	char *buf = NULL;
 	char *s, *p;
-	const char *search = CPUINFO_PROC;
+	const char *search = cpuinfo_proc;
 	size_t len = 0;
 	int ret = -1;
 
@@ -638,6 +634,25 @@ done:
 	return ret;
 }
 
+static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
+		       struct perf_evlist *evlist __maybe_unused)
+{
+#ifndef CPUINFO_PROC
+#define CPUINFO_PROC {"model name", }
+#endif
+	const char *cpuinfo_procs[] = CPUINFO_PROC;
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) {
+		int ret;
+		ret = __write_cpudesc(fd, cpuinfo_procs[i]);
+		if (ret >= 0)
+			return ret;
+	}
+	return -1;
+}
+
+
 static int write_nrcpus(int fd, struct perf_header *h __maybe_unused,
 			struct perf_evlist *evlist __maybe_unused)
 {
Signature · 1 line
1.9.3
author maintainer
#3 lore raw

PATCH 3/10 perf tools: Fix report -F abort for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F abort
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

---
 tools/perf/util/sort.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
tools/perf/util/sort.c +11 -3
index 4906cd81cb56..82241fe54e4b 100644
@@ -989,6 +989,9 @@ struct sort_entry sort_mem_dcacheline = {
 static int64_t
 sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
 {
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
 	return left->branch_info->flags.abort !=
 		right->branch_info->flags.abort;
 }
@@ -996,10 +999,15 @@ sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
 static int hist_entry__abort_snprintf(struct hist_entry *he, char *bf,
 				    size_t size, unsigned int width)
 {
-	static const char *out = ".";
+	static const char *out = "N/A";
+
+	if (he->branch_info) {
+		if (he->branch_info->flags.abort)
+			out = "A";
+		else
+			out = ".";
+	}
 
-	if (he->branch_info->flags.abort)
-		out = "A";
 	return repsep_snprintf(bf, size, "%-*s", width, out);
 }
 
Signature · 1 line
1.9.3
author maintainer
#4 lore raw

PATCH 4/10 perf tools: Fix report -F in_tx for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F in_tx
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

---
 tools/perf/util/sort.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
tools/perf/util/sort.c +10 -3
index 82241fe54e4b..9bcdb57076b8 100644
@@ -1021,6 +1021,9 @@ struct sort_entry sort_abort = {
 static int64_t
 sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
 {
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
 	return left->branch_info->flags.in_tx !=
 		right->branch_info->flags.in_tx;
 }
@@ -1028,10 +1031,14 @@ sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
 static int hist_entry__in_tx_snprintf(struct hist_entry *he, char *bf,
 				    size_t size, unsigned int width)
 {
-	static const char *out = ".";
+	static const char *out = "N/A";
 
-	if (he->branch_info->flags.in_tx)
-		out = "T";
+	if (he->branch_info) {
+		if (he->branch_info->flags.in_tx)
+			out = "T";
+		else
+			out = ".";
+	}
 
 	return repsep_snprintf(bf, size, "%-*s", width, out);
 }
Signature · 1 line
1.9.3
author maintainer
#5 lore raw

PATCH 5/10 perf tools: Fix report -F mispredict for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F mispredict
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

---
 tools/perf/util/sort.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
tools/perf/util/sort.c +12 -8
index 9bcdb57076b8..0c68af83e7dd 100644
@@ -471,11 +471,13 @@ struct sort_entry sort_sym_to = {
 static int64_t
 sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	const unsigned char mp = left->branch_info->flags.mispred !=
-					right->branch_info->flags.mispred;
-	const unsigned char p = left->branch_info->flags.predicted !=
-					right->branch_info->flags.predicted;
+	unsigned char mp, p;
 
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
+	mp = left->branch_info->flags.mispred != right->branch_info->flags.mispred;
+	p  = left->branch_info->flags.predicted != right->branch_info->flags.predicted;
 	return mp || p;
 }
 
@@ -483,10 +485,12 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
 				    size_t size, unsigned int width){
 	static const char *out = "N/A";
 
-	if (he->branch_info->flags.predicted)
-		out = "N";
-	else if (he->branch_info->flags.mispred)
-		out = "Y";
+	if (he->branch_info) {
+		if (he->branch_info->flags.predicted)
+			out = "N";
+		else if (he->branch_info->flags.mispred)
+			out = "Y";
+	}
 
 	return repsep_snprintf(bf, size, "%-*.*s", width, width, out);
 }
Signature · 1 line
1.9.3
author maintainer
#6 lore raw

PATCH 6/10 perf tools: Fix report -F symbol_to for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F symbol_to
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

---
 tools/perf/util/sort.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
tools/perf/util/sort.c +14 -5
index 0c68af83e7dd..57047c0a247c 100644
@@ -413,8 +413,13 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
 static int64_t
 sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	struct addr_map_symbol *to_l = &left->branch_info->to;
-	struct addr_map_symbol *to_r = &right->branch_info->to;
+	struct addr_map_symbol *to_l, *to_r;
+
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
+	to_l = &left->branch_info->to;
+	to_r = &right->branch_info->to;
 
 	if (!to_l->sym && !to_r->sym)
 		return _sort__addr_cmp(to_l->addr, to_r->addr);
@@ -434,10 +439,14 @@ static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf,
 static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf,
 				       size_t size, unsigned int width)
 {
-	struct addr_map_symbol *to = &he->branch_info->to;
-	return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
-					 he->level, bf, size, width);
+	if (he->branch_info) {
+		struct addr_map_symbol *to = &he->branch_info->to;
+
+		return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
+						 he->level, bf, size, width);
+	}
 
+	return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
 }
 
 struct sort_entry sort_dso_from = {
Signature · 1 line
1.9.3
author maintainer
#7 lore raw

PATCH 7/10 perf tools: Fix report -F symbol_from for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F symbol_from
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

---
 tools/perf/util/sort.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
tools/perf/util/sort.c +13 -3
index 57047c0a247c..fc4ff2a96616 100644
@@ -404,6 +404,12 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
 	struct addr_map_symbol *from_l = &left->branch_info->from;
 	struct addr_map_symbol *from_r = &right->branch_info->from;
 
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
+	from_l = &left->branch_info->from;
+	from_r = &right->branch_info->from;
+
 	if (!from_l->sym && !from_r->sym)
 		return _sort__addr_cmp(from_l->addr, from_r->addr);
 
@@ -430,10 +436,14 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
 static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf,
 					 size_t size, unsigned int width)
 {
-	struct addr_map_symbol *from = &he->branch_info->from;
-	return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
-					 he->level, bf, size, width);
+	if (he->branch_info) {
+		struct addr_map_symbol *from = &he->branch_info->from;
 
+		return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
+						 he->level, bf, size, width);
+	}
+
+	return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
 }
 
 static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf,
Signature · 1 line
1.9.3
author maintainer
#8 lore raw

PATCH 8/10 perf tools: Fix report -F dso_to for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F dso_to
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

---
 tools/perf/util/sort.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/sort.c +8 -2
index fc4ff2a96616..7a9054a23c36 100644
@@ -387,6 +387,9 @@ static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf,
 static int64_t
 sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
 {
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
 	return _sort__dso_cmp(left->branch_info->to.map,
 			      right->branch_info->to.map);
 }
@@ -394,8 +397,11 @@ sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
 static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf,
 				       size_t size, unsigned int width)
 {
-	return _hist_entry__dso_snprintf(he->branch_info->to.map,
-					 bf, size, width);
+	if (he->branch_info)
+		return _hist_entry__dso_snprintf(he->branch_info->to.map,
+						 bf, size, width);
+	else
+		return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
 }
 
 static int64_t
Signature · 1 line
1.9.3
author maintainer
#9 lore raw

PATCH 9/10 perf tools: Fix report -F dso_from for data without branch info

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

The branch field sorting code assumes hist_entry::branch_info is allocated, which is wrong and following perf session ends up with report segfault.

  $ perf record ls
  $ perf report -F dso_from
  perf: Segmentation fault

Checking that hist_entry::branch_info is valid and display "N/A" string in snprint callback if it's not.

Cc Andi Kleen <[email protected]>
Cc Corey Ashford <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/perf/util/sort.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/sort.c +8 -2
index 7a9054a23c36..9402885a77f3 100644
@@ -373,6 +373,9 @@ struct sort_entry sort_cpu = {
 static int64_t
 sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
 {
+	if (!left->branch_info || !right->branch_info)
+		return cmp_null(left->branch_info, right->branch_info);
+
 	return _sort__dso_cmp(left->branch_info->from.map,
 			      right->branch_info->from.map);
 }
@@ -380,8 +383,11 @@ sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
 static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf,
 				    size_t size, unsigned int width)
 {
-	return _hist_entry__dso_snprintf(he->branch_info->from.map,
-					 bf, size, width);
+	if (he->branch_info)
+		return _hist_entry__dso_snprintf(he->branch_info->from.map,
+						 bf, size, width);
+	else
+		return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
 }
 
 static int64_t
Signature · 1 line
1.9.3
author maintainer
#10 lore raw

PATCH 10/10 perf probe: Trivial typo fix for --demangle

In reply to Arnaldo Carvalho de Melo

From: Masami Hiramatsu <[email protected]>

Replace "Disable" with "Enable", since --demangle option enables symbol demangling, not disable it.

perf probe has --demangle and --no-demangle options, but the command-line help (--help) shows only --demangle option. So it should explain about --demangle.

---
 tools/perf/builtin-probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-probe.c +1 -1
index 04412b4770a2..7af26acf06d9 100644
@@ -375,7 +375,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_CALLBACK('x', "exec", NULL, "executable|path",
 			"target executable name or path", opt_set_target),
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
-		    "Disable symbol demangling"),
+		    "Enable symbol demangling"),
 	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
 		    "Enable kernel symbol demangling"),
 	OPT_END()
Signature · 1 line
1.9.3
#11 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 55 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit 1776b10627e486dd431fe72d8d47e5a865cf65d1:

perf/x86/intel: Revert incomplete and undocumented Broadwell client support (2014-10-29 11:07:58 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo

for you to fetch changes up to 4cdcc33db2f0455f297b4e14e434ba311ec5ca06:

perf probe: Trivial typo fix for --demangle (2014-10-29 10:30:18 -0200)

----------------------------------------------------------------
perf/urgent fixes:

User visible:

* Fix report -F (abort, in_tx, mispredict, etc) segfaults for sample.data files without branch info (Jiri Olsa)

* Add patch that should have went in a previous patchkit to use global cache provided by libunwind (Namhyung Kim)

* Make CPUINFO_PROC an array to support different kernels, problem detected when the information reported via /proc/cpuinfo changed on ARM (Wang Nan)

* 'perf probe' --demangle typo fix and a new --quiet option (Masami Hiramatsu)

----------------------------------------------------------------
Jiri Olsa (7):
perf tools: Fix report -F abort for data without branch info perf tools: Fix report -F in_tx for data without branch info perf tools: Fix report -F mispredict for data without branch info perf tools: Fix report -F symbol_to for data without branch info perf tools: Fix report -F symbol_from for data without branch info perf tools: Fix report -F dso_to for data without branch info perf tools: Fix report -F dso_from for data without branch info

Masami Hiramatsu (1):
perf probe: Trivial typo fix for --demangle

Namhyung Kim (1):
perf callchain: Use global caching provided by libunwind

Wang Nan (1):
perf tools: Make CPUINFO_PROC an array to support different kernel versions

Quoted 8 lines
 tools/perf/builtin-probe.c         |   2 +-
 tools/perf/perf-sys.h              |  30 +++++------
 tools/perf/util/header.c           |  27 +++++++---
 tools/perf/util/sort.c             | 102 +++++++++++++++++++++++++++----------
 tools/perf/util/thread.c           |   3 ++
 tools/perf/util/unwind-libunwind.c |  12 +++++
 tools/perf/util/unwind.h           |   3 ++
 7 files changed, 131 insertions(+), 48 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo