From patchwork Thu Dec 22 16:03:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 35866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp35052wrn; Thu, 22 Dec 2022 08:09:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsgqRkJhVmnm5SR6pYo4fN3kIGAWEwZ1HWTWv7pQmOPp5/HyAhoUJARZDsezl7yt2jKspGP X-Received: by 2002:a62:198a:0:b0:577:d10d:6eab with SMTP id 132-20020a62198a000000b00577d10d6eabmr7232695pfz.21.1671725376114; Thu, 22 Dec 2022 08:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671725376; cv=none; d=google.com; s=arc-20160816; b=QK9XIOzlqHL7UoyMaYjZj7KTpJDm+XoXswICMhDhWpZbDsArWqZ4Ir3vfg84RQmakl akuXPckPzF4UW1ZzoOLRzqLxYKFHuPuYTDSnkgLTi5xQsykDo51Iiair0OaYIiH/CC8H OCSP1jhUaRqp8jw+eNB5Rla4iponXpqjTJg63lN47dFF+FZq+ZoI8enPLAh69MCZPdqD 14aXoeQGp/cdHXRA9auEq9HH73tokpaHrrEb7DPhOvTzvqcb2KlLo5jgUG5T2EaVqY+X fxFKZ+ScuRack+jKZ7560kUdMPGhC9Y01171FzEdUojj7YjZ+yyj7OGW7C/iWw73GQwT xpXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/8H13aJ0M2pGDx5KItC/HEyEzo9+JzYiRL1t7MmE4y4=; b=dpX0+k5orpDByiHB8bSFYWBNWocjsu/pefZRtUXwF6+2eKdZEM4zhOWrW32GeqkO0T it083ZkTfdurVGH12rBccr5zXr6DTjYiW65wyZ4bgoJrwIIWCY5IxIBmhBurE8UzOvi5 l9hb+/U3XfC0ulbxLnQcOSKH1cKzEo8tzqESTg2V0YPqW13upU5CIWsdP9Sq21/q3gyv A/jpdc6gbx0XaShFcLLdjr1HFFbsRX//jlPA7Mv2HRtkH+22SAwZoAUuJsdIlxl4cMKV 9RYPGWdotaZ7dgC6C5zlMvByLBmeY0wYxkEibssV6X+2ob0qCVrOqxZWSbjQ3wp0V5Y4 Zarg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a056a0024c200b00574f3820920si1006229pfv.331.2022.12.22.08.09.23; Thu, 22 Dec 2022 08:09:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235195AbiLVQHl (ORCPT + 99 others); Thu, 22 Dec 2022 11:07:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234880AbiLVQHd (ORCPT ); Thu, 22 Dec 2022 11:07:33 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82B242EFAB; Thu, 22 Dec 2022 08:07:29 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 55E912F4; Thu, 22 Dec 2022 08:08:10 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 591F33FAFB; Thu, 22 Dec 2022 08:07:26 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org, tanmay@marvell.com Cc: sgoutham@marvell.com, gcherian@marvell.com, lcherian@marvell.com, bbhushan2@marvell.com, James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] perf: Remove remaining duplication of bus/event_source/devices/... Date: Thu, 22 Dec 2022 16:03:23 +0000 Message-Id: <20221222160328.3639989-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221222160328.3639989-1-james.clark@arm.com> References: <20221222160328.3639989-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752931107939336886?= X-GMAIL-MSGID: =?utf-8?q?1752931107939336886?= Use the new perf_pmu__pathname_scnprintf() instead. No functional changes. Signed-off-by: James Clark Reviewed-by: Leo Yan --- tools/perf/util/pmu.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index faaeec1e15aa..15b852b3c401 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -574,8 +574,6 @@ static void pmu_read_sysfs(void) * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) * may have a "cpus" file. */ -#define SYS_TEMPLATE_ID "./bus/event_source/devices/%s/identifier" - static struct perf_cpu_map *pmu_cpumask(char *name) { struct perf_cpu_map *cpus; @@ -616,9 +614,9 @@ static char *pmu_id(const char *name) char path[PATH_MAX], *str; size_t len; - snprintf(path, PATH_MAX, SYS_TEMPLATE_ID, name); + perf_pmu__pathname_scnprintf(path, PATH_MAX, name, "identifier"); - if (sysfs__read_str(path, &str, &len) < 0) + if (filename__read_str(path, &str, &len) < 0) return NULL; str[len - 1] = 0; /* remove line feed */ @@ -864,16 +862,11 @@ pmu_find_alias_name(const char *name __maybe_unused) return NULL; } -static int pmu_max_precise(const char *name) +static int pmu_max_precise(struct perf_pmu *pmu) { - char path[PATH_MAX]; int max_precise = -1; - scnprintf(path, PATH_MAX, - "bus/event_source/devices/%s/caps/max_precise", - name); - - sysfs__read_int(path, &max_precise); + perf_pmu__scan_file(pmu, "caps/max_precise", "%d", &max_precise); return max_precise; } @@ -932,7 +925,7 @@ static struct perf_pmu *pmu_lookup(const char *lookup_name) pmu->is_uncore = pmu_is_uncore(name); if (pmu->is_uncore) pmu->id = pmu_id(name); - pmu->max_precise = pmu_max_precise(name); + pmu->max_precise = pmu_max_precise(pmu); pmu_add_cpu_aliases(&aliases, pmu); pmu_add_sys_aliases(&aliases, pmu);