Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf cacheline: Move cacheline related routines to separate files

To disentangle util/sort.h a bit more.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-6kbf2cauas06rbqp15pyter5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+50 -33
+1
tools/perf/builtin-c2c.c
··· 26 26 #include "hist.h" 27 27 #include "sort.h" 28 28 #include "tool.h" 29 + #include "cacheline.h" 29 30 #include "data.h" 30 31 #include "event.h" 31 32 #include "evlist.h"
+1
tools/perf/util/Build
··· 1 1 perf-y += annotate.o 2 2 perf-y += block-range.o 3 3 perf-y += build-id.o 4 + perf-y += cacheline.o 4 5 perf-y += config.o 5 6 perf-y += ctype.o 6 7 perf-y += db-export.o
+26
tools/perf/util/cacheline.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include "cacheline.h" 3 + #include "../perf.h" 4 + #include <unistd.h> 5 + 6 + #ifdef _SC_LEVEL1_DCACHE_LINESIZE 7 + #define cache_line_size(cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE) 8 + #else 9 + #include <api/fs/fs.h> 10 + #include "debug.h" 11 + static void cache_line_size(int *cacheline_sizep) 12 + { 13 + if (sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", cacheline_sizep)) 14 + pr_debug("cannot determine cache line size"); 15 + } 16 + #endif 17 + 18 + int cacheline_size(void) 19 + { 20 + static int size; 21 + 22 + if (!size) 23 + cache_line_size(&size); 24 + 25 + return size; 26 + }
+21
tools/perf/util/cacheline.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef PERF_CACHELINE_H 3 + #define PERF_CACHELINE_H 4 + 5 + #include <linux/compiler.h> 6 + 7 + int __pure cacheline_size(void); 8 + 9 + static inline u64 cl_address(u64 address) 10 + { 11 + /* return the cacheline of the address */ 12 + return (address & ~(cacheline_size() - 1)); 13 + } 14 + 15 + static inline u64 cl_offset(u64 address) 16 + { 17 + /* return the cacheline of the address */ 18 + return (address & (cacheline_size() - 1)); 19 + } 20 + 21 + #endif // PERF_CACHELINE_H
+1
tools/perf/util/sort.c
··· 6 6 #include <linux/time64.h> 7 7 #include "sort.h" 8 8 #include "hist.h" 9 + #include "cacheline.h" 9 10 #include "comm.h" 10 11 #include "map.h" 11 12 #include "symbol.h"
-12
tools/perf/util/sort.h
··· 204 204 return period * 100.0 / total_period; 205 205 } 206 206 207 - static inline u64 cl_address(u64 address) 208 - { 209 - /* return the cacheline of the address */ 210 - return (address & ~(cacheline_size() - 1)); 211 - } 212 - 213 - static inline u64 cl_offset(u64 address) 214 - { 215 - /* return the cacheline of the address */ 216 - return (address & (cacheline_size() - 1)); 217 - } 218 - 219 207 enum sort_mode { 220 208 SORT_MODE__NORMAL, 221 209 SORT_MODE__BRANCH,
-20
tools/perf/util/util.c
··· 43 43 44 44 unsigned int page_size; 45 45 46 - #ifdef _SC_LEVEL1_DCACHE_LINESIZE 47 - #define cache_line_size(cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE) 48 - #else 49 - static void cache_line_size(int *cacheline_sizep) 50 - { 51 - if (sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", cacheline_sizep)) 52 - pr_debug("cannot determine cache line size"); 53 - } 54 - #endif 55 - 56 - int cacheline_size(void) 57 - { 58 - static int size; 59 - 60 - if (!size) 61 - cache_line_size(&size); 62 - 63 - return size; 64 - } 65 - 66 46 int sysctl_perf_event_max_stack = PERF_MAX_STACK_DEPTH; 67 47 int sysctl_perf_event_max_contexts_per_stack = PERF_MAX_CONTEXTS_PER_STACK; 68 48
-1
tools/perf/util/util.h
··· 34 34 size_t hex_width(u64 v); 35 35 36 36 extern unsigned int page_size; 37 - int __pure cacheline_size(void); 38 37 39 38 int sysctl__max_stack(void); 40 39