RE: Lookaside cache with high volume of objects hangs the kernel on destruction (deadlock)
From: Thomas Gleixner <hidden>
Date: 2012-07-09 13:40:27
Chris, On Mon, 9 Jul 2012, Thomas Gleixner wrote:
On Fri, 6 Jul 2012, PRINGLE Chris wrote:quoted
It worries me a bit because this could potentially go wrong during runtime if the kernel ever reaps the lookaside cache for memory; this will then crash the entire system.Found the root cause, working on a fix.
Does the patch below work for you? Thanks, tglx Index: linux-stable-rt/mm/slab.c ===================================================================
--- linux-stable-rt.orig/mm/slab.c
+++ linux-stable-rt/mm/slab.c@@ -743,8 +743,26 @@ slab_on_each_cpu(void (*func)(void *arg, { unsigned int i; + get_cpu_light(); for_each_online_cpu(i) func(arg, i); + put_cpu_light(); +} + +static void lock_slab_on(unsigned int cpu) +{ + if (cpu == smp_processor_id()) + local_lock_irq(slab_lock); + else + local_spin_lock_irq(slab_lock, &per_cpu(slab_lock, cpu).lock); +} + +static void unlock_slab_on(unsigned int cpu) +{ + if (cpu == smp_processor_id()) + local_unlock_irq(slab_lock); + else + local_spin_unlock_irq(slab_lock, &per_cpu(slab_lock, cpu).lock); } #endif
@@ -2692,10 +2710,10 @@ static void do_drain(void *arg, int cpu) { LIST_HEAD(tmp); - spin_lock_irq(&per_cpu(slab_lock, cpu).lock); + lock_slab_on(cpu); __do_drain(arg, cpu); list_splice_init(&per_cpu(slab_free_list, cpu), &tmp); - spin_unlock_irq(&per_cpu(slab_lock, cpu).lock); + unlock_slab_on(cpu); free_delayed(&tmp); } #endif
@@ -4163,9 +4181,9 @@ static void do_ccupdate_local(void *info #else static void do_ccupdate_local(void *info, int cpu) { - spin_lock_irq(&per_cpu(slab_lock, cpu).lock); + lock_slab_on(cpu); __do_ccupdate_local(info, cpu); - spin_unlock_irq(&per_cpu(slab_lock, cpu).lock); + unlock_slab_on(cpu); } #endif