Linux Audio

Check our new training course

Loading...
v5.4
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef PERF_CACHELINE_H
 3#define PERF_CACHELINE_H
 4
 5#include <linux/compiler.h>
 6
 7int __pure cacheline_size(void);
 8
 9static inline u64 cl_address(u64 address)
 
 
 
 
 
10{
 
 
 
 
 
11	/* return the cacheline of the address */
12	return (address & ~(cacheline_size() - 1));
13}
14
15static 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
v6.8
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef PERF_CACHELINE_H
 3#define PERF_CACHELINE_H
 4
 5#include <linux/compiler.h>
 6
 7int __pure cacheline_size(void);
 8
 9
10/*
11 * Some architectures have 'Adjacent Cacheline Prefetch' feature,
12 * which performs like the cacheline size being doubled.
13 */
14static inline u64 cl_address(u64 address, bool double_cl)
15{
16	u64 size = cacheline_size();
17
18	if (double_cl)
19		size *= 2;
20
21	/* return the cacheline of the address */
22	return (address & ~(size - 1));
23}
24
25static inline u64 cl_offset(u64 address, bool double_cl)
26{
27	u64 size = cacheline_size();
28
29	if (double_cl)
30		size *= 2;
31
32	/* return the offset inside cacheline */
33	return (address & (size - 1));
34}
35
36#endif // PERF_CACHELINE_H