Scalable statistics counters
Subsystems (3)
PATCH 1/1 Scalable statistics counters
Hi Andrew,
In continuation with my earlier post, here is Dipankar's 2.5.31 kmalloc_percpu patch which statctrs need.
Thanks,
Kiran
include/linux/slab.h +37 -0
@@ -13,6 +13,7 @@#include <linux/gfp.h> #include <linux/types.h> +#include <linux/smp.h> /* flags for kmem_cache_alloc() */ #define SLAB_NOFS GFP_NOFS
@@ -64,6 +65,42 @@extern int FASTCALL (kmem_cache_reap (int )); +#ifdef CONFIG_SMP + +struct percpu_data { +void *ptrs[NR_CPUS ]; +void *blkp; +}; + +#define per_cpu_ptr (ptr, cpu) \ +({ \ + struct percpu_data *__p = (struct percpu_data *)~(unsigned long)(ptr); \ + (__typeof__(ptr))__p->ptrs[(cpu)]; \ +}) +#define this_cpu_ptr (ptr) per_cpu_ptr(ptr, smp_processor_id()) +extern void *kmalloc_percpu (size_t size,int flags); +extern void kfree_percpu (const void *); +extern int percpu_interlaced_alloc (struct percpu_data *,size_t ,int ); +extern void percpu_interlaced_free (struct percpu_data *); +extern void percpu_data_sys_init (void ); + +#else + +#define per_cpu_ptr (ptr, cpu) (ptr) +#define this_cpu_ptr (ptr) (ptr) +static inline void *kmalloc_percpu (size_t size,int flags) +{ +kmalloc (size, flags); +} +static inline void kfree_percpu (const void *ptr) +{ +kfree (ptr); +} +static inline void percpu_data_sys_init (void ) { } + +#endif + +/* System wide caches */ extern kmem_cache_t *vm_area_cachep;extern kmem_cache_t *mm_cachep;
init/main.c +1 -0
@@ -431,6 +431,7 @@#endif mem_init ();kmem_cache_sizes_init (); +percpu_data_sys_init ();pgtable_cache_init ();pte_chain_init (); mempages = num_physpages;
kernel/ksyms.c +4 -0
@@ -105,6 +105,10 @@EXPORT_SYMBOL (kmem_cache_size);EXPORT_SYMBOL (kmalloc);EXPORT_SYMBOL (kfree); +#ifdef CONFIG_SMP +EXPORT_SYMBOL (kmalloc_percpu); +EXPORT_SYMBOL (kfree_percpu); +#endif EXPORT_SYMBOL (vfree);EXPORT_SYMBOL (__vmalloc);EXPORT_SYMBOL (vmalloc);
mm/Makefile +2 -1
@@ -10,7 +10,7 @@ O_TARGET := mm.o export-objs := shmem.o filemap.o mempool.o page_alloc.o \ - page-writeback.o + page-writeback.o percpu_data.o obj-y := memory.o mmap.o filemap.o mprotect.o mlock.o mremap.o \ vmalloc.o slab.o bootmem.o swap.o vmscan.o page_io.o \
@@ -18,4 +18,5 @@ shmem.o highmem.o mempool.o msync.o mincore.o readahead.o \ pdflush.o page-writeback.o rmap.o +obj-$(CONFIG_SMP) += percpu_data.o include $(TOPDIR)/Rules.make
mm/percpu_data.c +376 -0
376 lines not on this page · raw message
mm/slab.c +78 -0
90 lines not on this page · raw message