18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef PERF_CACHELINE_H
38c2ecf20Sopenharmony_ci#define PERF_CACHELINE_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/compiler.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciint __pure cacheline_size(void);
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cistatic inline u64 cl_address(u64 address)
108c2ecf20Sopenharmony_ci{
118c2ecf20Sopenharmony_ci	/* return the cacheline of the address */
128c2ecf20Sopenharmony_ci	return (address & ~(cacheline_size() - 1));
138c2ecf20Sopenharmony_ci}
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistatic inline u64 cl_offset(u64 address)
168c2ecf20Sopenharmony_ci{
178c2ecf20Sopenharmony_ci	/* return the cacheline of the address */
188c2ecf20Sopenharmony_ci	return (address & (cacheline_size() - 1));
198c2ecf20Sopenharmony_ci}
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#endif // PERF_CACHELINE_H
22