lkml.org 
[lkml]   [2018]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kmem_cache_attr (was Re: [PATCH 04/36] usercopy: Prepare for usercopy whitelisting)
On Tue, 16 Jan 2018, Matthew Wilcox wrote:

> On Tue, Jan 16, 2018 at 12:17:01PM -0600, Christopher Lameter wrote:
> > Draft patch of how the data structs could change. kmem_cache_attr is read
> > only.
>
> Looks good. Although I would add Kees' user feature:

Sure I tried to do this quickly so that the basic struct changes are
visible.

> And I'd start with
> +struct kmem_cache *kmem_cache_create_attr(const kmem_cache_attr *);
>
> leaving the old kmem_cache_create to kmalloc a kmem_cache_attr and
> initialise it.

Well at some point we should convert the callers by putting the
definitions into const kmem_cache_attr initializations. That way
the callbacks function pointers are safe.

> Can we also do something like this?
>
> -#define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\
> - sizeof(struct __struct), __alignof__(struct __struct),\
> - (__flags), NULL)
> +#define KMEM_CACHE(__struct, __flags) ({ \
> + const struct kmem_cache_attr kca ## __stringify(__struct) = { \
> + .name = #__struct, \
> + .size = sizeof(struct __struct), \
> + .align = __alignof__(struct __struct), \
> + .flags = (__flags), \
> + }; \
> + kmem_cache_create_attr(&kca ## __stringify(__struct)); \
> +})
>
> That way we won't need to convert any of those users.

Yep thats what I was planning.

\
 
 \ /
  Last update: 2018-01-18 00:20    [W:0.071 / U:1.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site