diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-05-22 08:01:17 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-05-22 08:01:17 -0700 |
| commit | b33a7bad9bcb5c8453d7a13a99b3151ebe69563f (patch) | |
| tree | 1de88006d14572e2f920f53bf173da41db3eb511 /kernel/fork.c | |
| parent | 108e31587b9b9b4c6aaa99deb7f50c09c9f9b880 (diff) | |
[PATCH] slab: consolidate panic code
Many places do:
if (kmem_cache_create(...) == NULL)
panic(...);
We can consolidate all that by passing another flag to kmem_cache_create()
which says "panic if it doesn't work".
Diffstat (limited to 'kernel/fork.c')
| -rw-r--r-- | kernel/fork.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index a42ffd46532f..3f0ddd189004 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -216,11 +216,8 @@ void __init fork_init(unsigned long mempages) #endif /* create a slab on which task_structs can be allocated */ task_struct_cachep = - kmem_cache_create("task_struct", - sizeof(struct task_struct),ARCH_MIN_TASKALIGN, - 0, NULL, NULL); - if (!task_struct_cachep) - panic("fork_init(): cannot create task_struct SLAB cache"); + kmem_cache_create("task_struct", sizeof(struct task_struct), + ARCH_MIN_TASKALIGN, SLAB_PANIC, NULL, NULL); #endif /* @@ -1249,37 +1246,20 @@ void __init proc_caches_init(void) { sighand_cachep = kmem_cache_create("sighand_cache", sizeof(struct sighand_struct), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (!sighand_cachep) - panic("Cannot create sighand SLAB cache"); - + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); signal_cachep = kmem_cache_create("signal_cache", sizeof(struct signal_struct), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (!signal_cachep) - panic("Cannot create signal SLAB cache"); - + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); 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"); - + sizeof(struct files_struct), 0, + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); 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"); - + sizeof(struct fs_struct), 0, + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); vm_area_cachep = kmem_cache_create("vm_area_struct", sizeof(struct vm_area_struct), 0, - 0, NULL, NULL); - if(!vm_area_cachep) - panic("vma_init: Cannot alloc vm_area_struct SLAB cache"); - + SLAB_PANIC, NULL, NULL); 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"); + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); } |
