aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index afdd406f618a..9e170d3c71e5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -140,11 +140,17 @@ struct mem_cgroup {
140 140
141/* 141/*
142 * We use the lower bit of the page->page_cgroup pointer as a bit spin 142 * We use the lower bit of the page->page_cgroup pointer as a bit spin
143 * lock. We need to ensure that page->page_cgroup is atleast two 143 * lock. We need to ensure that page->page_cgroup is at least two
144 * byte aligned (based on comments from Nick Piggin) 144 * byte aligned (based on comments from Nick Piggin). But since
145 * bit_spin_lock doesn't actually set that lock bit in a non-debug
146 * uniprocessor kernel, we should avoid setting it here too.
145 */ 147 */
146#define PAGE_CGROUP_LOCK_BIT 0x0 148#define PAGE_CGROUP_LOCK_BIT 0x0
147#define PAGE_CGROUP_LOCK (1 << PAGE_CGROUP_LOCK_BIT) 149#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
150#define PAGE_CGROUP_LOCK (1 << PAGE_CGROUP_LOCK_BIT)
151#else
152#define PAGE_CGROUP_LOCK 0x0
153#endif
148 154
149/* 155/*
150 * A page_cgroup page is associated with every page descriptor. The 156 * A page_cgroup page is associated with every page descriptor. The
@@ -271,19 +277,10 @@ static inline int page_cgroup_locked(struct page *page)
271 &page->page_cgroup); 277 &page->page_cgroup);
272} 278}
273 279
274void page_assign_page_cgroup(struct page *page, struct page_cgroup *pc) 280static void page_assign_page_cgroup(struct page *page, struct page_cgroup *pc)
275{ 281{
276 int locked; 282 VM_BUG_ON(!page_cgroup_locked(page));
277 283 page->page_cgroup = ((unsigned long)pc | PAGE_CGROUP_LOCK);
278 /*
279 * While resetting the page_cgroup we might not hold the
280 * page_cgroup lock. free_hot_cold_page() is an example
281 * of such a scenario
282 */
283 if (pc)
284 VM_BUG_ON(!page_cgroup_locked(page));
285 locked = (page->page_cgroup & PAGE_CGROUP_LOCK);
286 page->page_cgroup = ((unsigned long)pc | locked);
287} 284}
288 285
289struct page_cgroup *page_get_page_cgroup(struct page *page) 286struct page_cgroup *page_get_page_cgroup(struct page *page)