cacheline.h 708 B

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