aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/util/cacheline.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2019-08-27 10:22:25 +0200
committerIngo Molnar <mingo@kernel.org>2019-08-27 10:22:25 +0200
commit794b8bedca9341569e1081bc880e7ea209dbca5c (patch)
treeaccdfe136daf45dea3ee62567a53ae2bfb0f7fd8 /tools/perf/util/cacheline.c
parent39152ee51b77851689f9b23fde6f610d13566c39 (diff)
parent74a1e863eb73dcc9f069b671dfb40650f3832116 (diff)
Merge tag 'perf-core-for-mingo-5.4-20190826' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: perf report: Andi Kleen: - Make --ns time sort key output column wide enough for nanoseconds. perf script: Gustavo A. R. Silva: - Fix memory leaks in list_scripts() perf tests: James Clark: - Fixes hang in zstd compression test by changing the source of random data. perf trace: Arnaldo Carvalho de Melo: - augmented_raw_syscalls.c BPF helper improvements. Benjamin Peterson: - Fix off-by-one error in ioctl cmd->string table. libperf: Jiri Olsa: - Move most PERF_RECORD_ structs to perf/event.h. headers: Arnaldo Carvalho de Melo: - Move cacheline related routines to separate source files. - Move record_opts and other record declarations to separate files. - Explicitly add some more needed headers here and there. Souptick Joarder: - Remove some duplicate include directives. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/cacheline.c')
-rw-r--r--tools/perf/util/cacheline.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/perf/util/cacheline.c b/tools/perf/util/cacheline.c
new file mode 100644
index 000000000000..9361d3f61f75
--- /dev/null
+++ b/tools/perf/util/cacheline.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "cacheline.h"
+#include "../perf.h"
+#include <unistd.h>
+
+#ifdef _SC_LEVEL1_DCACHE_LINESIZE
+#define cache_line_size(cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
+#else
+#include <api/fs/fs.h>
+#include "debug.h"
+static void cache_line_size(int *cacheline_sizep)
+{
+ if (sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", cacheline_sizep))
+ pr_debug("cannot determine cache line size");
+}
+#endif
+
+int cacheline_size(void)
+{
+ static int size;
+
+ if (!size)
+ cache_line_size(&size);
+
+ return size;
+}