page_idle.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef _LINUX_MM_PAGE_IDLE_H
  2. #define _LINUX_MM_PAGE_IDLE_H
  3. #include <linux/bitops.h>
  4. #include <linux/page-flags.h>
  5. #include <linux/page_ext.h>
  6. #ifdef CONFIG_IDLE_PAGE_TRACKING
  7. #ifdef CONFIG_64BIT
  8. static inline bool page_is_young(struct page *page)
  9. {
  10. return PageYoung(page);
  11. }
  12. static inline void set_page_young(struct page *page)
  13. {
  14. SetPageYoung(page);
  15. }
  16. static inline bool test_and_clear_page_young(struct page *page)
  17. {
  18. return TestClearPageYoung(page);
  19. }
  20. static inline bool page_is_idle(struct page *page)
  21. {
  22. return PageIdle(page);
  23. }
  24. static inline void set_page_idle(struct page *page)
  25. {
  26. SetPageIdle(page);
  27. }
  28. static inline void clear_page_idle(struct page *page)
  29. {
  30. ClearPageIdle(page);
  31. }
  32. #else /* !CONFIG_64BIT */
  33. /*
  34. * If there is not enough space to store Idle and Young bits in page flags, use
  35. * page ext flags instead.
  36. */
  37. extern struct page_ext_operations page_idle_ops;
  38. static inline bool page_is_young(struct page *page)
  39. {
  40. struct page_ext *page_ext = lookup_page_ext(page);
  41. if (unlikely(!page_ext))
  42. return false;
  43. return test_bit(PAGE_EXT_YOUNG, &page_ext->flags);
  44. }
  45. static inline void set_page_young(struct page *page)
  46. {
  47. struct page_ext *page_ext = lookup_page_ext(page);
  48. if (unlikely(!page_ext))
  49. return;
  50. set_bit(PAGE_EXT_YOUNG, &page_ext->flags);
  51. }
  52. static inline bool test_and_clear_page_young(struct page *page)
  53. {
  54. struct page_ext *page_ext = lookup_page_ext(page);
  55. if (unlikely(!page_ext))
  56. return false;
  57. return test_and_clear_bit(PAGE_EXT_YOUNG, &page_ext->flags);
  58. }
  59. static inline bool page_is_idle(struct page *page)
  60. {
  61. struct page_ext *page_ext = lookup_page_ext(page);
  62. if (unlikely(!page_ext))
  63. return false;
  64. return test_bit(PAGE_EXT_IDLE, &page_ext->flags);
  65. }
  66. static inline void set_page_idle(struct page *page)
  67. {
  68. struct page_ext *page_ext = lookup_page_ext(page);
  69. if (unlikely(!page_ext))
  70. return;
  71. set_bit(PAGE_EXT_IDLE, &page_ext->flags);
  72. }
  73. static inline void clear_page_idle(struct page *page)
  74. {
  75. struct page_ext *page_ext = lookup_page_ext(page);
  76. if (unlikely(!page_ext))
  77. return;
  78. clear_bit(PAGE_EXT_IDLE, &page_ext->flags);
  79. }
  80. #endif /* CONFIG_64BIT */
  81. #else /* !CONFIG_IDLE_PAGE_TRACKING */
  82. static inline bool page_is_young(struct page *page)
  83. {
  84. return false;
  85. }
  86. static inline void set_page_young(struct page *page)
  87. {
  88. }
  89. static inline bool test_and_clear_page_young(struct page *page)
  90. {
  91. return false;
  92. }
  93. static inline bool page_is_idle(struct page *page)
  94. {
  95. return false;
  96. }
  97. static inline void set_page_idle(struct page *page)
  98. {
  99. }
  100. static inline void clear_page_idle(struct page *page)
  101. {
  102. }
  103. #endif /* CONFIG_IDLE_PAGE_TRACKING */
  104. #endif /* _LINUX_MM_PAGE_IDLE_H */