Commit cbb79694d592e9a76880f6ef6db8feccaeee1c32

Authored by Christoph Lameter
Committed by Pekka Enberg
1 parent db265eca77

mm/sl[aou]b: Do slab aliasing call from common code

The slab aliasing logic causes some strange contortions in slub. So add
a call to deal with aliases to slab_common.c but disable it for other
slab allocators by providng stubs that fail to create aliases.

Full general support for aliases will require additional cleanup passes
and more standardization of fields in kmem_cache.

Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>

Showing 3 changed files with 25 additions and 4 deletions Side-by-side Diff

... ... @@ -36,6 +36,16 @@
36 36 struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
37 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 49 int __kmem_cache_shutdown(struct kmem_cache *);
40 50  
41 51 #endif
... ... @@ -115,6 +115,10 @@
115 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 122 s = __kmem_cache_create(n, size, align, flags, ctor);
119 123  
120 124 if (s) {
... ... @@ -3708,7 +3708,7 @@
3708 3708 slub_max_order = 0;
3709 3709  
3710 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 3713 /* Allocate two kmem_caches from the page allocator */
3714 3714 kmalloc_size = ALIGN(kmem_size, cache_line_size());
... ... @@ -3922,7 +3922,7 @@
3922 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 3926 size_t align, unsigned long flags, void (*ctor)(void *))
3927 3927 {
3928 3928 struct kmem_cache *s;
3929 3929  
3930 3930  
... ... @@ -3939,10 +3939,17 @@
3939 3939  
3940 3940 if (sysfs_slab_alias(s, name)) {
3941 3941 s->refcount--;
3942   - return NULL;
  3942 + s = NULL;
3943 3943 }
3944   - return s;
3945 3944 }
  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;
3946 3953  
3947 3954 s = kmem_cache_alloc(kmem_cache, GFP_KERNEL);
3948 3955 if (s) {