Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423868AbdD1Ey6 (ORCPT ); Fri, 28 Apr 2017 00:54:58 -0400 Received: from mail-by2nam01on0050.outbound.protection.outlook.com ([104.47.34.50]:34816 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1423827AbdD1EyZ (ORCPT ); Fri, 28 Apr 2017 00:54:25 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cavium.com; From: Ganapatrao Kulkarni To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Will.Deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, acme@kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@redhat.com, jnair@caviumnetworks.com, gpkulkarni@gmail.com Subject: [PATCH v2 2/4] perf tools arm64: Add support for get_cpuid_str function. Date: Fri, 28 Apr 2017 10:23:45 +0530 Message-Id: <1493355227-31492-3-git-send-email-ganapatrao.kulkarni@cavium.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1493355227-31492-1-git-send-email-ganapatrao.kulkarni@cavium.com> References: <1493355227-31492-1-git-send-email-ganapatrao.kulkarni@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MA1PR01CA0068.INDPRD01.PROD.OUTLOOK.COM (10.164.116.168) To BN3PR0701MB1686.namprd07.prod.outlook.com (10.163.39.152) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 462ceab7-b9a9-41ba-23c2-08d48df2a28a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR0701MB1686; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;3:r2my90+FThI9XU1e+NhzE1MY0cY8eYV/E7AfodELB3MnaEt+GN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j4+5nTpuFicUD2HJNGxzuC7WGvVY9qHiz4Vc7asgeAhaGrgU9luwx2QlCVtWZW2T57s8YtrckoOrm+W2O+vPanEEesxmzOsqALpPEQAsEYiOuulw2SR302/qt8Nzg5swy89cq+K1C6M/7jzKwOEXv5Ob4O9Y76K4RFGGXdqNv88Wa7hJKYTzgs+MBL7/6QgKJgQOAWmb9jog9sa+QDcFV3E+J41JfvVUB0cLmGVzNtTPCpWoukUmz8fzqt8nT5d9fiAdSBQnh+LDC+cbndsdXWt9d8jpx6ud+UheiFKtQTZzka3VhM+iVAFcg3VdVKHghJIwSGMuBXiR0h3oYFmaJ5UX32Zh8QZpKq/VAIPoZ3QM4GXDlhHwyzN8MUs/UDDulD854vUiFen5Yv6JWfnePQF59cAilYz8JuBT/cxjpMailt65bChoXgLYPjS12nQdw+crB5VabSgsbozMhMIbeHVDQGIn76p+r X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(20161123558100)(6072148);SRVR:BN3PR0701MB1686;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1686; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;4:Lln0yGmtKr+Eff61Owlvj3wx1L6kC9YBOga5cJmpWOnJNNPrziXv3PJufBXG4JHbfdk6Zs2p178jmZvdKbbrjslljpLMxtwB6JIOj+gR2mpqng9hkqDB3zceeVmzA6CLKJ9F68vUGyIORgUW1/ud0sHLy9+fC8XCIvGU6RvuHSreZxEmfYAzMi7ecxc5XBMyp2c9jRvPpNjHwSolfSk2t6/0kX7dvsp9xyrDJscwMHu2jTcpJ9O1UVlzLDsvYBvUnOudank803YRH/EYLvHkz0y0ZMQIunylZFRMr53ViaCOLkEMAiagZ3zMm5qDa5nvSObZkl001KEBSo3C9bMyjl6iROhazt3bqRLzCf4B//pn3/oI4H+aWuinIyASMm3wZ1659Eo0bNjpmI5IMjLIjaCCe7CCz1MIhR9xdSAuE1d2XGPV0xtYaOfpf93bZNdp6vaYvJWEKLLRA4b2A7J0PwrWSVECXT3wOIgj5NOSJG3nkzFNRP8oUZgFp62eA2P0nPpwQGShyxjSC3Z8KI1Dh/t1lZyrtbFdc1kV6FdkKqH6T94d5Jntj6u8hNOVjB8F4EXoviUlTbffI0HekoGoJ0SBHFu+loMtQovEFxlsa8PAvoH73zGLprHS4edMJaiEY9puEiuSgke/VDChWbCjObyL09hnj1b8lE9XabK/npKoDAuflsEdW4jcW0UevZqFNXxzPAauBS+s3tuBZelMruXW9VwR3c8XghCeaOcqxAKUgkM79jBQrq9g1Sa83iC9gtDZj6mm4QET002ipdhAcY1t20JAb5YFSgyBfkpZq/ZBHWACioGescRdnUldkg3UjHA6O9U3bOoR0ho2NeyE0A== X-Forefront-PRVS: 029174C036 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39840400002)(39400400002)(39450400003)(39410400002)(50466002)(3846002)(86362001)(6486002)(36756003)(5009440100003)(48376002)(6512007)(4720700003)(7416002)(6116002)(5660300001)(50986999)(2950100002)(6506006)(53416004)(25786009)(42186005)(5003940100001)(38730400002)(110136004)(50226002)(305945005)(6666003)(7736002)(33646002)(4326008)(8676002)(66066001)(47776003)(189998001)(2906002)(53936002)(81166006)(76176999);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1686;H:mypc.caveonetworks.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0701MB1686;23:Ew9WiSJssz7sWf9cR2xwN1wODlkWZFeb4OYnN9c?= =?us-ascii?Q?nLtU8MIfaSqxNil168PBalXgNlgJ1FP5ufULmc3ffyKjyKaqBB8CUALzGqPZ?= =?us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XfCOkjHgaCOjWguVae97qeS?= =?us-ascii?Q?j8Pkw793b6osEgxifocxp6rC+fMeL8QwP9G8IU7ywPrRX+O75Zx/tC+y/GHW?= =?us-ascii?Q?6Ro+E/lM=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;6:xAM0fv8wSWQTd4pDXjIhb9JKSujAKuaV9NwG9SdLfH2nK/2J8HQ5Iwu9uBWvndUlSbMuZsS5Uyjwhw7dyFLKOIxaLiouH4o42zMq6pMYnnSm9/tXMfqPml09YSNZdisIFZEpAjX+SI/9LUMCCG059wlA4Bd26D47pd19LXGk8YFEdFzy2rewdhlEh2pXEaw6Y+kBh9xbek7IjRnujOsnAV6we52CXRngdtJEnomWU6xDTsGsEjOW7O/MOOEfMIQt06r3OXOd0E4UuAB3kTBSmipAbU3Pwh63Lq3XJEeBQ9h1uw17XWHJQgJRg37mzZlH50h24UdMoti9dA6Y+/NNWGG/ckY/Pt0hUSCj+1HRKEXVKEA1ubBw2KISryN7GMO5ju3F/N6/5AT1IwwgLr1ML4oXj5Q9daUS3H89qeUbAu77VnXLfnt99bshTGLyiQu4Qw4brfxtIzudFESgOyGzn4Tll39b0V5mc2oQZMT2nn61FZlcSe/WbGpUyNve5RO7GQQGhv7xaYTDEmMl5wkh9Q==;5:t+ZArOT1/WDBq0BrQ62lxdZq5WJPgEXkt1b6I7ZmP7bUkMVcEXYoSlNFKx6CzjMKP9RwE7QL3EyGivsySTsm+s0yoyneUlW5+ALVfrLEXL8l8qHB+O3cqYIbL1gGJFxSHxwyx8OLyHRkMlXI5b8J3A==;24:0jMaf41D64x1gpS1TSuk2ugPXhFR9/aXwyL2dWntixwT0tFlR1MGBAI7HKgpKnXzbeRb+C9DdrIXsex1Nj/yGlE4dEdlmMRonIoXQmbZZOc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;7:72SwhEtAA5JGENHAUjbRkR8fZx+9x9RlP2oAeJFPvs6Bl9146n+fP203GUNgRlWruzXkYJJ4I/NFLgmBilzy/hvibWeuCa6xUyAF8HHPMk5sMvfPxtnzXbpsHXJoEcHghOlUKoADscVarwa7VXY66Q/bzbQlUhvoDDIf/WHrfI79LguCTNIfrGWU2iLSxsSAj7/8zuHh1/60eyKGe5nbA5s3ku69LhvZzpvwtQ6lCORfMhBMERDRnFvbeox2IoYafCOk/N4dotM3h5OT1Ok9/B8kHC4yN3iE6ZXTyK5flqHLHmQKPNVGJoBDslcoAzCPWUqvKr70EcNVyAwtqsb+Vg== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 04:54:18.0426 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1686 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1823 Lines: 68 function get_cpuid_str returns MIDR string of the first online cpu from the range of cpus associated with the pmu core device. Signed-off-by: Ganapatrao Kulkarni --- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/header.c | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tools/perf/arch/arm64/util/header.c diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index cef6fb3..b1ab72d 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,3 +1,4 @@ +libperf-y += header.o libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm64/util/header.c b/tools/perf/arch/arm64/util/header.c new file mode 100644 index 0000000..d8980a6b --- /dev/null +++ b/tools/perf/arch/arm64/util/header.c @@ -0,0 +1,41 @@ +#include +#include +#include "header.h" + +#define LINUX_SYS_CPU_DIRECTORY "/sys/devices/system/cpu/" +#define MIDR "/regs/identification/midr_el1" + +char *get_cpuid_str(struct perf_pmu *pmu) +{ + char *buf = malloc(128); + FILE *file; + char *ret = NULL; + int cpu; + char sys_file[256]; + struct cpu_map *cpus; + + if (!pmu->cpus) + return NULL; + + /* read midr from list of cpus mapped to this pmu */ + cpus = cpu_map__get(pmu->cpus); + + for (cpu = 0; cpu < cpus->nr; cpu++) { + sprintf(sys_file, LINUX_SYS_CPU_DIRECTORY"cpu%d"MIDR, + cpus->map[cpu]); + file = fopen(sys_file, "r"); + if (file) { + ret = fgets(buf, 128, file); + if (ret) { + buf[strlen(buf)-1] = '\0'; + fclose(file); + cpu_map__put(cpus); + return buf; + } + fclose(file); + } + } + cpu_map__put(cpus); + free(buf); + return ret; +} -- 1.8.1.4