shuffle.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright(c) 2018 Intel Corporation. All rights reserved.
  3. #ifndef _MM_SHUFFLE_H
  4. #define _MM_SHUFFLE_H
  5. #include <linux/jump_label.h>
  6. #define SHUFFLE_ORDER (MAX_ORDER-1)
  7. #ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR
  8. DECLARE_STATIC_KEY_FALSE(page_alloc_shuffle_key);
  9. extern void __shuffle_free_memory(pg_data_t *pgdat);
  10. extern bool shuffle_pick_tail(void);
  11. static inline void shuffle_free_memory(pg_data_t *pgdat)
  12. {
  13. if (!static_branch_unlikely(&page_alloc_shuffle_key))
  14. return;
  15. __shuffle_free_memory(pgdat);
  16. }
  17. extern void __shuffle_zone(struct zone *z);
  18. static inline void shuffle_zone(struct zone *z)
  19. {
  20. if (!static_branch_unlikely(&page_alloc_shuffle_key))
  21. return;
  22. __shuffle_zone(z);
  23. }
  24. static inline bool is_shuffle_order(int order)
  25. {
  26. if (!static_branch_unlikely(&page_alloc_shuffle_key))
  27. return false;
  28. return order >= SHUFFLE_ORDER;
  29. }
  30. #else
  31. static inline bool shuffle_pick_tail(void)
  32. {
  33. return false;
  34. }
  35. static inline void shuffle_free_memory(pg_data_t *pgdat)
  36. {
  37. }
  38. static inline void shuffle_zone(struct zone *z)
  39. {
  40. }
  41. static inline bool is_shuffle_order(int order)
  42. {
  43. return false;
  44. }
  45. #endif
  46. #endif /* _MM_SHUFFLE_H */