Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1402044 > unrolled thread

[GIT PULL 00/12] perf/core improvements and fixes

Started byArnaldo Carvalho de Melo <acme@kernel.org>
First post2016-05-17 04:50 +0200
Last post2016-05-20 08:30 +0200
Articles 10 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [GIT PULL 00/12] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 10/12] perf core: Add perf_callchain_store_context() helper Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 06/12] perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 01/12] perf stat: Avoid fractional digits for integer scales Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 09/12] perf core: Add a 'nr' field to perf_event_callchain_context Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 12/12] perf tools: Separate accounting of contexts and real addresses in a stack trace Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 03/12] perf stat: Fix indentation of stalled backend cycle Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 02/12] perf symbols: Store vdso buildid unconditionally Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    [PATCH 05/12] perf stat: Use cpu-clock event for cpu targets Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-17 04:50 +0200
    Re: [GIT PULL 00/12] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-05-20 08:30 +0200

#1402044 — [GIT PULL 00/12] perf/core improvements and fixes

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[GIT PULL 00/12] perf/core improvements and fixes
Message-ID<rzDf3-77f-3@gated-at.bofh.it>
From: Arnaldo Carvalho de Melo <acme@redhat.com>

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit 3f56e687a138481894a1088d5aa7d41951bdb020:

  perf/core: Disable the event on a truncated AUX record (2016-05-12 10:14:55 +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-20160516

for you to fetch changes up to a29d5c9b8167dbc21a7ca8c0302e3799f9063b4e:

  perf tools: Separate accounting of contexts and real addresses in a stack trace (2016-05-16 23:11:54 -0300)

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

User visible:

- Honour the kernel.perf_event_max_stack knob more precisely by not counting
  PERF_CONTEXT_{KERNEL,USER} when deciding when to stop adding entries to
  the perf_sample->ip_callchain[] array (Arnaldo Carvalho de Melo)

- Fix identation of 'stalled-backend-cycles' in 'perf stat' (Namhyung Kim)

- Update runtime using 'cpu-clock' event in 'perf stat' (Namhyung Kim)

- Use 'cpu-clock' for cpu targets in 'perf stat' (Namhyung Kim)

- Avoid fractional digits for integer scales in 'perf stat' (Andi Kleen)

- Store vdso buildid unconditionally, as it appears in callchains and
  we're not checking those when creating the build-id table, so we
  end up not being able to resolve VDSO symbols when doing analysis
  on a different machine than the one where recording was done, possibly
  of a different arch even (arm -> x86_64) (He Kuang)

Infrastructure:

- Generalize max_stack sysctl handler, will be used for configuring
  multiple kernel knobs related to callchains (Arnaldo Carvalho de Melo)

Cleanups:

- Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE, to stop using
  open coded strings (Masami Hiramatsu)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Andi Kleen (1):
      perf stat: Avoid fractional digits for integer scales

Arnaldo Carvalho de Melo (6):
      perf core: Generalize max_stack sysctl handler
      perf core: Pass max stack as a perf_callchain_entry context
      perf core: Add a 'nr' field to perf_event_callchain_context
      perf core: Add perf_callchain_store_context() helper
      perf core: Separate accounting of contexts and real addresses in a stack trace
      perf tools: Separate accounting of contexts and real addresses in a stack trace

He Kuang (1):
      perf symbols: Store vdso buildid unconditionally

Masami Hiramatsu (1):
      perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE

Namhyung Kim (3):
      perf stat: Fix indentation of stalled backend cycle
      perf stat: Update runtime using cpu-clock event
      perf stat: Use cpu-clock event for cpu targets

 Documentation/sysctl/kernel.txt    | 14 ++++++++++++++
 arch/arc/kernel/perf_event.c       |  6 +++---
 arch/arm/kernel/perf_callchain.c   | 10 +++++-----
 arch/arm64/kernel/perf_callchain.c | 14 +++++++-------
 arch/metag/kernel/perf_callchain.c | 10 +++++-----
 arch/mips/kernel/perf_event.c      | 12 ++++++------
 arch/powerpc/perf/callchain.c      | 20 ++++++++++----------
 arch/s390/kernel/perf_event.c      |  4 ++--
 arch/sh/kernel/perf_callchain.c    |  4 ++--
 arch/sparc/kernel/perf_event.c     | 14 +++++++-------
 arch/tile/kernel/perf_event.c      |  6 +++---
 arch/x86/events/core.c             | 14 +++++++-------
 arch/xtensa/kernel/perf_event.c    | 10 +++++-----
 include/linux/perf_event.h         | 34 +++++++++++++++++++++++++++++-----
 include/uapi/linux/perf_event.h    |  1 +
 kernel/bpf/stackmap.c              |  3 ++-
 kernel/events/callchain.c          | 36 ++++++++++++++++++++++++------------
 kernel/sysctl.c                    | 11 ++++++++++-
 tools/perf/builtin-buildid-cache.c |  8 ++++----
 tools/perf/builtin-stat.c          | 22 +++++++++++++---------
 tools/perf/perf.c                  |  3 +++
 tools/perf/util/annotate.c         |  2 +-
 tools/perf/util/build-id.c         |  2 +-
 tools/perf/util/dso.c              |  3 ++-
 tools/perf/util/machine.c          | 28 ++++++++++++++++++----------
 tools/perf/util/stat-shadow.c      |  8 +++++---
 tools/perf/util/symbol.c           | 10 +++++-----
 tools/perf/util/symbol.h           |  3 +++
 tools/perf/util/util.c             |  3 ++-
 tools/perf/util/util.h             |  3 ++-
 30 files changed, 201 insertions(+), 117 deletions(-)

[toc] | [next] | [standalone]


#1402045 — [PATCH 10/12] perf core: Add perf_callchain_store_context() helper

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 10/12] perf core: Add perf_callchain_store_context() helper
Message-ID<rzDf4-77f-9@gated-at.bofh.it>
In reply to#1402044
From: Arnaldo Carvalho de Melo <acme@redhat.com>

We need have different helpers to account how many contexts we have in
the sample and for real addresses, so do it now as a prep patch, to
ease review.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-q964tnyuqrxw5gld18vizs3c@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 arch/powerpc/perf/callchain.c | 6 +++---
 include/linux/perf_event.h    | 2 ++
 kernel/events/callchain.c     | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
index f68f213dc36c..f62597dbd757 100644
--- a/arch/powerpc/perf/callchain.c
+++ b/arch/powerpc/perf/callchain.c
@@ -76,7 +76,7 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
 			next_ip = regs->nip;
 			lr = regs->link;
 			level = 0;
-			perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
+			perf_callchain_store_context(entry, PERF_CONTEXT_KERNEL);
 
 		} else {
 			if (level == 0)
@@ -274,7 +274,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
 			    read_user_stack_64(&uregs[PT_R1], &sp))
 				return;
 			level = 0;
-			perf_callchain_store(entry, PERF_CONTEXT_USER);
+			perf_callchain_store_context(entry, PERF_CONTEXT_USER);
 			perf_callchain_store(entry, next_ip);
 			continue;
 		}
@@ -473,7 +473,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
 			    read_user_stack_32(&uregs[PT_R1], &sp))
 				return;
 			level = 0;
-			perf_callchain_store(entry, PERF_CONTEXT_USER);
+			perf_callchain_store_context(entry, PERF_CONTEXT_USER);
 			perf_callchain_store(entry, next_ip);
 			continue;
 		}
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 3803bb1a862b..2024b14cc2b1 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1079,6 +1079,8 @@ extern void put_callchain_buffers(void);
 
 extern int sysctl_perf_event_max_stack;
 
+#define perf_callchain_store_context(ctx, context) perf_callchain_store(ctx, context)
+
 static inline int perf_callchain_store(struct perf_callchain_entry_ctx *ctx, u64 ip)
 {
 	if (ctx->nr < ctx->max_stack) {
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 8774ff86debb..ca645736a983 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -200,7 +200,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 
 	if (kernel && !user_mode(regs)) {
 		if (add_mark)
-			perf_callchain_store(&ctx, PERF_CONTEXT_KERNEL);
+			perf_callchain_store_context(&ctx, PERF_CONTEXT_KERNEL);
 		perf_callchain_kernel(&ctx, regs);
 	}
 
@@ -217,7 +217,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 				goto exit_put;
 
 			if (add_mark)
-				perf_callchain_store(&ctx, PERF_CONTEXT_USER);
+				perf_callchain_store_context(&ctx, PERF_CONTEXT_USER);
 			perf_callchain_user(&ctx, regs);
 		}
 	}
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402046 — [PATCH 06/12] perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 06/12] perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE
Message-ID<rzDf4-77f-13@gated-at.bofh.it>
In reply to#1402044
From: Masami Hiramatsu <mhiramat@kernel.org>

Instead of using a raw string, use DSO__NAME_KALLSYMS and
DSO__NAME_KCORE macros for kallsyms and kcore.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160515031935.4017.50971.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-buildid-cache.c |  8 ++++----
 tools/perf/util/annotate.c         |  2 +-
 tools/perf/util/machine.c          |  2 +-
 tools/perf/util/symbol.c           | 10 +++++-----
 tools/perf/util/symbol.h           |  3 +++
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index 632efc6b79a0..d75bded21fe0 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -119,8 +119,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
 	if (build_id_cache__kcore_buildid(from_dir, sbuildid) < 0)
 		return -1;
 
-	scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s",
-		  buildid_dir, sbuildid);
+	scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s",
+		  buildid_dir, DSO__NAME_KCORE, sbuildid);
 
 	if (!force &&
 	    !build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) {
@@ -131,8 +131,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
 	if (build_id_cache__kcore_dir(dir, sizeof(dir)))
 		return -1;
 
-	scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s",
-		  buildid_dir, sbuildid, dir);
+	scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s/%s",
+		  buildid_dir, DSO__NAME_KCORE, sbuildid, dir);
 
 	if (mkdir_p(to_dir, 0755))
 		return -1;
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 4db73d5a0dbc..b811924e5e1b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1122,7 +1122,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
 	} else if (dso__is_kcore(dso)) {
 		goto fallback;
 	} else if (readlink(symfs_filename, command, sizeof(command)) < 0 ||
-		   strstr(command, "[kernel.kallsyms]") ||
+		   strstr(command, DSO__NAME_KALLSYMS) ||
 		   access(symfs_filename, R_OK)) {
 		free(filename);
 fallback:
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 639a2903065e..18dd96bdde05 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -709,7 +709,7 @@ static struct dso *machine__get_kernel(struct machine *machine)
 	if (machine__is_host(machine)) {
 		vmlinux_name = symbol_conf.vmlinux_name;
 		if (!vmlinux_name)
-			vmlinux_name = "[kernel.kallsyms]";
+			vmlinux_name = DSO__NAME_KALLSYMS;
 
 		kernel = machine__findnew_kernel(machine, vmlinux_name,
 						 "[kernel]", DSO_TYPE_KERNEL);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 7fb33304fb4e..2252b545ff43 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1662,8 +1662,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 
 	build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
 
-	scnprintf(path, sizeof(path), "%s/[kernel.kcore]/%s", buildid_dir,
-		  sbuild_id);
+	scnprintf(path, sizeof(path), "%s/%s/%s", buildid_dir,
+		  DSO__NAME_KCORE, sbuild_id);
 
 	/* Use /proc/kallsyms if possible */
 	if (is_host) {
@@ -1699,8 +1699,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 	if (!find_matching_kcore(map, path, sizeof(path)))
 		return strdup(path);
 
-	scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s",
-		  buildid_dir, sbuild_id);
+	scnprintf(path, sizeof(path), "%s/%s/%s",
+		  buildid_dir, DSO__NAME_KALLSYMS, sbuild_id);
 
 	if (access(path, F_OK)) {
 		pr_err("No kallsyms or vmlinux with build-id %s was found\n",
@@ -1769,7 +1769,7 @@ do_kallsyms:
 
 	if (err > 0 && !dso__is_kcore(dso)) {
 		dso->binary_type = DSO_BINARY_TYPE__KALLSYMS;
-		dso__set_long_name(dso, "[kernel.kallsyms]", false);
+		dso__set_long_name(dso, DSO__NAME_KALLSYMS, false);
 		map__fixup_start(map);
 		map__fixup_end(map);
 	}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 2b5e4ed76fcb..25f2fd672c2e 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -44,6 +44,9 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
 #define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
 #endif
 
+#define DSO__NAME_KALLSYMS	"[kernel.kallsyms]"
+#define DSO__NAME_KCORE		"[kernel.kcore]"
+
 /** struct symbol - symtab entry
  *
  * @ignore - resolvable but tools ignore it (e.g. idle routines)
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402047 — [PATCH 01/12] perf stat: Avoid fractional digits for integer scales

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 01/12] perf stat: Avoid fractional digits for integer scales
Message-ID<rzDf4-77f-11@gated-at.bofh.it>
In reply to#1402044
From: Andi Kleen <ak@linux.intel.com>

When the scaling factor is a full integer don't display fractional
digits. This avoids unnecessary .00 output for topdown metrics with
scale factors.

v2: Remove redundant check.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1462489447-31832-7-git-send-email-andi@firstfloor.org
[ Rename 'round' to 'stat_round' as 'round' is defined in math.h,
  included by this patch, and this breaks the build on ubuntu 12.04 ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 5645a8361de6..16a923c1633b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -66,6 +66,7 @@
 #include <stdlib.h>
 #include <sys/prctl.h>
 #include <locale.h>
+#include <math.h>
 
 #define DEFAULT_SEPARATOR	" "
 #define CNTR_NOT_SUPPORTED	"<not supported>"
@@ -986,12 +987,12 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
 	const char *fmt;
 
 	if (csv_output) {
-		fmt = sc != 1.0 ?  "%.2f%s" : "%.0f%s";
+		fmt = floor(sc) != sc ?  "%.2f%s" : "%.0f%s";
 	} else {
 		if (big_num)
-			fmt = sc != 1.0 ? "%'18.2f%s" : "%'18.0f%s";
+			fmt = floor(sc) != sc ? "%'18.2f%s" : "%'18.0f%s";
 		else
-			fmt = sc != 1.0 ? "%18.2f%s" : "%18.0f%s";
+			fmt = floor(sc) != sc ? "%18.2f%s" : "%18.0f%s";
 	}
 
 	aggr_printout(evsel, id, nr);
@@ -1995,7 +1996,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
 				    union perf_event *event,
 				    struct perf_session *session)
 {
-	struct stat_round_event *round = &event->stat_round;
+	struct stat_round_event *stat_round = &event->stat_round;
 	struct perf_evsel *counter;
 	struct timespec tsh, *ts = NULL;
 	const char **argv = session->header.env.cmdline_argv;
@@ -2004,12 +2005,12 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
 	evlist__for_each(evsel_list, counter)
 		perf_stat_process_counter(&stat_config, counter);
 
-	if (round->type == PERF_STAT_ROUND_TYPE__FINAL)
-		update_stats(&walltime_nsecs_stats, round->time);
+	if (stat_round->type == PERF_STAT_ROUND_TYPE__FINAL)
+		update_stats(&walltime_nsecs_stats, stat_round->time);
 
-	if (stat_config.interval && round->time) {
-		tsh.tv_sec  = round->time / NSECS_PER_SEC;
-		tsh.tv_nsec = round->time % NSECS_PER_SEC;
+	if (stat_config.interval && stat_round->time) {
+		tsh.tv_sec  = stat_round->time / NSECS_PER_SEC;
+		tsh.tv_nsec = stat_round->time % NSECS_PER_SEC;
 		ts = &tsh;
 	}
 
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402048 — [PATCH 09/12] perf core: Add a 'nr' field to perf_event_callchain_context

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 09/12] perf core: Add a 'nr' field to perf_event_callchain_context
Message-ID<rzDf4-77f-15@gated-at.bofh.it>
In reply to#1402044
From: Arnaldo Carvalho de Melo <acme@redhat.com>

We will use it to count how many addresses are in the entry->ip[] array,
excluding PERF_CONTEXT_{KERNEL,USER,etc} entries, so that we can really
return the number of entries specified by the user via the relevant
sysctl, kernel.perf_event_max_contexts, or via the per event
perf_event_attr.sample_max_stack knob.

This way we keep the perf_sample->ip_callchain->nr meaning, that is the
number of entries, be it real addresses or PERF_CONTEXT_ entries, while
honouring the max_stack knobs, i.e. the end result will be max_stack
entries if we have at least that many entries in a given stack trace.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-s8teto51tdqvlfhefndtat9r@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 arch/arm/kernel/perf_callchain.c   | 2 +-
 arch/arm64/kernel/perf_callchain.c | 4 ++--
 arch/metag/kernel/perf_callchain.c | 2 +-
 arch/mips/kernel/perf_event.c      | 4 ++--
 arch/powerpc/perf/callchain.c      | 4 ++--
 arch/sparc/kernel/perf_event.c     | 6 +++---
 arch/x86/events/core.c             | 4 ++--
 include/linux/perf_event.h         | 6 ++++--
 kernel/events/callchain.c          | 3 +--
 9 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/arch/arm/kernel/perf_callchain.c b/arch/arm/kernel/perf_callchain.c
index bc552e813e7b..22bf1f64d99a 100644
--- a/arch/arm/kernel/perf_callchain.c
+++ b/arch/arm/kernel/perf_callchain.c
@@ -75,7 +75,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
 
 	tail = (struct frame_tail __user *)regs->ARM_fp - 1;
 
-	while ((entry->entry->nr < entry->max_stack) &&
+	while ((entry->nr < entry->max_stack) &&
 	       tail && !((unsigned long)tail & 0x3))
 		tail = user_backtrace(tail, entry);
 }
diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c
index 0d60150057cf..713ca824f266 100644
--- a/arch/arm64/kernel/perf_callchain.c
+++ b/arch/arm64/kernel/perf_callchain.c
@@ -122,7 +122,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
 
 		tail = (struct frame_tail __user *)regs->regs[29];
 
-		while (entry->entry->nr < entry->max_stack &&
+		while (entry->nr < entry->max_stack &&
 		       tail && !((unsigned long)tail & 0xf))
 			tail = user_backtrace(tail, entry);
 	} else {
@@ -132,7 +132,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
 
 		tail = (struct compat_frame_tail __user *)regs->compat_fp - 1;
 
-		while ((entry->entry->nr < entry->max_stack) &&
+		while ((entry->nr < entry->max_stack) &&
 			tail && !((unsigned long)tail & 0x3))
 			tail = compat_user_backtrace(tail, entry);
 #endif
diff --git a/arch/metag/kernel/perf_callchain.c b/arch/metag/kernel/perf_callchain.c
index b3261a98b15b..3e8e048040df 100644
--- a/arch/metag/kernel/perf_callchain.c
+++ b/arch/metag/kernel/perf_callchain.c
@@ -65,7 +65,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
 
 	--frame;
 
-	while ((entry->entry->nr < entry->max_stack) && frame)
+	while ((entry->nr < entry->max_stack) && frame)
 		frame = user_backtrace(frame, entry);
 }
 
diff --git a/arch/mips/kernel/perf_event.c b/arch/mips/kernel/perf_event.c
index 22395c7d7030..d64056e0bb56 100644
--- a/arch/mips/kernel/perf_event.c
+++ b/arch/mips/kernel/perf_event.c
@@ -35,7 +35,7 @@ static void save_raw_perf_callchain(struct perf_callchain_entry_ctx *entry,
 		addr = *sp++;
 		if (__kernel_text_address(addr)) {
 			perf_callchain_store(entry, addr);
-			if (entry->entry->nr >= entry->max_stack)
+			if (entry->nr >= entry->max_stack)
 				break;
 		}
 	}
@@ -59,7 +59,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
 	}
 	do {
 		perf_callchain_store(entry, pc);
-		if (entry->entry->nr >= entry->max_stack)
+		if (entry->nr >= entry->max_stack)
 			break;
 		pc = unwind_stack(current, &sp, pc, &ra);
 	} while (pc);
diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
index c9260c1dfdbc..f68f213dc36c 100644
--- a/arch/powerpc/perf/callchain.c
+++ b/arch/powerpc/perf/callchain.c
@@ -247,7 +247,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
 	sp = regs->gpr[1];
 	perf_callchain_store(entry, next_ip);
 
-	while (entry->entry->nr < entry->max_stack) {
+	while (entry->nr < entry->max_stack) {
 		fp = (unsigned long __user *) sp;
 		if (!valid_user_sp(sp, 1) || read_user_stack_64(fp, &next_sp))
 			return;
@@ -453,7 +453,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
 	sp = regs->gpr[1];
 	perf_callchain_store(entry, next_ip);
 
-	while (entry->entry->nr < entry->max_stack) {
+	while (entry->nr < entry->max_stack) {
 		fp = (unsigned int __user *) (unsigned long) sp;
 		if (!valid_user_sp(sp, 0) || read_user_stack_32(fp, &next_sp))
 			return;
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index bcc5376db74b..710f3278d448 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -1756,7 +1756,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
 			}
 		}
 #endif
-	} while (entry->entry->nr < entry->max_stack);
+	} while (entry->nr < entry->max_stack);
 }
 
 static inline int
@@ -1790,7 +1790,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
 		pc = sf.callers_pc;
 		ufp = (unsigned long)sf.fp + STACK_BIAS;
 		perf_callchain_store(entry, pc);
-	} while (entry->entry->nr < entry->max_stack);
+	} while (entry->nr < entry->max_stack);
 }
 
 static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
@@ -1822,7 +1822,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
 			ufp = (unsigned long)sf.fp;
 		}
 		perf_callchain_store(entry, pc);
-	} while (entry->entry->nr < entry->max_stack);
+	} while (entry->nr < entry->max_stack);
 }
 
 void
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 07f2b01cfb72..5de96a18cd9c 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2283,7 +2283,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent
 
 	fp = compat_ptr(ss_base + regs->bp);
 	pagefault_disable();
-	while (entry->entry->nr < entry->max_stack) {
+	while (entry->nr < entry->max_stack) {
 		unsigned long bytes;
 		frame.next_frame     = 0;
 		frame.return_address = 0;
@@ -2343,7 +2343,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
 		return;
 
 	pagefault_disable();
-	while (entry->entry->nr < entry->max_stack) {
+	while (entry->nr < entry->max_stack) {
 		unsigned long bytes;
 		frame.next_frame	     = NULL;
 		frame.return_address = 0;
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index dbd18246b36e..3803bb1a862b 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -64,6 +64,7 @@ struct perf_callchain_entry {
 struct perf_callchain_entry_ctx {
 	struct perf_callchain_entry *entry;
 	u32			    max_stack;
+	u32			    nr;
 };
 
 struct perf_raw_record {
@@ -1080,9 +1081,10 @@ extern int sysctl_perf_event_max_stack;
 
 static inline int perf_callchain_store(struct perf_callchain_entry_ctx *ctx, u64 ip)
 {
-	struct perf_callchain_entry *entry = ctx->entry;
-	if (entry->nr < ctx->max_stack) {
+	if (ctx->nr < ctx->max_stack) {
+		struct perf_callchain_entry *entry = ctx->entry;
 		entry->ip[entry->nr++] = ip;
+		++ctx->nr;
 		return 0;
 	} else {
 		return -1; /* no more room, stop walking the stack */
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index af95ad92893a..8774ff86debb 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -196,8 +196,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 
 	ctx.entry     = entry;
 	ctx.max_stack = max_stack;
-
-	entry->nr = init_nr;
+	ctx.nr	      = entry->nr = init_nr;
 
 	if (kernel && !user_mode(regs)) {
 		if (add_mark)
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402049 — [PATCH 12/12] perf tools: Separate accounting of contexts and real addresses in a stack trace

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 12/12] perf tools: Separate accounting of contexts and real addresses in a stack trace
Message-ID<rzDf4-77f-17@gated-at.bofh.it>
In reply to#1402044
From: Arnaldo Carvalho de Melo <acme@redhat.com>

The perf_sample->ip_callchain->nr value includes all the entries in the
ip_callchain->ip[] array, real addresses and PERF_CONTEXT_{KERNEL,USER,etc},
while what the user expects is that what is in the kernel.perf_event_max_stack
sysctl or in the upcoming per event perf_event_attr.sample_max_stack knob be
honoured in terms of IP addresses in the stack trace.

So match the kernel support and validate chain->nr taking into account
both kernel.perf_event_max_stack and kernel.perf_event_max_contexts_per_stack.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/n/tip-mgx0jpzfdq4uq4abfa40byu0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf.c         |  3 +++
 tools/perf/util/machine.c | 26 +++++++++++++++++---------
 tools/perf/util/util.c    |  3 ++-
 tools/perf/util/util.h    |  3 ++-
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 797000842d40..15982cee5ef3 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -549,6 +549,9 @@ int main(int argc, const char **argv)
 	if (sysctl__read_int("kernel/perf_event_max_stack", &value) == 0)
 		sysctl_perf_event_max_stack = value;
 
+	if (sysctl__read_int("kernel/perf_event_max_contexts_per_stack", &value) == 0)
+		sysctl_perf_event_max_contexts_per_stack = value;
+
 	cmd = extract_argv0_path(argv[0]);
 	if (!cmd)
 		cmd = "perf-help";
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 18dd96bdde05..7ba9fadb68af 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1811,9 +1811,9 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 {
 	struct branch_stack *branch = sample->branch_stack;
 	struct ip_callchain *chain = sample->callchain;
-	int chain_nr = min(max_stack, (int)chain->nr);
+	int chain_nr = chain->nr;
 	u8 cpumode = PERF_RECORD_MISC_USER;
-	int i, j, err;
+	int i, j, err, nr_entries, nr_contexts;
 	int skip_idx = -1;
 	int first_call = 0;
 
@@ -1828,7 +1828,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	 * Based on DWARF debug information, some architectures skip
 	 * a callchain entry saved by the kernel.
 	 */
-	if (chain->nr < sysctl_perf_event_max_stack)
+	if (chain_nr < sysctl_perf_event_max_stack)
 		skip_idx = arch_skip_callchain_idx(thread, chain);
 
 	/*
@@ -1889,12 +1889,8 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	}
 
 check_calls:
-	if (chain->nr > sysctl_perf_event_max_stack && (int)chain->nr > max_stack) {
-		pr_warning("corrupted callchain. skipping...\n");
-		return 0;
-	}
-
-	for (i = first_call; i < chain_nr; i++) {
+	for (i = first_call, nr_entries = 0, nr_contexts = 0;
+	     i < chain_nr && nr_entries < max_stack; i++) {
 		u64 ip;
 
 		if (callchain_param.order == ORDER_CALLEE)
@@ -1908,6 +1904,14 @@ check_calls:
 #endif
 		ip = chain->ips[j];
 
+		if (ip >= PERF_CONTEXT_MAX) {
+			if (++nr_contexts > sysctl_perf_event_max_contexts_per_stack)
+				goto out_corrupted_callchain;
+		} else {
+			if (++nr_entries > sysctl_perf_event_max_stack)
+				goto out_corrupted_callchain;
+		}
+
 		err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip);
 
 		if (err)
@@ -1915,6 +1919,10 @@ check_calls:
 	}
 
 	return 0;
+
+out_corrupted_callchain:
+	pr_warning("corrupted callchain. skipping...\n");
+	return 0;
 }
 
 static int unwind_entry(struct unwind_entry *entry, void *arg)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index eab077ad6ca9..23504ad5d6dd 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -33,7 +33,8 @@ struct callchain_param	callchain_param = {
 unsigned int page_size;
 int cacheline_size;
 
-unsigned int sysctl_perf_event_max_stack = PERF_MAX_STACK_DEPTH;
+int sysctl_perf_event_max_stack = PERF_MAX_STACK_DEPTH;
+int sysctl_perf_event_max_contexts_per_stack = PERF_MAX_CONTEXTS_PER_STACK;
 
 bool test_attr__enabled;
 
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 7651633a8dc7..1e8c3167b9fb 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -261,7 +261,8 @@ void sighandler_dump_stack(int sig);
 
 extern unsigned int page_size;
 extern int cacheline_size;
-extern unsigned int sysctl_perf_event_max_stack;
+extern int sysctl_perf_event_max_stack;
+extern int sysctl_perf_event_max_contexts_per_stack;
 
 struct parse_tag {
 	char tag;
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402051 — [PATCH 03/12] perf stat: Fix indentation of stalled backend cycle

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 03/12] perf stat: Fix indentation of stalled backend cycle
Message-ID<rzDf4-77f-23@gated-at.bofh.it>
In reply to#1402044
From: Namhyung Kim <namhyung@kernel.org>

The commit 140aeadc1fb5 ("perf stat: Abstract stat metrics printing")
changed how shadow metrics are printed, but it missed to update the
width of the stalled backend cycles event to 7.2% like others.  This
resulted in misaligned output like below:

  Performance counter stats for 'pwd':

          0.638313      task-clock (msec)         #    0.567 CPUs utilized
                 0      context-switches          #    0.000 K/sec
                 0      cpu-migrations            #    0.000 K/sec
                54      page-faults               #    0.085 M/sec
           885,600      cycles                    #    1.387 GHz
           558,438      stalled-cycles-frontend   #   63.06% frontend cycles idle
           431,355      stalled-cycles-backend    #  48.71% backend cycles idle
           674,956      instructions              #    0.76  insn per cycle
                                                  #    0.83  stalled cycles per insn
           130,380      branches                  #  204.257 M/sec
     <not counted>      branch-misses

       0.001125426 seconds time elapsed

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Fixes: 140aeadc1fb5 ("perf stat: Abstract stat metrics printing")
Link: http://lkml.kernel.org/r/1463119263-5569-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/stat-shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index fdb71961143e..61200fcac5ef 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -188,7 +188,7 @@ static void print_stalled_cycles_backend(int cpu,
 
 	color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio);
 
-	out->print_metric(out->ctx, color, "%6.2f%%", "backend cycles idle", ratio);
+	out->print_metric(out->ctx, color, "%7.2f%%", "backend cycles idle", ratio);
 }
 
 static void print_branch_misses(int cpu,
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402052 — [PATCH 02/12] perf symbols: Store vdso buildid unconditionally

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 02/12] perf symbols: Store vdso buildid unconditionally
Message-ID<rzDf4-77f-25@gated-at.bofh.it>
In reply to#1402044
From: He Kuang <hekuang@huawei.com>

When unwinding callchains on a different machine, vdso info should be
available so the unwind process won't be interrupted if address falls
into vdso region. But in most cases, the addresses of sample events are
not in vdso range, the buildid of a zero hit vdso won't be stored into
perf.data.

This patch stores vdso buildid regardless of whether the vdso is hit or
not.

Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1463042596-61703-3-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/build-id.c | 2 +-
 tools/perf/util/dso.c      | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index bff425e1232c..67e5966503b2 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -256,7 +256,7 @@ static int machine__write_buildid_table(struct machine *machine, int fd)
 		size_t name_len;
 		bool in_kernel = false;
 
-		if (!pos->hit)
+		if (!pos->hit && !dso__is_vdso(pos))
 			continue;
 
 		if (dso__is_vdso(pos)) {
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 3357479082ca..75b75615e2f8 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -7,6 +7,7 @@
 #include "auxtrace.h"
 #include "util.h"
 #include "debug.h"
+#include "vdso.h"
 
 char dso__symtab_origin(const struct dso *dso)
 {
@@ -1169,7 +1170,7 @@ bool __dsos__read_build_ids(struct list_head *head, bool with_hits)
 	struct dso *pos;
 
 	list_for_each_entry(pos, head, node) {
-		if (with_hits && !pos->hit)
+		if (with_hits && !pos->hit && !dso__is_vdso(pos))
 			continue;
 		if (pos->has_build_id) {
 			have_build_id = true;
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1402053 — [PATCH 05/12] perf stat: Use cpu-clock event for cpu targets

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-05-17 04:50 +0200
Subject[PATCH 05/12] perf stat: Use cpu-clock event for cpu targets
Message-ID<rzDf4-77f-27@gated-at.bofh.it>
In reply to#1402044
From: Namhyung Kim <namhyung@kernel.org>

Currently 'perf stat' always counts task-clock event by default.  But
it's somewhat confusing for system-wide targets (especially with 'sleep
N' as the 'sleep' task just sleeps and doesn't use cputime).  Changing
to cpu-clock event instead for that case makes more sense IMHO.

Before:
  # perf stat -a sleep 0.1

   Performance counter stats for 'system wide':

        403.038603      task-clock (msec)     #    4.001 CPUs utilized
               150      context-switches      #    0.372 K/sec
                 7      cpu-migrations        #    0.017 K/sec
                71      page-faults           #    0.176 K/sec
        23,705,169      cycles                #    0.059 GHz
        15,888,166      instructions          #    0.67  insn per cycle
         3,326,078      branches              #    8.253 M/sec
            87,643      branch-misses         #    2.64% of all branches

       0.100737009 seconds time elapsed

  #

After:

  # perf stat -a sleep 0.1

   Performance counter stats for 'system wide':

        404.271182      cpu-clock (msec)      #    4.000 CPUs utilized
               143      context-switches      #    0.354 K/sec
                13      cpu-migrations        #    0.032 K/sec
                73      page-faults           #    0.181 K/sec
        22,119,220      cycles                #    0.055 GHz
        13,622,065      instructions          #    0.62  insn per cycle
         2,918,769      branches              #    7.220 M/sec
            85,033      branch-misses         #    2.91% of all branches

       0.101073089 seconds time elapsed

  #

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1463119263-5569-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 16a923c1633b..efdd23221c16 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1905,6 +1905,9 @@ static int add_default_attributes(void)
 	}
 
 	if (!evsel_list->nr_entries) {
+		if (target__has_cpu(&target))
+			default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;
+
 		if (perf_evlist__add_default_attrs(evsel_list, default_attrs0) < 0)
 			return -1;
 		if (pmu_have_event("cpu", "stalled-cycles-frontend")) {
-- 
2.5.5

[toc] | [prev] | [next] | [standalone]


#1404152

FromIngo Molnar <mingo@kernel.org>
Date2016-05-20 08:30 +0200
Message-ID<rAM6B-1Zw-9@gated-at.bofh.it>
In reply to#1402044
* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit 3f56e687a138481894a1088d5aa7d41951bdb020:
> 
>   perf/core: Disable the event on a truncated AUX record (2016-05-12 10:14:55 +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-20160516
> 
> for you to fetch changes up to a29d5c9b8167dbc21a7ca8c0302e3799f9063b4e:
> 
>   perf tools: Separate accounting of contexts and real addresses in a stack trace (2016-05-16 23:11:54 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Honour the kernel.perf_event_max_stack knob more precisely by not counting
>   PERF_CONTEXT_{KERNEL,USER} when deciding when to stop adding entries to
>   the perf_sample->ip_callchain[] array (Arnaldo Carvalho de Melo)
> 
> - Fix identation of 'stalled-backend-cycles' in 'perf stat' (Namhyung Kim)
> 
> - Update runtime using 'cpu-clock' event in 'perf stat' (Namhyung Kim)
> 
> - Use 'cpu-clock' for cpu targets in 'perf stat' (Namhyung Kim)
> 
> - Avoid fractional digits for integer scales in 'perf stat' (Andi Kleen)
> 
> - Store vdso buildid unconditionally, as it appears in callchains and
>   we're not checking those when creating the build-id table, so we
>   end up not being able to resolve VDSO symbols when doing analysis
>   on a different machine than the one where recording was done, possibly
>   of a different arch even (arm -> x86_64) (He Kuang)
> 
> Infrastructure:
> 
> - Generalize max_stack sysctl handler, will be used for configuring
>   multiple kernel knobs related to callchains (Arnaldo Carvalho de Melo)
> 
> Cleanups:
> 
> - Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE, to stop using
>   open coded strings (Masami Hiramatsu)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Andi Kleen (1):
>       perf stat: Avoid fractional digits for integer scales
> 
> Arnaldo Carvalho de Melo (6):
>       perf core: Generalize max_stack sysctl handler
>       perf core: Pass max stack as a perf_callchain_entry context
>       perf core: Add a 'nr' field to perf_event_callchain_context
>       perf core: Add perf_callchain_store_context() helper
>       perf core: Separate accounting of contexts and real addresses in a stack trace
>       perf tools: Separate accounting of contexts and real addresses in a stack trace
> 
> He Kuang (1):
>       perf symbols: Store vdso buildid unconditionally
> 
> Masami Hiramatsu (1):
>       perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE
> 
> Namhyung Kim (3):
>       perf stat: Fix indentation of stalled backend cycle
>       perf stat: Update runtime using cpu-clock event
>       perf stat: Use cpu-clock event for cpu targets
> 
>  Documentation/sysctl/kernel.txt    | 14 ++++++++++++++
>  arch/arc/kernel/perf_event.c       |  6 +++---
>  arch/arm/kernel/perf_callchain.c   | 10 +++++-----
>  arch/arm64/kernel/perf_callchain.c | 14 +++++++-------
>  arch/metag/kernel/perf_callchain.c | 10 +++++-----
>  arch/mips/kernel/perf_event.c      | 12 ++++++------
>  arch/powerpc/perf/callchain.c      | 20 ++++++++++----------
>  arch/s390/kernel/perf_event.c      |  4 ++--
>  arch/sh/kernel/perf_callchain.c    |  4 ++--
>  arch/sparc/kernel/perf_event.c     | 14 +++++++-------
>  arch/tile/kernel/perf_event.c      |  6 +++---
>  arch/x86/events/core.c             | 14 +++++++-------
>  arch/xtensa/kernel/perf_event.c    | 10 +++++-----
>  include/linux/perf_event.h         | 34 +++++++++++++++++++++++++++++-----
>  include/uapi/linux/perf_event.h    |  1 +
>  kernel/bpf/stackmap.c              |  3 ++-
>  kernel/events/callchain.c          | 36 ++++++++++++++++++++++++------------
>  kernel/sysctl.c                    | 11 ++++++++++-
>  tools/perf/builtin-buildid-cache.c |  8 ++++----
>  tools/perf/builtin-stat.c          | 22 +++++++++++++---------
>  tools/perf/perf.c                  |  3 +++
>  tools/perf/util/annotate.c         |  2 +-
>  tools/perf/util/build-id.c         |  2 +-
>  tools/perf/util/dso.c              |  3 ++-
>  tools/perf/util/machine.c          | 28 ++++++++++++++++++----------
>  tools/perf/util/stat-shadow.c      |  8 +++++---
>  tools/perf/util/symbol.c           | 10 +++++-----
>  tools/perf/util/symbol.h           |  3 +++
>  tools/perf/util/util.c             |  3 ++-
>  tools/perf/util/util.h             |  3 ++-
>  30 files changed, 201 insertions(+), 117 deletions(-)

Pulled, thanks a lot Arnaldo!

	Ingo

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web