diff options
author | Christoph Lameter <cl@linux.com> | 2013-01-10 14:12:17 -0500 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2013-02-01 05:32:08 -0500 |
commit | f97d5f634d3b5133951424fae751db1f339548bd (patch) | |
tree | cb4db9a78c8eb1bd0522679d90f553d40d15f3e9 /mm/slub.c | |
parent | 9425c58e5445277699ff3c2a87bac1cfebc1b48d (diff) |
slab: Common function to create the kmalloc array
The kmalloc array is created in similar ways in both SLAB
and SLUB. Create a common function and have both allocators
call that function.
V1->V2:
Whitespace cleanup
Reviewed-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 55 |
1 files changed, 3 insertions, 52 deletions
@@ -3633,7 +3633,6 @@ void __init kmem_cache_init(void) | |||
3633 | static __initdata struct kmem_cache boot_kmem_cache, | 3633 | static __initdata struct kmem_cache boot_kmem_cache, |
3634 | boot_kmem_cache_node; | 3634 | boot_kmem_cache_node; |
3635 | int i; | 3635 | int i; |
3636 | int caches = 2; | ||
3637 | 3636 | ||
3638 | if (debug_guardpage_minorder()) | 3637 | if (debug_guardpage_minorder()) |
3639 | slub_max_order = 0; | 3638 | slub_max_order = 0; |
@@ -3703,64 +3702,16 @@ void __init kmem_cache_init(void) | |||
3703 | size_index[size_index_elem(i)] = 8; | 3702 | size_index[size_index_elem(i)] = 8; |
3704 | } | 3703 | } |
3705 | 3704 | ||
3706 | /* Caches that are not of the two-to-the-power-of size */ | 3705 | create_kmalloc_caches(0); |
3707 | if (KMALLOC_MIN_SIZE <= 32) { | ||
3708 | kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0); | ||
3709 | caches++; | ||
3710 | } | ||
3711 | |||
3712 | if (KMALLOC_MIN_SIZE <= 64) { | ||
3713 | kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0); | ||
3714 | caches++; | ||
3715 | } | ||
3716 | |||
3717 | for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) { | ||
3718 | kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0); | ||
3719 | caches++; | ||
3720 | } | ||
3721 | |||
3722 | slab_state = UP; | ||
3723 | |||
3724 | /* Provide the correct kmalloc names now that the caches are up */ | ||
3725 | if (KMALLOC_MIN_SIZE <= 32) { | ||
3726 | kmalloc_caches[1]->name = kstrdup(kmalloc_caches[1]->name, GFP_NOWAIT); | ||
3727 | BUG_ON(!kmalloc_caches[1]->name); | ||
3728 | } | ||
3729 | |||
3730 | if (KMALLOC_MIN_SIZE <= 64) { | ||
3731 | kmalloc_caches[2]->name = kstrdup(kmalloc_caches[2]->name, GFP_NOWAIT); | ||
3732 | BUG_ON(!kmalloc_caches[2]->name); | ||
3733 | } | ||
3734 | |||
3735 | for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) { | ||
3736 | char *s = kasprintf(GFP_NOWAIT, "kmalloc-%d", 1 << i); | ||
3737 | |||
3738 | BUG_ON(!s); | ||
3739 | kmalloc_caches[i]->name = s; | ||
3740 | } | ||
3741 | 3706 | ||
3742 | #ifdef CONFIG_SMP | 3707 | #ifdef CONFIG_SMP |
3743 | register_cpu_notifier(&slab_notifier); | 3708 | register_cpu_notifier(&slab_notifier); |
3744 | #endif | 3709 | #endif |
3745 | 3710 | ||
3746 | #ifdef CONFIG_ZONE_DMA | ||
3747 | for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) { | ||
3748 | struct kmem_cache *s = kmalloc_caches[i]; | ||
3749 | |||
3750 | if (s && s->size) { | ||
3751 | char *name = kasprintf(GFP_NOWAIT, | ||
3752 | "dma-kmalloc-%d", s->object_size); | ||
3753 | |||
3754 | BUG_ON(!name); | ||
3755 | kmalloc_dma_caches[i] = create_kmalloc_cache(name, | ||
3756 | s->object_size, SLAB_CACHE_DMA); | ||
3757 | } | ||
3758 | } | ||
3759 | #endif | ||
3760 | printk(KERN_INFO | 3711 | printk(KERN_INFO |
3761 | "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d," | 3712 | "SLUB: HWalign=%d, Order=%d-%d, MinObjects=%d," |
3762 | " CPUs=%d, Nodes=%d\n", | 3713 | " CPUs=%d, Nodes=%d\n", |
3763 | caches, cache_line_size(), | 3714 | cache_line_size(), |
3764 | slub_min_order, slub_max_order, slub_min_objects, | 3715 | slub_min_order, slub_max_order, slub_min_objects, |
3765 | nr_cpu_ids, nr_node_ids); | 3716 | nr_cpu_ids, nr_node_ids); |
3766 | } | 3717 | } |