Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754745AbbGXVDf (ORCPT ); Fri, 24 Jul 2015 17:03:35 -0400 Received: from mga14.intel.com ([192.55.52.115]:22443 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754179AbbGXVDd (ORCPT ); Fri, 24 Jul 2015 17:03:33 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,540,1432623600"; d="scan'208";a="612361976" From: kan.liang@intel.com To: a.p.zijlstra@chello.nl, acme@kernel.org Cc: luto@kernel.org, mingo@redhat.com, eranian@google.com, ak@linux.intel.com, mark.rutland@arm.com, adrian.hunter@intel.com, jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH V2 2/6] perf,tools: read cpu max freq and msr type from header Date: Fri, 24 Jul 2015 09:48:28 -0400 Message-Id: <1437745712-16649-3-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1437745712-16649-1-git-send-email-kan.liang@intel.com> References: <1437745712-16649-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: 3070 Lines: 101 From: Kan Liang In perf report, read cpu max freq and msr type from header. Signed-off-by: Kan Liang --- tools/perf/builtin-report.c | 3 +++ tools/perf/util/cpumap.h | 1 + tools/perf/util/header.c | 21 +++++++++++++++++++++ tools/perf/util/header.h | 2 ++ tools/perf/util/session.h | 1 + 5 files changed, 28 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 95a4771..2a32e9a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -818,6 +818,9 @@ repeat: symbol_conf.cumulate_callchain = false; } + cpu_max_freq = session->header.env.cpu_max_freq; + msr_pmu_type = perf_header_find_pmu_type(session, "msr"); + if (setup_sorting() < 0) { if (sort_order) parse_options_usage(report_usage, options, "s", 1); diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index 6784677..70ac686 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -56,6 +56,7 @@ static inline bool cpu_map__empty(const struct cpu_map *map) int max_cpu_num; int max_node_num; int *cpunode_map; +unsigned int cpu_max_freq; int cpu__setup_cpunode_map(void); unsigned int get_cpu_max_freq(void); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 287a488..e83681b 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2847,3 +2847,24 @@ int perf_event__process_build_id(struct perf_tool *tool __maybe_unused, session); return 0; } + +int perf_header_find_pmu_type(struct perf_session *session, const char *name) +{ + u32 pmu_num = session->header.env.nr_pmu_mappings; + u32 type; + char *str, *tmp; + + str = session->header.env.pmu_mappings; + while (pmu_num--) { + type = strtoul(str, &tmp, 0); + if (*tmp != ':') { + pr_err("unable to read pmu mappings from head\n"); + return -1; + } + str = tmp + 1; + if (!strcmp(str, name)) + return type; + str += strlen(str) + 1; + } + return -1; +} diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index a646025..233644b 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -150,6 +150,8 @@ int perf_event__process_build_id(struct perf_tool *tool, struct perf_session *session); bool is_perf_magic(u64 magic); +int perf_header_find_pmu_type(struct perf_session *s, const char *name); + #define NAME_ALIGN 64 int write_padded(int fd, const void *bf, size_t count, size_t count_aligned); diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index b44afc7..a339338 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -17,6 +17,7 @@ struct thread; struct auxtrace; struct itrace_synth_opts; +unsigned int msr_pmu_type; struct perf_session { struct perf_header header; -- 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/