Received: by 2002:ac8:1418:0:b0:3ab:920c:4c8b with SMTP id k24csp434432qtj; Thu, 19 Jan 2023 08:06:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXsF+TkZgoQbheSRXzhs81CjPY8MoEm66uiRjCMrlDPXUuFDGJUGUxKgrSYZzeQ2Ph0tjH+D X-Received: by 2002:a17:90a:ac0c:b0:227:1a22:d182 with SMTP id o12-20020a17090aac0c00b002271a22d182mr12362875pjq.42.1674144368767; Thu, 19 Jan 2023 08:06:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674144368; cv=none; d=google.com; s=arc-20160816; b=nbhL/4LUCkMosCux7weNl1JjcLSVKLt08DzwHnI1dDCSNmft/MshMuKEfP7C0MMqoc whP6lxbxV8jgvFFrR9pbP7SI5KayeXv64adRNvUO5fyzhSSzdmk8+Fi52zAHNOF8i4Hi HM/aVSOs6Qyk1WT/3GFobMKGmwI3hs5icSow0TawKH1kkF6GltIT94NnzPNApOfJJnpu xtzYdA3IPAI+Im5RS7bEw+5SOX0NqK1oUL0JBAYFg2YYIAf7PONVdsq7IEpC3lTldA0w bLrNtrp2vYQNdx1+IGBRx2xt4/0KlPpqizfzPuRGVMD5XbGi1d0WzYFWRWHjMKVdsJkC CMFw== 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=zs6Hc6D42RqBpFvzqp/Dgn1W2VtoY74YxW8la2qUoAQUo5x2c0u0sTykhXYH6kNHJp vBZA596UvmnaEN4xAGqXcVTkP+++2iwGu1RVg+MMwdol7eaTetVQU6V5LQ/9UPAkSR5a O0/KBGWPh6pUFt1ID3TjQruJYgE7wjNp6CxM8G8Ac7xhYYwrq1LNDQT4DEODq1W928Fk kNk0SJLKTvdcOiTPomyf4ouAQ2oSuEFGmlCkUoob5bC9lrZMSLwtFrT8jUqXoEX305Gz YL4WBqS4QKXfuj28bmP+xdPzyJh3l+FuHJAAFL+hvYcGq77xgRDt967RdKciskvKJxC2 xgYg== 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 n14-20020a17090ade8e00b002262a74af32si5415942pjv.40.2023.01.19.08.06.02; Thu, 19 Jan 2023 08:06:08 -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 S231319AbjASPqW (ORCPT + 45 others); Thu, 19 Jan 2023 10:46:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231335AbjASPqG (ORCPT ); Thu, 19 Jan 2023 10:46:06 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD85786EE3; Thu, 19 Jan 2023 07:46:03 -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 190C81FB; Thu, 19 Jan 2023 07:46:45 -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 8D0623F445; Thu, 19 Jan 2023 07:46:00 -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 v4 3/8] perf: Remove remaining duplication of bus/event_source/devices/... Date: Thu, 19 Jan 2023 15:43:02 +0000 Message-Id: <20230119154308.3815108-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119154308.3815108-1-james.clark@arm.com> References: <20230119154308.3815108-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 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); -- 2.25.1