mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kan.liang@intel.com
To: a.p.zijlstra@chello.nl, acme@kernel.org, linux-kernel@vger.kernel.org
Cc: ak@linux.intel.com, Kan Liang <kan.liang@intel.com>
Subject: [PATCH 3/5] perf,tools: change perf stat to use event's cpu map
Date: Tue,  3 Mar 2015 03:54:44 -0500	[thread overview]
Message-ID: <1425372886-33397-3-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1425372886-33397-1-git-send-email-kan.liang@intel.com>

From: Kan Liang <kan.liang@intel.com>

With cpu_list, perf stat should use event's cpu map.

Different events may have different cpu map. So the same index in cpu
map does not point to the same CPU id. perf_evsel__get_cpumap_index is
introduced to find out the CPU id's index for a given cpu map.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/builtin-stat.c |  5 +++--
 tools/perf/util/evsel.h   | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e598e4e..5ae8686 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -165,7 +165,7 @@ static inline void diff_timespec(struct timespec *r, struct timespec *a,
 
 static inline struct cpu_map *perf_evsel__cpus(struct perf_evsel *evsel)
 {
-	return (evsel->cpus && !target.cpu_list) ? evsel->cpus : evsel_list->cpus;
+	return evsel->cpus ? evsel->cpus : evsel_list->cpus;
 }
 
 static inline int perf_evsel__nr_cpus(struct perf_evsel *evsel)
@@ -302,7 +302,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
 	attr->inherit = !no_inherit;
 
 	if (target__has_cpu(&target))
-		return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
+		return perf_evsel__open_per_cpu(evsel, evsel_list->cpus);
 
 	if (!target__has_task(&target) && perf_evsel__is_group_leader(evsel)) {
 		attr->disabled = 1;
@@ -1218,6 +1218,7 @@ static void print_aggr(char *prefix)
 			nr = 0;
 			for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) {
 				cpu2 = perf_evsel__cpus(counter)->map[cpu];
+				cpu2 = perf_evsel__get_cpumap_index(NULL, cpu2, evsel_list->cpus);
 				s2 = aggr_get_id(evsel_list->cpus, cpu2);
 				if (s2 != id)
 					continue;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index dcf202a..a633320 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -8,6 +8,7 @@
 #include <linux/types.h>
 #include "xyarray.h"
 #include "symbol.h"
+#include "cpumap.h"
 
 struct perf_counts_values {
 	union {
@@ -359,4 +360,27 @@ static inline bool has_branch_callstack(struct perf_evsel *evsel)
 {
 	return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
 }
+
+static inline int perf_evsel__get_cpumap_index(struct perf_evsel *evsel,
+					       int cpu,
+					       struct cpu_map *evlist_cpus)
+{
+	struct cpu_map *cpus;
+	int i;
+
+	if (evlist_cpus == NULL)
+		return -1;
+
+	if (evsel && evsel->cpus)
+		cpus = evsel->cpus;
+	else
+		cpus = evlist_cpus;
+
+	for (i = 0; i < cpus->nr; i++) {
+		if (cpu == cpus->map[i])
+			return i;
+	}
+	return -1;
+}
+
 #endif /* __PERF_EVSEL_H */
-- 
1.8.3.1


  parent reply	other threads:[~2015-03-03 16:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-03  8:54 [PATCH 1/5] perf,core: allow invalid context events to be part of sw/hw groups kan.liang
2015-03-03  8:54 ` [PATCH 2/5] perf,tools: check and re-organize evsel cpu maps kan.liang
2015-03-03 16:09   ` Arnaldo Carvalho de Melo
2015-03-03 16:11     ` Arnaldo Carvalho de Melo
2015-03-03 17:09       ` Liang, Kan
2015-03-04  0:15         ` Arnaldo Carvalho de Melo
2015-03-18 12:31           ` Liang, Kan
2015-03-03  8:54 ` kan.liang [this message]
2015-03-03  8:54 ` [PATCH 4/5] perf,tools: open/mmap event according to event's cpu map not evlist's kan.liang
2015-03-03  8:54 ` [PATCH 5/5] perf/x86/intel/uncore: do not implicitly set uncore event cpu kan.liang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425372886-33397-3-git-send-email-kan.liang@intel.com \
    --to=kan.liang@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome