diff options
-rw-r--r-- | mm/slab.h | 10 | ||||
-rw-r--r-- | mm/slab_common.c | 4 | ||||
-rw-r--r-- | mm/slub.c | 15 |
3 files changed, 25 insertions, 4 deletions
@@ -36,6 +36,16 @@ extern struct kmem_cache *kmem_cache; | |||
36 | struct kmem_cache *__kmem_cache_create(const char *name, size_t size, | 36 | struct kmem_cache *__kmem_cache_create(const char *name, size_t size, |
37 | size_t align, unsigned long flags, void (*ctor)(void *)); | 37 | size_t align, unsigned long flags, void (*ctor)(void *)); |
38 | 38 | ||
39 | #ifdef CONFIG_SLUB | ||
40 | struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, | ||
41 | size_t align, unsigned long flags, void (*ctor)(void *)); | ||
42 | #else | ||
43 | static inline struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, | ||
44 | size_t align, unsigned long flags, void (*ctor)(void *)) | ||
45 | { return NULL; } | ||
46 | #endif | ||
47 | |||
48 | |||
39 | int __kmem_cache_shutdown(struct kmem_cache *); | 49 | int __kmem_cache_shutdown(struct kmem_cache *); |
40 | 50 | ||
41 | #endif | 51 | #endif |
diff --git a/mm/slab_common.c b/mm/slab_common.c index f18c06fd97c7..adc42b01b25b 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -115,6 +115,10 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align | |||
115 | goto out_locked; | 115 | goto out_locked; |
116 | } | 116 | } |
117 | 117 | ||
118 | s = __kmem_cache_alias(name, size, align, flags, ctor); | ||
119 | if (s) | ||
120 | goto out_locked; | ||
121 | |||
118 | s = __kmem_cache_create(n, size, align, flags, ctor); | 122 | s = __kmem_cache_create(n, size, align, flags, ctor); |
119 | 123 | ||
120 | if (s) { | 124 | if (s) { |
@@ -3708,7 +3708,7 @@ void __init kmem_cache_init(void) | |||
3708 | slub_max_order = 0; | 3708 | slub_max_order = 0; |
3709 | 3709 | ||
3710 | kmem_size = offsetof(struct kmem_cache, node) + | 3710 | kmem_size = offsetof(struct kmem_cache, node) + |
3711 | nr_node_ids * sizeof(struct kmem_cache_node *); | 3711 | nr_node_ids * sizeof(struct kmem_cache_node *); |
3712 | 3712 | ||
3713 | /* Allocate two kmem_caches from the page allocator */ | 3713 | /* Allocate two kmem_caches from the page allocator */ |
3714 | kmalloc_size = ALIGN(kmem_size, cache_line_size()); | 3714 | kmalloc_size = ALIGN(kmem_size, cache_line_size()); |
@@ -3922,7 +3922,7 @@ static struct kmem_cache *find_mergeable(size_t size, | |||
3922 | return NULL; | 3922 | return NULL; |
3923 | } | 3923 | } |
3924 | 3924 | ||
3925 | struct kmem_cache *__kmem_cache_create(const char *name, size_t size, | 3925 | struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, |
3926 | size_t align, unsigned long flags, void (*ctor)(void *)) | 3926 | size_t align, unsigned long flags, void (*ctor)(void *)) |
3927 | { | 3927 | { |
3928 | struct kmem_cache *s; | 3928 | struct kmem_cache *s; |
@@ -3939,11 +3939,18 @@ struct kmem_cache *__kmem_cache_create(const char *name, size_t size, | |||
3939 | 3939 | ||
3940 | if (sysfs_slab_alias(s, name)) { | 3940 | if (sysfs_slab_alias(s, name)) { |
3941 | s->refcount--; | 3941 | s->refcount--; |
3942 | return NULL; | 3942 | s = NULL; |
3943 | } | 3943 | } |
3944 | return s; | ||
3945 | } | 3944 | } |
3946 | 3945 | ||
3946 | return s; | ||
3947 | } | ||
3948 | |||
3949 | struct kmem_cache *__kmem_cache_create(const char *name, size_t size, | ||
3950 | size_t align, unsigned long flags, void (*ctor)(void *)) | ||
3951 | { | ||
3952 | struct kmem_cache *s; | ||
3953 | |||
3947 | s = kmem_cache_alloc(kmem_cache, GFP_KERNEL); | 3954 | s = kmem_cache_alloc(kmem_cache, GFP_KERNEL); |
3948 | if (s) { | 3955 | if (s) { |
3949 | if (kmem_cache_open(s, name, | 3956 | if (kmem_cache_open(s, name, |