Merge tag 'block-5.9-2020-08-14' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / perf / util / cacheline.c
blobe98b5250a517d4b60b8f8b1a4e12124a502bb0bb
1 // SPDX-License-Identifier: GPL-2.0
2 #include "cacheline.h"
3 #include <unistd.h>
5 #ifdef _SC_LEVEL1_DCACHE_LINESIZE
6 #define cache_line_size(cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
7 #else
8 #include <api/fs/fs.h>
9 #include "debug.h"
10 static void cache_line_size(int *cacheline_sizep)
12 if (sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", cacheline_sizep))
13 pr_debug("cannot determine cache line size");
15 #endif
17 int cacheline_size(void)
19 static int size;
21 if (!size)
22 cache_line_size(&size);
24 return size;