lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y6VGWm0LtiVNvTmI@leoy-yangtze.lan>
Date:   Fri, 23 Dec 2022 14:10:34 +0800
From:   Leo Yan <leo.yan@...aro.org>
To:     James Clark <james.clark@....com>
Cc:     linux-perf-users@...r.kernel.org, tanmay@...vell.com,
        sgoutham@...vell.com, gcherian@...vell.com, lcherian@...vell.com,
        bbhushan2@...vell.com,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Mike Leach <mike.leach@...aro.org>,
        John Garry <john.g.garry@...cle.com>,
        Will Deacon <will@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>, coresight@...ts.linaro.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/7] perf: Remove remaining duplication of
 bus/event_source/devices/...

On Thu, Dec 22, 2022 at 04:03:23PM +0000, James Clark wrote:
> Use the new perf_pmu__pathname_scnprintf() instead. No functional
> changes.
> 
> Signed-off-by: James Clark <james.clark@....com>

Reviewed-by: Leo Yan <leo.yan@...aro.org>

> ---
>  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);
>  
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ