diff options
-rw-r--r-- | mm/slab.h | 3 | ||||
-rw-r--r-- | mm/slab_common.c | 8 | ||||
-rw-r--r-- | mm/slub.c | 19 |
3 files changed, 17 insertions, 13 deletions
@@ -38,13 +38,10 @@ extern int __kmem_cache_create(struct kmem_cache *, unsigned long flags); | |||
38 | #ifdef CONFIG_SLUB | 38 | #ifdef CONFIG_SLUB |
39 | struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, | 39 | struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, |
40 | size_t align, unsigned long flags, void (*ctor)(void *)); | 40 | size_t align, unsigned long flags, void (*ctor)(void *)); |
41 | extern int sysfs_slab_add(struct kmem_cache *s); | ||
42 | #else | 41 | #else |
43 | static inline struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, | 42 | static inline struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, |
44 | size_t align, unsigned long flags, void (*ctor)(void *)) | 43 | size_t align, unsigned long flags, void (*ctor)(void *)) |
45 | { return NULL; } | 44 | { return NULL; } |
46 | static inline int sysfs_slab_add(struct kmem_cache *s) { return 0; } | ||
47 | |||
48 | #endif | 45 | #endif |
49 | 46 | ||
50 | 47 | ||
diff --git a/mm/slab_common.c b/mm/slab_common.c index 651a3c60847a..9c217255ac49 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -155,14 +155,6 @@ out_locked: | |||
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
157 | 157 | ||
158 | if (s->refcount == 1) { | ||
159 | err = sysfs_slab_add(s); | ||
160 | if (err) | ||
161 | printk(KERN_WARNING "kmem_cache_create(%s) failed to" | ||
162 | " create sysfs entry. Error %d\n", | ||
163 | name, err); | ||
164 | } | ||
165 | |||
166 | return s; | 158 | return s; |
167 | } | 159 | } |
168 | EXPORT_SYMBOL(kmem_cache_create); | 160 | EXPORT_SYMBOL(kmem_cache_create); |
@@ -202,10 +202,12 @@ struct track { | |||
202 | enum track_item { TRACK_ALLOC, TRACK_FREE }; | 202 | enum track_item { TRACK_ALLOC, TRACK_FREE }; |
203 | 203 | ||
204 | #ifdef CONFIG_SYSFS | 204 | #ifdef CONFIG_SYSFS |
205 | static int sysfs_slab_add(struct kmem_cache *); | ||
205 | static int sysfs_slab_alias(struct kmem_cache *, const char *); | 206 | static int sysfs_slab_alias(struct kmem_cache *, const char *); |
206 | static void sysfs_slab_remove(struct kmem_cache *); | 207 | static void sysfs_slab_remove(struct kmem_cache *); |
207 | 208 | ||
208 | #else | 209 | #else |
210 | static inline int sysfs_slab_add(struct kmem_cache *s) { return 0; } | ||
209 | static inline int sysfs_slab_alias(struct kmem_cache *s, const char *p) | 211 | static inline int sysfs_slab_alias(struct kmem_cache *s, const char *p) |
210 | { return 0; } | 212 | { return 0; } |
211 | static inline void sysfs_slab_remove(struct kmem_cache *s) { } | 213 | static inline void sysfs_slab_remove(struct kmem_cache *s) { } |
@@ -3943,7 +3945,20 @@ struct kmem_cache *__kmem_cache_alias(const char *name, size_t size, | |||
3943 | 3945 | ||
3944 | int __kmem_cache_create(struct kmem_cache *s, unsigned long flags) | 3946 | int __kmem_cache_create(struct kmem_cache *s, unsigned long flags) |
3945 | { | 3947 | { |
3946 | return kmem_cache_open(s, flags); | 3948 | int err; |
3949 | |||
3950 | err = kmem_cache_open(s, flags); | ||
3951 | if (err) | ||
3952 | return err; | ||
3953 | |||
3954 | mutex_unlock(&slab_mutex); | ||
3955 | err = sysfs_slab_add(s); | ||
3956 | mutex_lock(&slab_mutex); | ||
3957 | |||
3958 | if (err) | ||
3959 | kmem_cache_close(s); | ||
3960 | |||
3961 | return err; | ||
3947 | } | 3962 | } |
3948 | 3963 | ||
3949 | #ifdef CONFIG_SMP | 3964 | #ifdef CONFIG_SMP |
@@ -5233,7 +5248,7 @@ static char *create_unique_id(struct kmem_cache *s) | |||
5233 | return name; | 5248 | return name; |
5234 | } | 5249 | } |
5235 | 5250 | ||
5236 | int sysfs_slab_add(struct kmem_cache *s) | 5251 | static int sysfs_slab_add(struct kmem_cache *s) |
5237 | { | 5252 | { |
5238 | int err; | 5253 | int err; |
5239 | const char *name; | 5254 | const char *name; |