All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thp+memcg-numa: fix BUG at include/linux/mm.h:370!
@ 2011-03-14  8:08 ` Hugh Dickins
  0 siblings, 0 replies; 28+ messages in thread
From: Hugh Dickins @ 2011-03-14  8:08 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrea Arcangeli, Andrew Morton, David Rientjes, linux-kernel, linux-mm

THP's collapse_huge_page() has an understandable but ugly difference
in when its huge page is allocated: inside if NUMA but outside if not.
It's hardly surprising that the memcg failure path forgot that, freeing
the page in the non-NUMA case, then hitting a VM_BUG_ON in get_page()
(or even worse, using the freed page).

Signed-off-by: Hugh Dickins <hughd@google.com>
---

 mm/huge_memory.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- 2.6.38-rc8/mm/huge_memory.c	2011-03-08 09:27:16.000000000 -0800
+++ linux/mm/huge_memory.c	2011-03-13 18:26:21.000000000 -0700
@@ -1762,6 +1762,10 @@ static void collapse_huge_page(struct mm
 #ifndef CONFIG_NUMA
 	VM_BUG_ON(!*hpage);
 	new_page = *hpage;
+	if (unlikely(mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL))) {
+		up_read(&mm->mmap_sem);
+		return;
+	}
 #else
 	VM_BUG_ON(*hpage);
 	/*
@@ -1781,12 +1785,12 @@ static void collapse_huge_page(struct mm
 		*hpage = ERR_PTR(-ENOMEM);
 		return;
 	}
-#endif
 	if (unlikely(mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL))) {
 		up_read(&mm->mmap_sem);
 		put_page(new_page);
 		return;
 	}
+#endif
 
 	/* after allocating the hugepage upgrade to mmap_sem write mode */
 	up_read(&mm->mmap_sem);

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2011-04-01 21:22 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-14  8:08 [PATCH] thp+memcg-numa: fix BUG at include/linux/mm.h:370! Hugh Dickins
2011-03-14  8:08 ` Hugh Dickins
2011-03-14 15:25 ` Minchan Kim
2011-03-14 15:25   ` Minchan Kim
2011-03-14 15:52 ` Andrea Arcangeli
2011-03-14 15:52   ` Andrea Arcangeli
2011-03-14 16:37   ` Hugh Dickins
2011-03-14 16:37     ` Hugh Dickins
2011-03-14 16:56     ` Linus Torvalds
2011-03-14 16:56       ` Linus Torvalds
2011-03-14 17:17       ` Andrea Arcangeli
2011-03-14 17:17         ` Andrea Arcangeli
2011-03-14 19:58         ` Johannes Weiner
2011-03-14 19:58           ` Johannes Weiner
2011-03-14 23:42           ` KAMEZAWA Hiroyuki
2011-03-14 23:42             ` KAMEZAWA Hiroyuki
2011-04-01 21:21           ` Andrea Arcangeli
2011-04-01 21:21             ` Andrea Arcangeli
2011-03-14 16:59     ` [PATCH] mm: PageBuddy and mapcount underflows robustness Andrea Arcangeli
2011-03-14 16:59       ` Andrea Arcangeli
2011-03-14 17:30       ` Linus Torvalds
2011-03-14 17:30         ` Linus Torvalds
2011-03-17 23:16         ` Andrea Arcangeli
2011-03-17 23:16           ` Andrea Arcangeli
2011-03-18 21:34           ` Hugh Dickins
2011-03-18 21:34             ` Hugh Dickins
2011-03-23 22:58             ` [stable] " Greg KH
2011-03-23 22:58               ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.