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