[PATCH -mm] slub: fix cpu hotplug offline/online path

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Akinobu Mita
Date: Tuesday, October 9, 2007 - 9:13 am

This patch fixes the problem introduced by:
http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc8/2.6.23-rc8-mm2/b...

I got slub BUG report when I tried to do cpu hotplug/unplug
$ while true; do
	echo 0 > /sys/devices/system/cpu/cpu1/online
	echo 1 > /sys/devices/system/cpu/cpu1/online
done

This is because init_alloc_cpu_cpu() is called every time when the CPU is
going to be onlined but init_alloc_cpu_cpu() is not intented to be called
twice or more for same CPU. Then it breaks kmem_cache_cpu_free list for
the CPU.

This patch removes init_alloc_cpu_cpu() from cpu hotplug notifier. But
call it for each possible CPUs not only online CPUs at initialization time.

Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

---
 mm/slub.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: 2.6-mm/mm/slub.c
===================================================================
--- 2.6-mm.orig/mm/slub.c
+++ 2.6-mm/mm/slub.c
@@ -2029,7 +2029,7 @@ static int alloc_kmem_cache_cpus(struct 
 /*
  * Initialize the per cpu array.
  */
-static void init_alloc_cpu_cpu(int cpu)
+static void __init init_alloc_cpu_cpu(int cpu)
 {
 	int i;
 
@@ -2041,7 +2041,7 @@ static void __init init_alloc_cpu(void)
 {
 	int cpu;
 
-	for_each_online_cpu(cpu)
+	for_each_possible_cpu(cpu)
 		init_alloc_cpu_cpu(cpu);
   }
 
@@ -2973,7 +2973,6 @@ static int __cpuinit slab_cpuup_callback
 	switch (action) {
 	case CPU_UP_PREPARE:
 	case CPU_UP_PREPARE_FROZEN:
-		init_alloc_cpu_cpu(cpu);
 		down_read(&slub_lock);
 		list_for_each_entry(s, &slab_caches, list)
 			s->cpu_slab[cpu] = alloc_kmem_cache_cpu(s, cpu,
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -mm] slub: fix cpu hotplug offline/online path, Akinobu Mita, (Tue Oct 9, 9:13 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Tue Oct 9, 11:46 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Tue Oct 9, 11:50 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Tue Oct 9, 12:15 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Wed Oct 10, 10:39 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Thu Oct 11, 9:46 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Akinobu Mita, (Thu Oct 11, 10:24 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Thu Oct 11, 10:36 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Thu Oct 11, 10:37 am)