Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2809565rwb; Fri, 20 Jan 2023 07:38:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8ayg2R0DZZZ3G3sb28pwJNrCimF6b88HoY1wlDvxQDT8zPNyCSWUPW349YFKVmKy7KIz2 X-Received: by 2002:a05:6402:360d:b0:46c:2c94:d30b with SMTP id el13-20020a056402360d00b0046c2c94d30bmr17810697edb.33.1674229091219; Fri, 20 Jan 2023 07:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674229091; cv=none; d=google.com; s=arc-20160816; b=cpy69TQUrezTa7iEJe3fI2+N2cUq7xajAT43mLvC0lOmSku18vSII3d6hbt72VT0CN 0/mQCN5DwZ1mWmrEivqvEvIriodmb0HeGUryJaK9Tv6GrddItb3KNi4kBs3oogrZyEsf maVxBXtn620j4uj/8dlJeoXZUkuwOmLP4mUZxZlh2oDL8XD1R6gh9lXxRet9GvneFfgB GD3NeYxYRBjK2IOTpLVbf7/KUTXNicDawSupq34Hgx0kEwTCENC8KpB9TJ/VacHdROAv DqiP6E/0NsjeGhqmOHJi3TEsLTXWSGpXZB9315nptm2zGl2w3LurmkKJIwcpQF9q/YJD UVJQ== 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=3Outt2+xjov5/wm0yQGWigEqcQLFBd7xRT/oWJYal+M=; b=Ej+ozSz6z1Uko+HovhSFV/vjl7bNhpYIrYiTafDx+L8sZj9RGGb6odJtPFTYFXfgbm xEFk74ZkpzD4BFNrgfy/yEvsIZNyD/1rih4FheC+ZYvdNZd/XMglsI1kQ3xtpSQYuoXA R5HtuK37tyDVm7RNOIuNoQW+2pqwA2y4a1VZOL3CwU7UrfGvAK5ccOEUC6wQccqj+CW4 b2Y64+ZFju3EpD61JFNtBfdcY82A+zeNGSqYU6B7Ae12exJBmekKm8Oa4kn/9615DiFZ 97fpLm95G/nePXWyPjGozsD0jmFQ+tJ1g6u45pVK2qvPtgzrFIrDBqjT8H/Kb9DV8QQq KNGw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020aa7cb8d000000b0047ae036876fsi38456924edt.59.2023.01.20.07.37.59; Fri, 20 Jan 2023 07:38:11 -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 S230186AbjATOuq (ORCPT + 49 others); Fri, 20 Jan 2023 09:50:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjATOuo (ORCPT ); Fri, 20 Jan 2023 09:50:44 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB2A513B; Fri, 20 Jan 2023 06:50:42 -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 577A5152B; Fri, 20 Jan 2023 06:38:47 -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 D1E673F67D; Fri, 20 Jan 2023 06:38:02 -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 v5 3/8] perf: Remove remaining duplication of bus/event_source/devices/... Date: Fri, 20 Jan 2023 14:36:56 +0000 Message-Id: <20230120143702.4035046-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120143702.4035046-1-james.clark@arm.com> References: <20230120143702.4035046-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 a771a5972fc5..23e1d70fa343 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -575,8 +575,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; @@ -619,9 +617,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 */ @@ -867,16 +865,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; } @@ -935,7 +928,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); -- 2.25.1