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: <20200422114122.GG962614@krava>
Date:   Wed, 22 Apr 2020 13:41:22 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     John Garry <john.garry@...wei.com>
Cc:     peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
        mark.rutland@....com, alexander.shishkin@...ux.intel.com,
        namhyung@...nel.org, will@...nel.org, ak@...ux.intel.com,
        linuxarm@...wei.com, linux-kernel@...r.kernel.org,
        qiangqing.zhang@....com, irogers@...gle.com, robin.murphy@....com,
        zhangshaokun@...ilicon.com, linux-arm-kernel@...ts.infradead.org
Subject: Re: [RFC PATCH v2 07/13] perf pmu: Add pmu_id()

On Fri, Apr 17, 2020 at 06:41:18PM +0800, John Garry wrote:
> Add a function to read the PMU id sysfs entry. We only do it for uncore
> PMUs where this would be relevant.
> 
> Signed-off-by: John Garry <john.garry@...wei.com>
> ---
>  tools/perf/util/pmu.c | 36 ++++++++++++++++++++++++++++++++++++
>  tools/perf/util/pmu.h |  1 +
>  2 files changed, 37 insertions(+)
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index ef6a63f3d386..6a67c6a28d08 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -594,6 +594,7 @@ static struct perf_cpu_map *__pmu_cpumask(const char *path)
>   * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64)
>   * may have a "cpus" file.
>   */
> +#define CPUS_TEMPLATE_ID	"%s/bus/event_source/devices/%s/identifier"
>  #define CPUS_TEMPLATE_UNCORE	"%s/bus/event_source/devices/%s/cpumask"
>  #define CPUS_TEMPLATE_CPU	"%s/bus/event_source/devices/%s/cpus"
>  
> @@ -632,6 +633,39 @@ static bool pmu_is_uncore(const char *name)
>  	return file_available(path);
>  }
>  
> +static char *pmu_id(const char *name)
> +{
> +	char path[PATH_MAX], *id;
> +	const char *sysfs;
> +	FILE *file;
> +	int n;
> +
> +	sysfs = sysfs__mountpoint();
> +	snprintf(path, PATH_MAX, CPUS_TEMPLATE_ID, sysfs, name);
> +
> +	id = malloc(PATH_MAX);
> +	if (!id)
> +		return NULL;
> +
> +	file = fopen(path, "r");
> +	if (!file) {
> +		free(id);
> +		return NULL;
> +	}
> +
> +	n = fscanf(file, "%s", id);
> +
> +	fclose(file);
> +
> +	if (!n) {
> +		free(id);
> +		return NULL;
> +	}
> +
> +	return id;
> +}

I still need to go through this patchset in more detail,
but just quick note, that we have sysfs__read_str that you
could use in here

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ