2012-10-25 13:10:54

by Peter Zijlstra

[permalink] [raw]
Subject: [PATCH 31/31] sched, numa, mm: Add memcg support to do_huge_pmd_numa_page()

From: Johannes Weiner <[email protected]>

[ Turned email suggestions into patch plus fixes. ]
Signed-off-by: Ingo Molnar <[email protected]>
---
mm/huge_memory.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

Index: tip/mm/huge_memory.c
===================================================================
--- tip.orig/mm/huge_memory.c
+++ tip/mm/huge_memory.c
@@ -742,6 +742,7 @@ void do_huge_pmd_numa_page(struct mm_str
unsigned int flags, pmd_t entry)
{
unsigned long haddr = address & HPAGE_PMD_MASK;
+ struct mem_cgroup *memcg = NULL;
struct page *new_page = NULL;
struct page *page = NULL;
int node, lru;
@@ -800,6 +801,8 @@ migrate:
if (!new_page)
goto alloc_fail;

+ mem_cgroup_prepare_migration(page, new_page, &memcg);
+
lru = PageLRU(page);

if (lru && isolate_lru_page(page)) /* does an implicit get_page() */
@@ -852,14 +855,19 @@ migrate:
put_page(page); /* drop the LRU isolation reference */

unlock_page(new_page);
+
+ mem_cgroup_end_migration(memcg, page, new_page, true);
+
unlock_page(page);
put_page(page); /* Drop the local reference */

return;

alloc_fail:
- if (new_page)
+ if (new_page) {
+ mem_cgroup_end_migration(memcg, page, new_page, false);
put_page(new_page);
+ }

unlock_page(page);