PATCH: Fix to slab.c for SMP (test9-pre7)
Subsystems (3)
Hi
In previous mails I reported that test9-preX (X>=3) freezes when running in SMP mmap001. I have found that the problem was in how was handing the slab cache by cpu. With this patch mmap001 returns to work (i.e. it loops a lot in the VM layer, but the same loops than in UP).
Linus, if you see no problems, please apply. (If you want the patch without the shrink_[id]_caches part, please, let me know).
This patch does:
- shrink_[id]_caches return the count of the freed pages (from ingo and marcelo patch)
- removes the ret variable in smp_call_function (it was unused)
- removes the slab_cache_drain_mask/slab_drain_local_cache and its references for the timer interrupt code. That calls are now done with smp_call_function, that lets us to simplify a lot the code (we don't need the cache_drain_wait queue anymore.
- Change the cache_drain_sem semaphore to cache_all_lock spinlock, as now we never sleep/schedule while holding it. The name is changed because it is not only used by the drain routines it is also used by the update ones.
- slab_drain_local_cache is divided in the functions:
slab_drain_local_cache
do_ccupdate_local
as we known a compile time _which_ part of the function we want to call.
- pass the spinlock calls inside slab_cache_all_sync, as they are needed only when calling that function. The wait queue is not needed anymore. This function used global variables to pass arguments to slab_drain_local_cache, that has been changed to use global arguments.
- do_ccupdate & drain_cpu_caches code has been refunded inside slab_cache_all_sync, as the same code except for one line.
- In the process, the net result are ~40 less lines of code
Thanks to Phillip Rumpf, Stephen Tweedie, Alan Cox, Ingo & the rest of the people that explained me the SMP/cross CPU mysteries.
Any comments, suggestions are welcome
Later, Juan.
arch/i386/kernel/smp.c +1 -2
@@ -464,7 +464,7 @@*/ {struct call_data_struct data; -int ret, cpus = smp_num_cpus-1 ; +int cpus = smp_num_cpus-1 ;if (!cpus)return 0 ;
@@ -485,7 +485,6 @@while (atomic_read (&data.started) != cpus)barrier (); - ret =0 ;if (wait)while (atomic_read (&data.finished) != cpus)barrier ();
fs/dcache.c +1 -7
@@ -572,14 +572,8 @@if (priority) count = dentry_stat.nr_unused / priority;prune_dcache (count); -/* FIXME: kmem_cache_shrink here should tell us -the number of pages freed, and it should -work in a __GFP_DMA/__GFP_HIGHMEM behaviour -to free only the interesting pages in -function of the needs of the current allocation. */ -kmem_cache_shrink (dentry_cache); -return 0 ; +return kmem_cache_shrink (dentry_cache); }#define NAME_ALLOC_LEN (len) ((len+16) & ~15)
fs/inode.c +1 -7
@@ -471,14 +471,8 @@if (priority) count = inodes_stat.nr_unused / priority;prune_icache (count); -/* FIXME: kmem_cache_shrink here should tell us -the number of pages freed, and it should -work in a __GFP_DMA/__GFP_HIGHMEM behaviour -to free only the interesting pages in -function of the needs of the current allocation. */ -kmem_cache_shrink (inode_cachep); -return 0 ; +return kmem_cache_shrink (inode_cachep); }/*
include/linux/slab.h +0 -8
@@ -76,14 +76,6 @@extern kmem_cache_t *fs_cachep;extern kmem_cache_t *sigact_cachep; -#ifdef CONFIG_SMP -extern unsigned long slab_cache_drain_mask; -extern void slab_drain_local_cache (void ); -#else -#define slab_cache_drain_mask 0 -#define slab_drain_local_cache () do { } while (0) -#endif -#endif /* __KERNEL__ */ #endif /* _LINUX_SLAB_H */
kernel/timer.c +0 -4
@@ -22,7 +22,6 @@#include <linux/smp_lock.h> #include <linux/interrupt.h> #include <linux/kernel_stat.h> -#include <linux/slab.h> #include <asm/uaccess.h>
@@ -596,9 +595,6 @@ kstat.per_cpu_system[cpu] += system; }else if (local_bh_count (cpu) ||local_irq_count (cpu) >1 ) kstat.per_cpu_system[cpu] += system; - -if (slab_cache_drain_mask & (1UL << cpu)) -slab_drain_local_cache (); }/*
mm/slab.c +36 -79
182 lines not on this page · raw message
Signature · 6 lines
In theory, practice and theory are the same, but in practice they are different -- Larry McVoy -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux.eu.org/Linux-MM/