From patchwork Tue Jan 3 16:20:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 38500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4703935wrt; Tue, 3 Jan 2023 08:23:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXu2o7nl2ibZnoX6o0iNE9f3l6gHa2r2JI/v05UDzq7LM4H66/YYvX8lHSfm3YXoUanXdw2g X-Received: by 2002:a17:903:1092:b0:189:e757:ff1 with SMTP id u18-20020a170903109200b00189e7570ff1mr37930558pld.47.1672763010455; Tue, 03 Jan 2023 08:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672763010; cv=none; d=google.com; s=arc-20160816; b=o86w9F2m1vzTnsRtxivdArZjLNe70CSMuBJo20rv5h1QTzyO1OkWj4+ZOtU+Ek0imk AunNGBZjfelBVQVl8BAdCuZ8UOgPalwcUqOoxBV2mT2igdyvk4wp7KAUCv0z1b1TZMcN mofI53HvV7+TnweODW+zrFffmURnuPT5o8CfvJ/IM3T2cGuG6+bYFcgkkqHeaxWtEqTE Oizr35IK1VfqWCJy+RlPxUV9u8Dx1LURQ7go9f69voyPjMVoxRbY9W2q1XkjQyouxV5A c1aX4yRgV4nFodaWOk8RrxvMWtLumgcmvmU/trCsbivdsoQ+zGJYkQhGed2jaINDS4Yt eL1g== 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=a9COYZ3QcyXVQ11l7PyvfZF7W9TPdNQ+RTIjqSsURMI=; b=m4g/Dk9qm8NuCkm/lbl7den4HfUhbGWS7Cy8zcrFrmEP1W+YG61RN6mNNMhisLE4la 0g+aMDGH7SyzJU7KlQGZRYOY01yl9dd/7uQfDupSKpFEOkRPHRPbVzQxP39z/n8eRRMl E5yrCBNlvMcrbfy6bzX1ulEomoC7qR+CF7zux9Lgw1JQ2M2dr9gr1jTSvzeNaI50/Kc6 ysqf8p/eZZhkZTsVoZJUb0gwKWFYjeDoSEGyyLnzb/ji4u3BkWz4+OzFFQr5yj9qlkhs rz0iBBucZPj8XcP2AYP7EX+WegGTfS5f+/cbwyuzdf/Mi6RLmDxfmco7D6BWko1uZzcw +pZw== 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 i5-20020a170902c94500b00189bae9d928si36269675pla.162.2023.01.03.08.23.18; Tue, 03 Jan 2023 08:23:30 -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 S238168AbjACQWb (ORCPT + 99 others); Tue, 3 Jan 2023 11:22:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238221AbjACQWA (ORCPT ); Tue, 3 Jan 2023 11:22:00 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C78CF13CF4; Tue, 3 Jan 2023 08:21:32 -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 3B47F1570; Tue, 3 Jan 2023 08:22:14 -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 9C4EF3F71A; Tue, 3 Jan 2023 08:21:29 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org, tanmay@marvell.com, leo.yan@linaro.org, mike.leach@linaro.org Cc: sgoutham@marvell.com, gcherian@marvell.com, lcherian@marvell.com, bbhushan2@marvell.com, James Clark , Mathieu Poirier , Suzuki K Poulose , 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 v3 3/7] perf: Remove remaining duplication of bus/event_source/devices/... Date: Tue, 3 Jan 2023 16:20:37 +0000 Message-Id: <20230103162042.423694-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230103162042.423694-1-james.clark@arm.com> References: <20230103162042.423694-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?1754019146484820239?= X-GMAIL-MSGID: =?utf-8?q?1754019146484820239?= Use the new perf_pmu__pathname_scnprintf() instead. No functional changes. Reviewed-by: Leo Yan Signed-off-by: James Clark --- 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 683cc7953f11..7a4e243a370d 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(const char *name) { struct perf_cpu_map *cpus; @@ -618,9 +616,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, sizeof(path), 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 */ @@ -866,16 +864,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; } @@ -934,7 +927,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);