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]
Date:	Fri, 23 May 2014 18:54:06 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Don Zickus <dzickus@...hat.com>
Cc:	acme@...stprotocols.net, peterz@...radead.org,
	LKML <linux-kernel@...r.kernel.org>, namhyung@...il.com,
	eranian@...gle.com, Andi Kleen <andi@...stfloor.org>
Subject: Re: [PATCH 6/7] perf: Add support to dynamically get cacheline size

On Mon, May 19, 2014 at 03:13:52PM -0400, Don Zickus wrote:
> Different arches may have different cacheline sizes.  Look it up and set
> a global variable for reference.
> 
> Signed-off-by: Don Zickus <dzickus@...hat.com>
> ---
>  tools/perf/util/cpumap.c | 31 +++++++++++++++++++++++++++++++
>  tools/perf/util/cpumap.h | 12 ++++++++++++
>  tools/perf/util/sort.c   |  3 +++
>  3 files changed, 46 insertions(+)
> 
> diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
> index c4e55b7..d833238 100644
> --- a/tools/perf/util/cpumap.c
> +++ b/tools/perf/util/cpumap.c
> @@ -477,3 +477,34 @@ int cpu__setup_cpunode_map(void)
>  	closedir(dir1);
>  	return 0;
>  }
> +
> +int cpu__setup_cacheline_size(void)
> +{
> +	const char *mnt;
> +	char path[PATH_MAX];
> +	int n, ret, size;
> +	FILE *fp;
> +	
> +
> +	mnt = sysfs__mountpoint();
> +	if (!mnt)
> +		return -1;
> +
> +	n = snprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu0/cache/index0/coherency_line_size", mnt);
> +	if (n == PATH_MAX) {
> +		pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX);
> +		return -1;
> +	}
> +
> +	fp = fopen(path, "r");
> +	if (!fp)
> +		return -1;
> +	ret = fscanf(fp, "%d", &size);
> +	fclose(fp);
> +	if (ret != 1)
> +		return -1;

you can use filename__read_int

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ