Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423884AbdD1Ez2 (ORCPT ); Fri, 28 Apr 2017 00:55:28 -0400 Received: from mail-by2nam01on0084.outbound.protection.outlook.com ([104.47.34.84]:24800 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1423832AbdD1Ey3 (ORCPT ); Fri, 28 Apr 2017 00:54:29 -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 3/4] perf utils: Add helper function is_pmu_core to detect PMU CORE devices Date: Fri, 28 Apr 2017 10:23:46 +0530 Message-Id: <1493355227-31492-4-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: 99120565-78c3-430f-5a98-08d48df2a504 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR0701MB1686; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;3:lUDIQKglG4XayEg1Knh+kIPlWYsBRd6uJzQGC4/iab0R24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UgOv2HIWrfLNzJr1O5jNNaOraHaov+m29cY/la3sQ3XN/HF3Gg9z1Lv4h8jQtmPaq0ZORDXE9GD7FosPhpTf/Orc8OolMJjb5nkk+/8AQMt682dNJASLDLLIyobQZj7X0cmaj2tXFg6nj5mDshob/zyFWQ0PdDXQZvRA/aHL1p6GflBRNgU6vdWrHDl/nyOgB+kt1/9U8DMOHcwvouPYOxard+QyUqo/bKWtkXvayCjXxu26xGAT9wlwDB4MeATUxTIt+ieKaokWvlMoK/opVBz6TN2lgdJbnG8VUYTsTST3h7qaDtBVoIzCrZ7acEZ7NBJ8L/S6aC/2IL0ZNNCYFvpAflSb/itjv0dDmj5vIPAg4s3Z1fT0Cs3WTKN/9L6ZCSFKUmIcWQ4j4oicf/zidog2JZoF/M0+70evelKQrp1IXKnLU1rEQvlUYUhFG6KYVYcJVe7tn8+hxAi9Q+iy/24zvWVGEn7z0nexpqkEQ68oTXIuj5uIRlp7b1p 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:/SzkaG0g2kim1IL2A59h8k0qyrc/+/5GXRk1cE3O+UilHD0jPyjGz0vi5tQfQW3VnUv3aOoSfSYz0hf6rgPR8ygaBvM22xWn9Qu4m7UVVXT0OvydqPb7Fbh1STetgvuLShlP7oZqeLvDDtH709AeHwhAwpXw+YPw2NuMcqZk+rkh39aR9EUQLCIZFKmM+91rCrkAZzJGeVL8De/tBtTuhdjOfyFawh1SFYBzbqDMnSVIgo6kF/qs/lUKs88omgGYn5TOSPv+FTgB/bVAW7XvEBeko+mBnEBbVUSx7CiE/DpvwpU7hvrvSYXWzj03DRGjqAkkYvevfzCFfiTWrbFhM2AO9mSw0MEdI6882iRB3mIVrjhqT6zbGRAKeCnGLhKqgn6WnLIzjExQfm3IfHMhV2ZT0f8nRlG4IZB160EwrZuqb3C32yAIOPFzegwNa5YPqAoz9l5Dj9j7FXRThajUEp3T05UcqgBePJ1fwCc3iKG51fddWhtXMGEf7j9nZ4LD8mPrAfTbX/jJY5KyeM3/cSRuPMzye/ckFUPcplr0ctB2Bi9eV6aWH12Siaa7iMiI4/ZGXbTHvQ2HFLnOy5hKWWzvyG/zfsf/+M3MAuNDZZNgte3wz0Ez5OyKlSL40RwZLKqsKQuohfgNwWtb4/1KYF0mptsbokUPx004Y5O6UYP5+jk5jSZK8GG1R8soInEnLjEETs0VnC0COBY0xQmMDx2Gh5C4m7wey4Gd7cRV3S1yhceXWlC48mP8NsBu3PzFG+gu17NHNyAF1Q0VFBO1f2PV3iRVWqUbes4tFImwT34= 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)(217873001);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:PBPbTaBKW1qPp76q9Tbom1emHc851RSUdiFMMFZ?= =?us-ascii?Q?KQ7VXsvyCobPP4J+4JOAyyh1MxQPj2QPP8RKdwjU6YtLLq9kRbg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KXegvK7JPJNKerXpfMrK9YgEi0Y2H?= =?us-ascii?Q?zR7W2noKM6U4P4SZ3uOjC5yUzby4Zkg/0vrQhLYF2nkfFX1loPrPKebC2hyw?= =?us-ascii?Q?4YKEn0vulmpuRlD36PPAmva9aw4Yd?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;6:+mzw+QNjoba5jyGfQa1ECYvdqVrOJ10Nc3qg1M3HAas8Nox4+0sXpn4QnwCmEpSV1DxVf+fN7yZ9JycFxu/Dtyjwf2S543EQXWwfS8pvYT5EVSfx8OakBFkuWZwBnPd9/35AZjIKCK6WAsmHbpcG6EbLSzav4LjFGaQjoKYxMm9L/2X8Hgb2fna4c3KdY8NtIMucsHBZV4zB1xUS4ehRKYOgOIkKkwUM47LfPnC2kVu9ilRh8SuS6ihlrV+5ucNNm+Yt3mXvU7CiZBA7iPaR9YjFoc9DOUH7QHZb//5Z3Hwkb7h3WTJonoHzxt9XGEgVW9T3UNMv1Qgl7r8dlowhNBPW4RjqJgc6V36PCEBnC1a9tRzlgHxBgTCDRA2ICOSZLJ0KlXkDFPrbO4Hnw7mELt/0Q33DNZuQdSRWAk3NDFDNYFKNmABlzOH5e9bAbaK2Yuihn5DCpUO0/d2tsrOwrAEOaNtQ6PnnO/c17UkZGwTQSdsDbldV5/asK1OaM2prs7686geN0bu/lz6hW7sMSw==;5:TdH8YRXULOdABJfHsDke9WXyILhSc1mRz0WX9I6iV1qwtN5sHd87GKAwm9wBNn86Nx5MCt59yM8XgYW/kBuN0d53x+GIOnEm6onO97PwCmPiiUHdE226uBDlRsf9D2/dz00tiyHvbH+7mYQDjPdIRA==;24:K92WuSQcSSiUEET3TFHmFArh8sB06q+AE0/py1aoPsPwq75T3W5LAKhY0PdKhu0KQtC+B4kHDMEFaevZLbqlgar12jpVat7rsoaVZlEI30k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1686;7:a6BfM1/nHDn3RZid7gk2Q16dW/o6tuJUJB4sPcxunavW+a6mwbv9no4yYTWgeZHCoQzu6mdsPR05q+H/ahUDCvl5qXDznEZzpGkhAVSkTWmZskYAq11V6gq4IvwFtXVDvP3umbMCKiIVQrMiKMTDb6gTzMh1Tv6c06N9HVwMWT4rSYIs7cvrqyNEsjAQoC1HHtOerddcM2LrE4TU55BpfIkN9gy6Q4MhnI9FiSiouoX1U+uTaub4F+CiREFxipxy1DfWeRVymMWIIeMpogjBmNUBWhbicwquAw4/SfTeru9vo8VBfWzXLF/GPM0uJZ5j8ZP0Nga5W9e9fWQ/lKvoNQ== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 04:54:22.2146 (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: 2142 Lines: 80 On some platforms, PMU core devices sysfs name is not cpu. Adding function is_pmu_core to detect as core device using core device specific hints in sysfs. For arm64 platforms, all core devices have file "cpus" in sysfs. Signed-off-by: Ganapatrao Kulkarni --- tools/perf/util/pmu.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index c754805..48333fe 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -499,6 +499,39 @@ static struct cpu_map *pmu_cpumask(const char *name) } /* + * PMU CORE devices have different name other than cpu in sysfs on some + * platforms. looking for possible sysfs files to identify as core device. + */ +static int is_pmu_core(const char *name) +{ + struct stat st; + char path[PATH_MAX]; + const char *sysfs = sysfs__mountpoint(); + const char **template; + const char *templates[] = { + "%s/bus/event_source/devices/%s/cpus", + NULL + }; + + if (!sysfs) + return 0; + + /* Look for cpu sysfs */ + snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu", sysfs); + if ((stat(path, &st) == 0) && + (strncmp(name, "cpu", strlen("cpu")) == 0)) + return 1; + + for (template = templates; *template; template++) { + snprintf(path, PATH_MAX, *template, sysfs, name); + if (stat(path, &st) == 0) + return 1; + } + + return 0; +} + +/* * Return the CPU id as a raw string. * * Each architecture should provide a more precise id string that @@ -552,15 +585,18 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name, */ i = 0; while (1) { - const char *pname; pe = &map->table[i++]; if (!pe->name) break; - pname = pe->pmu ? pe->pmu : "cpu"; - if (strncmp(pname, name, strlen(pname))) - continue; + if (!is_pmu_core(name)) { + /* check for uncore devices */ + if (pe->pmu == NULL) + continue; + if (strncmp(pe->pmu, name, strlen(pe->pmu))) + continue; + } /* need type casts to override 'const' */ __perf_pmu__new_alias(head, NULL, (char *)pe->name, -- 1.8.1.4