page_reporting.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _MM_PAGE_REPORTING_H
  3. #define _MM_PAGE_REPORTING_H
  4. #include <linux/mmzone.h>
  5. #include <linux/pageblock-flags.h>
  6. #include <linux/page-isolation.h>
  7. #include <linux/jump_label.h>
  8. #include <linux/slab.h>
  9. #include <linux/pgtable.h>
  10. #include <linux/scatterlist.h>
  11. #define PAGE_REPORTING_MIN_ORDER pageblock_order
  12. #ifdef CONFIG_PAGE_REPORTING
  13. DECLARE_STATIC_KEY_FALSE(page_reporting_enabled);
  14. void __page_reporting_notify(void);
  15. static inline bool page_reported(struct page *page)
  16. {
  17. return static_branch_unlikely(&page_reporting_enabled) &&
  18. PageReported(page);
  19. }
  20. /**
  21. * page_reporting_notify_free - Free page notification to start page processing
  22. *
  23. * This function is meant to act as a screener for __page_reporting_notify
  24. * which will determine if a give zone has crossed over the high-water mark
  25. * that will justify us beginning page treatment. If we have crossed that
  26. * threshold then it will start the process of pulling some pages and
  27. * placing them in the batch list for treatment.
  28. */
  29. static inline void page_reporting_notify_free(unsigned int order)
  30. {
  31. /* Called from hot path in __free_one_page() */
  32. if (!static_branch_unlikely(&page_reporting_enabled))
  33. return;
  34. /* Determine if we have crossed reporting threshold */
  35. if (order < PAGE_REPORTING_MIN_ORDER)
  36. return;
  37. /* This will add a few cycles, but should be called infrequently */
  38. __page_reporting_notify();
  39. }
  40. #else /* CONFIG_PAGE_REPORTING */
  41. #define page_reported(_page) false
  42. static inline void page_reporting_notify_free(unsigned int order)
  43. {
  44. }
  45. #endif /* CONFIG_PAGE_REPORTING */
  46. #endif /*_MM_PAGE_REPORTING_H */