aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-05-22 08:01:17 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-05-22 08:01:17 -0700
commitb33a7bad9bcb5c8453d7a13a99b3151ebe69563f (patch)
tree1de88006d14572e2f920f53bf173da41db3eb511 /kernel
parent108e31587b9b9b4c6aaa99deb7f50c09c9f9b880 (diff)
downloadhistory-b33a7bad9bcb5c8453d7a13a99b3151ebe69563f.tar.gz
[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')
-rw-r--r--kernel/fork.c40
-rw-r--r--kernel/signal.c4
-rw-r--r--kernel/user.c5
3 files changed, 12 insertions, 37 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index a42ffd46532fd0..3f0ddd189004bb 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);
}
diff --git a/kernel/signal.c b/kernel/signal.c
index b749ec799f96f8..53d4c6ef401f1b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2573,7 +2573,5 @@ void __init signals_init(void)
kmem_cache_create("sigqueue",
sizeof(struct sigqueue),
__alignof__(struct sigqueue),
- 0, NULL, NULL);
- if (!sigqueue_cachep)
- panic("signals_init(): cannot create sigqueue SLAB cache");
+ SLAB_PANIC, NULL, NULL);
}
diff --git a/kernel/user.c b/kernel/user.c
index 0e9e032a6d84eb..60e942b8f098ab 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -149,10 +149,7 @@ static int __init uid_cache_init(void)
int n;
uid_cachep = kmem_cache_create("uid_cache", sizeof(struct user_struct),
- 0,
- SLAB_HWCACHE_ALIGN, NULL, NULL);
- if(!uid_cachep)
- panic("Cannot create uid taskcount SLAB cache\n");
+ 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
for(n = 0; n < UIDHASH_SZ; ++n)
INIT_LIST_HEAD(uidhash_table + n);