Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423853AbdD1Eyp (ORCPT ); Fri, 28 Apr 2017 00:54:45 -0400 Received: from mail-by2nam01on0048.outbound.protection.outlook.com ([104.47.34.48]:64267 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1423788AbdD1EyU (ORCPT ); Fri, 28 Apr 2017 00:54:20 -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 1/4] perf utils: passing pmu as a parameter to function get_cpuid_str Date: Fri, 28 Apr 2017 10:23:44 +0530 Message-Id: <1493355227-31492-2-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: e3ec4601-11ec-455e-1407-08d48df2a017 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR0701MB1686; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;3:F8j9KI49s28QAt/K5+A23+rGRckYoMsq9KFxoupXA6r5oFoLftf2K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SlUaohohsq5GLBWE8Vg9uB9ir9HnD8Nz11YdJUEpF6s6Se8WWCwMwZznRqVBIMqS/bwfF+6EhTWL0vCY63wehGOxZ8CM9V4zIqOPVeS21PzY9R1fiJSOB6hQR3k4Va4nrYw5WyMfBQPjMNXypa+IxU5J+QeGNQxTIw7GYbSXIauGsIzosJBfC9di3hKWYRUKe63EjILG+P/DzNSCEMlR5taaz45ysri/Jj7toHTUJlarYUckT6OViuqy6eoR74bQss4wLNYqTUfv1KaWHSbjt9KBOjX67u+EgNzmP5prc7CCQ7Kmy7Qlva40CDxk42QoLClOcMtRzZpxqevxJ7CqrxaeHlKVqzIpWvzi3wyHpi1UxKDTbUE4Z8j6yFVYKMNVRCmnmQcy8uSEs//1CD1XXpwv6FfqSeAiQ2pG3Kzgh18sgzV5znPHbZ/vD4imGJeVDDuhDwwoA3Vgtyvt2ERi0cTC6ipx92wJQZvdClw6ZYkTg7TSbSjb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; 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:W1JTXQ/v79VC4V+1tqOGXXG/hXMq3qz8tMf1oo3DMhc9NxvMj5gDOyewJgz3aSuwIgCovkMR+ipqvlIKJsROvgCJsRU8B3PexeMEn2DLavNBCGsiZOJBT0aQK4poabduR2O+mC0ShzEK6dFSvlTvgmIOkFJo14AnpWVJH3n+8iNpUpWo0iP9bmr5uRwkshEJ/+BumqteRMHBbVlyCfQmIDil0BUZVItTpyaWeHDyjitPhXalt/dYCvWDEBZKpkgZ6x438B1v2Y/9smAMtkIGOQWm2tfaxOGTqQ4WverH/IoZcOYE9ez6G+AlwMW8HeHsdajPM6/qAvgegPw0p322O7mI8WH08GmzCwgPG78XZ7jefrusJQ5Gs3yPKdMxZGjBjVRoWOM7dXsn3hf+HQgAoacDRyAxBjGI1bpL8DcLliBzbjX3GmSUKmheBpTwha+CMJ2mlv8i83ITRYdflKji0ClLM+DvkNSMxGsQ+xcYI/4JdtUNPmh4goU8YWSFDyJ9SKSb1TkWlxMD33SXqa7gpxVPQjlNoW5eyOphhvgYNWT3pdU17faUu6grlpAiRRmUPESV+LpSAwWlXu/DYiWt8rXT1TunSsPvDcdBvMeKz+TBmuw+jFi595F9RIeZtsm05ICXPehCjPHkFi6OPwXyBexDUAc3CZVb50kF5XfaEVY3O78PYfR3rACHdXGgvb5hLtBcFL3NOkVWvjvlApPTsboyjlQ9rb2AGtT36CS67CTmpBpItHzycro8xgE7bimMU6Ld3nNvg+zCk5ghDspyf3ci9lA9jyZyjcEI/tNupBY= 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:DFZMQPI7w7f9l/f8mWgSCHsm6yT7Z7Dtbx4b42l?= =?us-ascii?Q?uLWgw4oOLCS8bwiGWvh0iHwTOqJwfzEJVDfBkz8iojKd4gxPenBc44m0SqXs?= =?us-ascii?Q?P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mBOWXn71phtfodbjdrPPOzJ33A8/zW?= =?us-ascii?Q?VQqDYzXRlxEbkQo2mCjrJ+d2IeG43cJimpB6QwjP1z1Koqe6aH/LzjpldCcu?= =?us-ascii?Q?R1Uf2CW0=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;6:qE1rD2NONuUUq0S2WqCjCwOICgaPQRTrTJdtZNvxaJl9gYwms5e78+Dlkh4OwQWW1qLZR4TgfTxi89SYD85vfE18boUIVyS4iD5Rs74wRPc8ObynH3EIqCm/hg/pINTRD/7bAYUyqG5/M9aq4aOEckDSgw/rlsvmdI2kH18egvizUGc1/z2qoCNGiULNwXl30ZyuNiemcu9q8tYHYmrXxwSBtmEMP+rRO3IjuKgG+u/KlggMkydXulXO+yOURPCuDtfdUWsrbdT8y5LtZdZz0v+XEk1uwDs7cQmoZfuxPz0pPFqkig1PJlmwMxflQiOkVJ7rhNrShZGH2rcFKdM1L5slT1zTddo4/GjHj5UMZBuE30xrzbe+a+fa32IztcPjS2e89wIEcbY57TnwEY1RJHAxrA5SRJ2CPwBwHlEhr09mowSKwL8k5zkBdlVj2GhjvsrgZPqSbJ0IC3MwFTfc+kHSSa3hXNsbrq87/0AbdS3TccCGYBB1YvRL0hVq47bwtA+/CPrany25Gw86tpgBhA==;5:5SyYbfrFABmjPHZyjCKHK31J8Q+gSHUDDzS/7ACsNF6ELagQiiDrPs4iu+rW19f/BpQ8OXvn0FJUmmb//PLn4yt00RlxDdM5yv3eyftLsIZ5QQOmMmgu/A0ZIysquedewKpDaFGYg4U9A265kYqCmQ==;24:sjatePkmhoFzYAmrJ27MIH48ylCoBz5Oap7uK2wSkGEdlBz5I3kNWeEFArYS4SnELAVOLLH6Kb7L7LQowYLvdB2UJv/2zv8UF/j8s70CG1Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;7:hyxqwgpSWNKj7VgcxpvWfamh7suqx7FYW6bRXjvZD6d2dHt1uoMmoc20GaZhUFHMWimeFufX1hGbND4hpjmVLGL5rJSm8md0vjYJQXIrdGYWSuonY4u7p5/UxUIUz8vzi59EQGOt362CxROOrHmD0kcGcdhrfJQrjazvKKDsFYBP8XtGq3BSx2AZ/4zbc+EBk4c9E0EM048p2sPolVaNARiv2UcCVxPrrkOTm+7lw0gBbzVnDg9ElkqHtUM3n5a+XAJnovLf0qkmRJH3n+C3ASn2qvJ/sB+7oiTOm2/RJ8yarJIilSKMpsw3AZVFjb5K6YK9A+1SQGwGoTX07S92kQ== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 04:54:13.9175 (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: 3366 Lines: 116 cpuid string will not be same on all CPUs on heterogeneous platforms like ARM's big.LITTLE, adding provision(using pmu->cpus) to find cpuid string from associated CPUs of PMU CORE device. Signed-off-by: Ganapatrao Kulkarni --- tools/perf/arch/powerpc/util/header.c | 3 ++- tools/perf/arch/x86/util/header.c | 4 +++- tools/perf/util/header.h | 3 ++- tools/perf/util/pmu.c | 10 ++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c index 9aaa6f5..9a70cc1 100644 --- a/tools/perf/arch/powerpc/util/header.c +++ b/tools/perf/arch/powerpc/util/header.c @@ -34,10 +34,11 @@ } char * -get_cpuid_str(void) +get_cpuid_str(struct perf_pmu *pmu) { char *bufp; + do { if (pmu) {} } while (0); if (asprintf(&bufp, "%.8lx", mfspr(SPRN_PVR)) < 0) bufp = NULL; diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c index a74a48d..1e240ca 100644 --- a/tools/perf/arch/x86/util/header.c +++ b/tools/perf/arch/x86/util/header.c @@ -65,10 +65,12 @@ } char * -get_cpuid_str(void) +get_cpuid_str(struct perf_pmu *pmu) { char *buf = malloc(128); + do { if (pmu) {} } while (0); + if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) { free(buf); return NULL; diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index d30109b..6bb14a4 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -8,6 +8,7 @@ #include #include "event.h" #include "env.h" +#include "pmu.h" enum { HEADER_RESERVED = 0, /* always cleared */ @@ -151,5 +152,5 @@ int perf_event__process_build_id(struct perf_tool *tool, */ int get_cpuid(char *buffer, size_t sz); -char *get_cpuid_str(void); +char *get_cpuid_str(struct perf_pmu *pmu); #endif /* __PERF_HEADER_H */ diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 12f84dd..c754805 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -504,8 +504,9 @@ static struct cpu_map *pmu_cpumask(const char *name) * Each architecture should provide a more precise id string that * can be use to match the architecture's "mapfile". */ -char * __weak get_cpuid_str(void) +char * __weak get_cpuid_str(struct perf_pmu *pmu) { + do { if (pmu) {} } while (0); return NULL; } @@ -514,7 +515,8 @@ char * __weak get_cpuid_str(void) * to the current running CPU. Then, add all PMU events from that table * as aliases. */ -static void pmu_add_cpu_aliases(struct list_head *head, const char *name) +static void pmu_add_cpu_aliases(struct list_head *head, const char *name, + struct perf_pmu *pmu) { int i; struct pmu_events_map *map; @@ -526,7 +528,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name) if (cpuid) cpuid = strdup(cpuid); if (!cpuid) - cpuid = get_cpuid_str(); + cpuid = get_cpuid_str(pmu); if (!cpuid) return; @@ -601,12 +603,12 @@ static struct perf_pmu *pmu_lookup(const char *name) if (pmu_aliases(name, &aliases)) return NULL; - pmu_add_cpu_aliases(&aliases, name); pmu = zalloc(sizeof(*pmu)); if (!pmu) return NULL; pmu->cpus = pmu_cpumask(name); + pmu_add_cpu_aliases(&aliases, name, pmu); INIT_LIST_HEAD(&pmu->format); INIT_LIST_HEAD(&pmu->aliases); -- 1.8.1.4