![]() | |||||||||||||
Messages in this thread Patch in this message |
Hi Linus, Mark, all, I have combined Mark's sigact_cachep patch with my fs_cachep one. Also, bdev_init must be __init. Also, the structures hanging off tsk-> logically belong to proc_caches_init(). Patch fully tested under 2.4.0-test6. Regards, Tigran A copy of patch on: http://www.moses.uklinux.net/patches/caches-2.4.0-test6.patch diff -urN -X dontdiff linux/fs/block_dev.c caches/fs/block_dev.c --- linux/fs/block_dev.c Thu Aug 10 06:51:11 2000 +++ caches/fs/block_dev.c Fri Aug 11 10:35:59 2000 @@ -347,7 +347,7 @@ } } -void bdev_init(void) +void __init bdev_init(void) { int i; struct list_head *head = bdev_hashtable; @@ -364,7 +364,7 @@ 0, SLAB_HWCACHE_ALIGN, init_once, NULL); if (!bdev_cachep) - panic("cannot create bdev slab cache"); + panic("Cannot create bdev_cache SLAB cache"); } /* diff -urN -X dontdiff linux/fs/dcache.c caches/fs/dcache.c --- linux/fs/dcache.c Thu Aug 10 06:51:11 2000 +++ caches/fs/dcache.c Fri Aug 11 10:49:01 2000 @@ -1228,9 +1228,6 @@ /* SLAB cache for __getname() consumers */ kmem_cache_t *names_cachep; -/* SLAB cache for files_struct structures */ -kmem_cache_t *files_cachep; - /* SLAB cache for file structures */ kmem_cache_t *filp_cachep; @@ -1246,19 +1243,13 @@ sizeof(struct buffer_head), 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if(!bh_cachep) - panic("Cannot create buffer head SLAB cache\n"); + panic("Cannot create buffer head SLAB cache"); names_cachep = kmem_cache_create("names_cache", PAGE_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if (!names_cachep) panic("Cannot create names SLAB cache"); - - files_cachep = kmem_cache_create("files_cache", - sizeof(struct files_struct), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (!files_cachep) - panic("Cannot create files SLAB cache"); filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, diff -urN -X dontdiff linux/include/linux/mm.h caches/include/linux/mm.h --- linux/include/linux/mm.h Thu Aug 10 06:51:12 2000 +++ caches/include/linux/mm.h Fri Aug 11 10:31:57 2000 @@ -384,7 +384,6 @@ extern void swapin_readahead(swp_entry_t); /* mmap.c */ -extern void vma_init(void); extern void merge_segments(struct mm_struct *, unsigned long, unsigned long); extern void insert_vm_struct(struct mm_struct *, struct vm_area_struct *); extern void build_mmap_avl(struct mm_struct *); diff -urN -X dontdiff linux/include/linux/sched.h caches/include/linux/sched.h --- linux/include/linux/sched.h Thu Aug 10 06:51:12 2000 +++ caches/include/linux/sched.h Fri Aug 11 10:24:52 2000 @@ -541,6 +541,7 @@ extern int in_group_p(gid_t); extern int in_egroup_p(gid_t); +extern void proc_caches_init(void); extern void flush_signals(struct task_struct *); extern void flush_signal_handlers(struct task_struct *); extern int dequeue_signal(sigset_t *, siginfo_t *); diff -urN -X dontdiff linux/include/linux/slab.h caches/include/linux/slab.h --- linux/include/linux/slab.h Thu Aug 10 06:51:12 2000 +++ caches/include/linux/slab.h Fri Aug 11 10:36:35 2000 @@ -73,6 +73,8 @@ extern kmem_cache_t *filp_cachep; extern kmem_cache_t *dquot_cachep; extern kmem_cache_t *bh_cachep; +extern kmem_cache_t *fs_cachep; +extern kmem_cache_t *sigact_cachep; #ifdef CONFIG_SMP extern unsigned long slab_cache_drain_mask; diff -urN -X dontdiff linux/init/main.c caches/init/main.c --- linux/init/main.c Thu Aug 10 06:51:12 2000 +++ caches/init/main.c Fri Aug 11 10:40:30 2000 @@ -562,8 +562,8 @@ mempages = num_physpages; fork_init(mempages); + proc_caches_init(); vfs_caches_init(mempages); - vma_init(); buffer_init(mempages); page_cache_init(mempages); kiobuf_setup(); diff -urN -X dontdiff linux/kernel/exit.c caches/kernel/exit.c --- linux/kernel/exit.c Thu Aug 10 06:51:12 2000 +++ caches/kernel/exit.c Fri Aug 11 10:21:38 2000 @@ -229,7 +229,7 @@ dput(fs->altroot); mntput(fs->altrootmnt); } - kfree(fs); + kmem_cache_free(fs_cachep, fs); } } @@ -264,7 +264,7 @@ tsk->sig = NULL; spin_unlock_irq(&tsk->sigmask_lock); if (atomic_dec_and_test(&sig->count)) - kfree(sig); + kmem_cache_free(sigact_cachep, sig); } flush_signals(tsk); diff -urN -X dontdiff linux/kernel/fork.c caches/kernel/fork.c --- linux/kernel/fork.c Thu Aug 10 06:51:12 2000 +++ caches/kernel/fork.c Fri Aug 11 10:49:00 2000 @@ -32,9 +32,6 @@ unsigned long total_forks; /* Handle normal Linux uptimes. */ int last_pid; -/* SLAB cache for mm_struct's. */ -kmem_cache_t *mm_cachep; - struct task_struct *pidhash[PIDHASH_SZ]; void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait) @@ -340,7 +337,7 @@ static inline struct fs_struct *__copy_fs_struct(struct fs_struct *old) { - struct fs_struct *fs = kmalloc(sizeof(*old), GFP_KERNEL); + struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL); /* We don't need to lock fs - think why ;-) */ if (fs) { atomic_set(&fs->count, 1); @@ -506,7 +503,7 @@ atomic_inc(¤t->sig->count); return 0; } - tsk->sig = kmalloc(sizeof(*tsk->sig), GFP_KERNEL); + tsk->sig = kmem_cache_alloc(sigact_cachep, GFP_KERNEL); if (!tsk->sig) return -1; spin_lock_init(&tsk->sig->siglock); @@ -697,4 +694,52 @@ bad_fork_free: free_task_struct(p); goto bad_fork; +} + +/* SLAB cache for signal_struct structures (tsk->sig) */ +kmem_cache_t *sigact_cachep; + +/* SLAB cache for files_struct structures (tsk->files) */ +kmem_cache_t *files_cachep; + +/* SLAB cache for fs_struct structures (tsk->fs) */ +kmem_cache_t *fs_cachep; + +/* SLAB cache for vm_area_struct structures */ +kmem_cache_t *vm_area_cachep; + +/* SLAB cache for mm_struct structures (tsk->mm) */ +kmem_cache_t *mm_cachep; + +void __init proc_caches_init(void) +{ + sigact_cachep = kmem_cache_create("signal_act", + sizeof(struct signal_struct), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!sigact_cachep) + panic("Cannot create signal action SLAB cache"); + + files_cachep = kmem_cache_create("files_cache", + sizeof(struct files_struct), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!files_cachep) + panic("Cannot create files SLAB cache"); + + fs_cachep = kmem_cache_create("fs_cache", + sizeof(struct fs_struct), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!fs_cachep) + panic("Cannot create fs_struct SLAB cache"); + + vm_area_cachep = kmem_cache_create("vm_area_struct", + sizeof(struct vm_area_struct), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if(!vm_area_cachep) + panic("vma_init: Cannot alloc vm_area_struct SLAB cache"); + + mm_cachep = kmem_cache_create("mm_struct", + sizeof(struct mm_struct), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if(!mm_cachep) + panic("vma_init: Cannot alloc mm_struct SLAB cache"); } diff -urN -X dontdiff linux/mm/mmap.c caches/mm/mmap.c --- linux/mm/mmap.c Fri Jul 28 09:59:00 2000 +++ caches/mm/mmap.c Fri Aug 11 10:34:57 2000 @@ -36,9 +36,6 @@ __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111 }; -/* SLAB cache for vm_area_struct's. */ -kmem_cache_t *vm_area_cachep; - int sysctl_overcommit_memory; /* Check that a process has enough memory to allocate a @@ -993,21 +990,4 @@ kmem_cache_free(vm_area_cachep, mpnt); mpnt = prev; } -} - -void __init vma_init(void) -{ - vm_area_cachep = kmem_cache_create("vm_area_struct", - sizeof(struct vm_area_struct), - 0, SLAB_HWCACHE_ALIGN, - NULL, NULL); - if(!vm_area_cachep) - panic("vma_init: Cannot alloc vm_area_struct cache."); - - mm_cachep = kmem_cache_create("mm_struct", - sizeof(struct mm_struct), - 0, SLAB_HWCACHE_ALIGN, - NULL, NULL); - if(!mm_cachep) - panic("vma_init: Cannot alloc mm_struct cache."); } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/ | ||||||||||||
| Last update: 2005-03-22 13:58 [from the cache] ©2003-2008 | |||||||||||||