added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / include / linux / page_cgroup.h
blob602cc1fdee90c152dc458642256b623ce8cbfa78
1 #ifndef __LINUX_PAGE_CGROUP_H
2 #define __LINUX_PAGE_CGROUP_H
4 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
5 #include <linux/bit_spinlock.h>
6 /*
7 * Page Cgroup can be considered as an extended mem_map.
8 * A page_cgroup page is associated with every page descriptor. The
9 * page_cgroup helps us identify information about the cgroup
10 * All page cgroups are allocated at boot or memory hotplug event,
11 * then the page cgroup for pfn always exists.
13 struct page_cgroup {
14 unsigned long flags;
15 struct mem_cgroup *mem_cgroup;
16 struct page *page;
17 struct list_head lru; /* per cgroup LRU list */
20 void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat);
21 void __init page_cgroup_init(void);
22 struct page_cgroup *lookup_page_cgroup(struct page *page);
24 enum {
25 /* flags for mem_cgroup */
26 PCG_LOCK, /* page cgroup is locked */
27 PCG_CACHE, /* charged as cache */
28 PCG_USED, /* this object is in use. */
31 #define TESTPCGFLAG(uname, lname) \
32 static inline int PageCgroup##uname(struct page_cgroup *pc) \
33 { return test_bit(PCG_##lname, &pc->flags); }
35 #define SETPCGFLAG(uname, lname) \
36 static inline void SetPageCgroup##uname(struct page_cgroup *pc)\
37 { set_bit(PCG_##lname, &pc->flags); }
39 #define CLEARPCGFLAG(uname, lname) \
40 static inline void ClearPageCgroup##uname(struct page_cgroup *pc) \
41 { clear_bit(PCG_##lname, &pc->flags); }
43 /* Cache flag is set only once (at allocation) */
44 TESTPCGFLAG(Cache, CACHE)
46 TESTPCGFLAG(Used, USED)
47 CLEARPCGFLAG(Used, USED)
49 static inline int page_cgroup_nid(struct page_cgroup *pc)
51 return page_to_nid(pc->page);
54 static inline enum zone_type page_cgroup_zid(struct page_cgroup *pc)
56 return page_zonenum(pc->page);
59 static inline void lock_page_cgroup(struct page_cgroup *pc)
61 bit_spin_lock(PCG_LOCK, &pc->flags);
64 static inline int trylock_page_cgroup(struct page_cgroup *pc)
66 return bit_spin_trylock(PCG_LOCK, &pc->flags);
69 static inline void unlock_page_cgroup(struct page_cgroup *pc)
71 bit_spin_unlock(PCG_LOCK, &pc->flags);
74 #else /* CONFIG_CGROUP_MEM_RES_CTLR */
75 struct page_cgroup;
77 static inline void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat)
81 static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
83 return NULL;
86 static inline void page_cgroup_init(void)
90 #endif
92 #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
93 #include <linux/swap.h>
94 extern struct mem_cgroup *
95 swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem);
96 extern struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent);
97 extern int swap_cgroup_swapon(int type, unsigned long max_pages);
98 extern void swap_cgroup_swapoff(int type);
99 #else
100 #include <linux/swap.h>
102 static inline
103 struct mem_cgroup *swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem)
105 return NULL;
108 static inline
109 struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent)
111 return NULL;
114 static inline int
115 swap_cgroup_swapon(int type, unsigned long max_pages)
117 return 0;
120 static inline void swap_cgroup_swapoff(int type)
122 return;
125 #endif
126 #endif