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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Christoph Lameter <clameter@...>
Cc: <linux-kernel@...>, Andrew Morton <akpm@...>, Pekka Enberg <penberg@...>
Date: Thursday, October 11, 2007 - 10:36 am

On Wed, Oct 10, 2007 at 10:39:32AM -0700, Christoph Lameter wrote:


        case CPU_DEAD:
        case CPU_DEAD_FROZEN:
                down_read(&slub_lock);
                list_for_each_entry(s, &slab_caches, list) {
                        struct kmem_cache_cpu *c = get_cpu_slab(s, cpu);

                        local_irq_save(flags);
                        __flush_cpu_slab(s, cpu);
                        local_irq_restore(flags);
                        free_kmem_cache_cpu(c, cpu);
                        s->cpu_slab[cpu] = NULL; <----------------------
                }
                up_read(&slub_lock);
                break;

When CPU is offlined, cpu-hotplug notifier sets s->cpu_slab[cpu] = NULL.
This means get_cpu_slab() always return NULL when CPU is being onlined.
So I can't use get_cpu_slab to check whether kmem_cache_cpu_free
initalization for the CPU has already been done or not.


cpu-hotplug notifier by CPU_DEAD event frees kmem_cache_cpu structures
for the CPU being offlined. So we have 100 kmem_cache cpu structures
when the CPU will be onlined again.

But I agree that it is not so trivial. It is why I added the comment
/* Already initialized once */ in previous patch.

This is another approach for the fix.
Use cpumask to check whether kmem_cache_cpu_free initalization for
the CPU has already been done or not.

---
 mm/slub.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: 2.6-mm/mm/slub.c
===================================================================
--- 2.6-mm.orig/mm/slub.c
+++ 2.6-mm/mm/slub.c
@@ -1959,6 +1959,7 @@ static DEFINE_PER_CPU(struct kmem_cache_
 				kmem_cache_cpu)[NR_KMEM_CACHE_CPU];
 
 static DEFINE_PER_CPU(struct kmem_cache_cpu *, kmem_cache_cpu_free);
+static cpumask_t kmem_cach_cpu_free_init_once = CPU_MASK_NONE;
 
 static struct kmem_cache_cpu *alloc_kmem_cache_cpu(struct kmem_cache *s,
 							int cpu, gfp_t flags)
@@ -2033,8 +2034,13 @@ static void init_alloc_cpu_cpu(int cpu)
 {
 	int i;
 
+	if (cpu_isset(cpu, kmem_cach_cpu_free_init_once))
+		return;
+
 	for (i = NR_KMEM_CACHE_CPU - 1; i >= 0; i--)
 		free_kmem_cache_cpu(&per_cpu(kmem_cache_cpu, cpu)[i], cpu);
+
+	cpu_set(cpu, kmem_cach_cpu_free_init_once);
 }
 
 static void __init init_alloc_cpu(void)
-
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, 12:13 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Tue Oct 9, 2:46 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Wed Oct 10, 1:39 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Akinobu Mita, (Thu Oct 11, 10:36 am)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Thu Oct 11, 1:37 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Thu Oct 11, 12:46 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Thu Oct 11, 1:36 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Tue Oct 9, 2:50 pm)
Re: [PATCH -mm] slub: fix cpu hotplug offline/online path, Christoph Lameter, (Tue Oct 9, 3:15 pm)