Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932568AbbDOPJL (ORCPT ); Wed, 15 Apr 2015 11:09:11 -0400 Received: from mga14.intel.com ([192.55.52.115]:31040 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756056AbbDOPIw (ORCPT ); Wed, 15 Apr 2015 11:08:52 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,582,1422950400"; d="scan'208";a="714104612" From: Kan Liang To: acme@kernel.org, a.p.zijlstra@chello.nl Cc: eranian@google.com, andi@firstfloor.org, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH V2 3/6] perf,tools: get real cpu id for print_aggr Date: Wed, 15 Apr 2015 03:56:13 -0400 Message-Id: <1429084576-1078-3-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1429084576-1078-1-git-send-email-kan.liang@intel.com> References: <1429084576-1078-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3223 Lines: 108 From: Kan Liang 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 --- 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 #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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/