Re: [RFC] SL[AUO]B common code 3/9] Extract common fields from struct kmem_cache

Christoph Lameter
2012-05-16T14:28:28Z

On Wed, 16 May 2012, Glauber Costa wrote:

> > /*
> > + * Common fields provided in kmem_cache by all slab allocators
> > + */
> > +#define SLAB_COMMON \
> > + unsigned int size, align; \
> > + unsigned long flags; \
> > + const char *name; \
> > + int refcount; \
> > + void (*ctor)(void *); \
> > + struct list_head list;
> > +
> > +/*
> > * struct kmem_cache related prototypes
>
> Isn't it better to define struct kmem_cache here, and then put the non-common
> fields under proper ifdefs ?

Then we would move the definition to include/linux/slab.h. The allocator
kmem_cache struct definitions rely on other allocator specific
declarations at this point. Wont work.

> > Index: linux-2.6/mm/slob.c
> > ===================================================================
> > --- linux-2.6.orig/mm/slob.c 2012-05-11 08:34:31.792522763 -0500
> > +++ linux-2.6/mm/slob.c 2012-05-11 09:42:52.032437799 -0500
> > @@ -538,13 +538,6 @@ size_t ksize(const void *block)
> > }
> > EXPORT_SYMBOL(ksize);
> >
> > -struct kmem_cache {
> > - unsigned int size, align;
> > - unsigned long flags;
> > - const char *name;
> > - void (*ctor)(void *);
> > -};
> > -
>
> Who defines struct kmem_cache for the slob now ?

Its defined in include/linux/slob_def.h