[PATCH] memory hotplug: run lru_add_drain_all() on each cpu

Gerald Schaefer
2008-12-03T21:25:32Z

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

offline_pages() calls lru_add_drain_all() followed by drain_all_pages().
While drain_all_pages() works on each cpu, lru_add_drain_all() only runs
on the current cpu for architectures w/o CONFIG_NUMA. This let us run
into the BUG_ON(!PageBuddy(page)) in __offline_isolated_pages() during
memory hotplug stress test on s390. The page in question was still on the
pcp list, because of a race with lru_add_drain_all() and drain_all_pages()
on different cpus.

This is fixed with this patch by adding CONFIG_MEMORY_HOTREMOVE to the
lru_add_drain_all() #ifdef, to let it run on each cpu.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>

---
mm/swap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6/mm/swap.c
===================================================================
--- linux-2.6.orig/mm/swap.c
+++ linux-2.6/mm/swap.c
@@ -299,7 +299,8 @@ void lru_add_drain(void)
put_cpu();
}

-#if defined(CONFIG_NUMA) || defined(CONFIG_UNEVICTABLE_LRU)
+#if defined(CONFIG_NUMA) || defined(CONFIG_UNEVICTABLE_LRU) || \
+ defined(CONFIG_MEMORY_HOTREMOVE)
static void lru_add_drain_per_cpu(struct work_struct *dummy)
{
lru_add_drain();