From 9f71b4f39d7c01cae9d80e938774ff6b0a9bfd80 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 7 Apr 2015 23:25:16 +0200 Subject: [PATCH] perf stat: Change metrics context calculation Changing metrics context calculation to allow more than 2 types of context. Following patches will add support for the rest of the exclude_* bits so we need separate array element for all context combinations. Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Cc: Andi Kleen Cc: David Ahern Cc: Paul Mackerras Cc: Peter Zijlstra Cc: William Cohen Link: http://lkml.kernel.org/r/1428441919-23099-4-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 52f433084779..cca100dc5fd0 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -247,9 +247,13 @@ out_free: return -1; } -#define NUM_CTX 3 +enum { + CTX_BIT_USER = 1 << 0, + CTX_BIT_KERNEL = 1 << 1, + CTX_BIT_MAX = 1 << 2, +}; -enum { CTX_USER, CTX_KERNEL, CTX_ALL }; +#define NUM_CTX CTX_BIT_MAX static struct stats runtime_nsecs_stats[MAX_NR_CPUS]; static struct stats runtime_cycles_stats[NUM_CTX][MAX_NR_CPUS]; @@ -269,12 +273,13 @@ static struct stats runtime_elision_stats[NUM_CTX][MAX_NR_CPUS]; static int evsel_context(struct perf_evsel *evsel) { + int ctx = 0; + if (evsel->attr.exclude_kernel) - return CTX_USER; + ctx |= CTX_BIT_KERNEL; if (evsel->attr.exclude_user) - return CTX_KERNEL; - /* Handle hypervisor too? */ - return CTX_ALL; + ctx |= CTX_BIT_USER; + return ctx; } static void perf_stat__reset_stats(struct perf_evlist *evlist) -- 2.34.1