diff options
Diffstat (limited to 'tools/perf/util/cacheline.h')
-rw-r--r-- | tools/perf/util/cacheline.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/perf/util/cacheline.h b/tools/perf/util/cacheline.h new file mode 100644 index 000000000000..dec8c0fb1f4a --- /dev/null +++ b/tools/perf/util/cacheline.h | |||
@@ -0,0 +1,21 @@ | |||
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 | ||