aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-05-06 17:49:57 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:55 -0400
commit0a31bd5f2bbb6473ef9d24f0063ca91cfa678b64 (patch)
treea945e829bf6bf7a93bf844b2ee9f2a3a2fa17c5d /kernel
parent5af60839909b8e3b28ca7cd7912fa0b23475617f (diff)
KMEM_CACHE(): simplify slab cache creation
This patch provides a new macro KMEM_CACHE(<struct>, <flags>) to simplify slab creation. KMEM_CACHE creates a slab with the name of the struct, with the size of the struct and with the alignment of the struct. Additional slab flags may be specified if necessary. Example struct test_slab { int a,b,c; struct list_head; } __cacheline_aligned_in_smp; test_slab_cache = KMEM_CACHE(test_slab, SLAB_PANIC) will create a new slab named "test_slab" of the size sizeof(struct test_slab) and aligned to the alignment of test slab. If it fails then we panic. Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/delayacct.c6
-rw-r--r--kernel/pid.c4
-rw-r--r--kernel/signal.c6
-rw-r--r--kernel/taskstats.c4
4 files changed, 4 insertions, 16 deletions
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 766d5912b26a..c0148ae992c4 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -31,11 +31,7 @@ __setup("nodelayacct", delayacct_setup_disable);
31 31
32void delayacct_init(void) 32void delayacct_init(void)
33{ 33{
34 delayacct_cache = kmem_cache_create("delayacct_cache", 34 delayacct_cache = KMEM_CACHE(task_delay_info, SLAB_PANIC);
35 sizeof(struct task_delay_info),
36 0,
37 SLAB_PANIC,
38 NULL, NULL);
39 delayacct_tsk_init(&init_task); 35 delayacct_tsk_init(&init_task);
40} 36}
41 37
diff --git a/kernel/pid.c b/kernel/pid.c
index 78f2aee90f54..9c80bc23d6b8 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -412,7 +412,5 @@ void __init pidmap_init(void)
412 set_bit(0, init_pid_ns.pidmap[0].page); 412 set_bit(0, init_pid_ns.pidmap[0].page);
413 atomic_dec(&init_pid_ns.pidmap[0].nr_free); 413 atomic_dec(&init_pid_ns.pidmap[0].nr_free);
414 414
415 pid_cachep = kmem_cache_create("pid", sizeof(struct pid), 415 pid_cachep = KMEM_CACHE(pid, SLAB_PANIC);
416 __alignof__(struct pid),
417 SLAB_PANIC, NULL, NULL);
418} 416}
diff --git a/kernel/signal.c b/kernel/signal.c
index 3670225ecbc0..2b4087d545a3 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2636,9 +2636,5 @@ __attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma)
2636 2636
2637void __init signals_init(void) 2637void __init signals_init(void)
2638{ 2638{
2639 sigqueue_cachep = 2639 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
2640 kmem_cache_create("sigqueue",
2641 sizeof(struct sigqueue),
2642 __alignof__(struct sigqueue),
2643 SLAB_PANIC, NULL, NULL);
2644} 2640}
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index ad7d2392cb0e..906cae771585 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -524,9 +524,7 @@ void __init taskstats_init_early(void)
524{ 524{
525 unsigned int i; 525 unsigned int i;
526 526
527 taskstats_cache = kmem_cache_create("taskstats_cache", 527 taskstats_cache = KMEM_CACHE(taskstats, SLAB_PANIC);
528 sizeof(struct taskstats),
529 0, SLAB_PANIC, NULL, NULL);
530 for_each_possible_cpu(i) { 528 for_each_possible_cpu(i) {
531 INIT_LIST_HEAD(&(per_cpu(listener_array, i).list)); 529 INIT_LIST_HEAD(&(per_cpu(listener_array, i).list));
532 init_rwsem(&(per_cpu(listener_array, i).sem)); 530 init_rwsem(&(per_cpu(listener_array, i).sem));