From: Kan Liang <kan.liang@intel.com>
To: acme@kernel.org, a.p.zijlstra@chello.nl
Cc: eranian@google.com, andi@firstfloor.org,
linux-kernel@vger.kernel.org, Kan Liang <kan.liang@intel.com>
Subject: [PATCH V2 3/6] perf,tools: get real cpu id for print_aggr
Date: Wed, 15 Apr 2015 03:56:13 -0400 [thread overview]
Message-ID: <1429084576-1078-3-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1429084576-1078-1-git-send-email-kan.liang@intel.com>
From: Kan Liang <kan.liang@intel.com>
Events don't share the same evlist->cpus anymore. So same cpu id may
have different index in different evsel_list->cpus.
In print_aggr, aggr_get_id needs index to get core/pkg id.
perf_evsel__get_cpumap_index is introduced to get the index by cpu id.
Signed-off-by: Kan Liang <kan.liang@intel.com>
---
Changes since V1
- Rebase to Arnaldo's code
For pure invalid context event group, using leader's pmu as
event members pmu.
tools/perf/builtin-stat.c | 1 +
tools/perf/util/cpumap.c | 4 ++--
tools/perf/util/evsel.c | 14 ++++++++++++++
tools/perf/util/evsel.h | 3 +++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2c1456e..c4f8fd2 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1231,6 +1231,7 @@ static void print_aggr(char *prefix)
nr = 0;
for (cpu = 0; cpu < cpu_map__nr(counter->cpus); cpu++) {
cpu2 = counter->cpus->map[cpu];
+ cpu2 = perf_evsel__get_cpumap_index(cpu2, evsel_list->cpus);
s2 = aggr_get_id(evsel_list->cpus, cpu2);
if (s2 != id)
continue;
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index c4e55b7..82f3ea8 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -211,7 +211,7 @@ int cpu_map__get_socket(struct cpu_map *map, int idx)
char path[PATH_MAX];
int cpu, ret;
- if (idx > map->nr)
+ if ((idx > map->nr) || (idx < 0))
return -1;
cpu = map->map[idx];
@@ -274,7 +274,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx)
char path[PATH_MAX];
int cpu, ret, s;
- if (idx > map->nr)
+ if ((idx > map->nr) || (idx < 0))
return -1;
cpu = map->map[idx];
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 33e3fd8..e177f43 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -991,6 +991,20 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
return 0;
}
+int perf_evsel__get_cpumap_index(int cpu, struct cpu_map *evsel_cpus)
+{
+ int i;
+
+ if (evsel_cpus == NULL)
+ return -1;
+
+ for (i = 0; i < evsel_cpus->nr; i++) {
+ if (cpu == evsel_cpus->map[i])
+ return i;
+ }
+ return -1;
+}
+
static int get_group_fd(struct perf_evsel *evsel, int cpu, int thread)
{
struct perf_evsel *leader = evsel->leader;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index e486151..5e9d347 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 {
@@ -366,4 +367,6 @@ typedef int (*attr__fprintf_f)(FILE *, const char *, const char *, void *);
int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
attr__fprintf_f attr__fprintf, void *priv);
+int perf_evsel__get_cpumap_index(int cpu, struct cpu_map *evsel_cpus);
+
#endif /* __PERF_EVSEL_H */
--
1.8.3.1
next prev parent reply other threads:[~2015-04-15 15:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 7:56 [PATCH V2 1/6] perf,core: allow invalid context events to be part of sw/hw groups Kan Liang
2015-04-15 7:56 ` [PATCH V2 2/6] perf evsel: Set evsel->cpus to the evlist->cpus when not constrained Kan Liang
2015-04-15 7:56 ` Kan Liang [this message]
2015-04-15 7:56 ` [PATCH V2 4/6] perf,tools: check and re-organize evsel cpu maps Kan Liang
2015-04-16 16:33 ` Mark Rutland
2015-04-15 7:56 ` [PATCH V2 5/6] perf,tools: open/mmap event uses event's cpu map Kan Liang
2015-04-15 7:56 ` [PATCH V2 6/6] perf/x86/intel/uncore: do not implicitly set uncore event cpu Kan Liang
2015-04-16 16:36 ` Mark Rutland
2015-04-15 16:15 ` [PATCH V2 1/6] perf,core: allow invalid context events to be part of sw/hw groups Peter Zijlstra
2015-04-15 16:21 ` Andi Kleen
2015-04-15 16:55 ` Peter Zijlstra
2015-04-15 17:28 ` Peter Zijlstra
2015-04-16 14:53 ` Liang, Kan
2015-04-16 16:31 ` Mark Rutland
2015-04-16 16:43 ` Mark Rutland
2015-04-16 17:16 ` Mark Rutland
2015-04-16 21:23 ` Andi Kleen
2015-04-17 9:47 ` Mark Rutland
2015-04-18 0:47 ` Andi Kleen
2015-04-20 10:15 ` Mark Rutland
2015-04-20 16:57 ` Andi Kleen
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=1429084576-1078-3-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=eranian@google.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