Skip to content

Commit 0c9050b

Browse files
braunertehcaster
authored andcommitted
slab: make kmem_cache_create_usercopy() static inline
Make kmem_cache_create_usercopy() a static inline function. Signed-off-by: Christian Brauner <[email protected]> Reviewed-by: Mike Rapoport (Microsoft) <[email protected]> Reviewed-by: Roman Gushchin <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 3d453e6 commit 0c9050b

File tree

2 files changed

+44
-50
lines changed

2 files changed

+44
-50
lines changed

include/linux/slab.h

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,50 @@ struct kmem_cache *__kmem_cache_create_args(const char *name,
266266
struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size,
267267
unsigned int align, slab_flags_t flags,
268268
void (*ctor)(void *));
269-
struct kmem_cache *kmem_cache_create_usercopy(const char *name,
270-
unsigned int size, unsigned int align,
271-
slab_flags_t flags,
272-
unsigned int useroffset, unsigned int usersize,
273-
void (*ctor)(void *));
269+
270+
/**
271+
* kmem_cache_create_usercopy - Create a cache with a region suitable
272+
* for copying to userspace
273+
* @name: A string which is used in /proc/slabinfo to identify this cache.
274+
* @size: The size of objects to be created in this cache.
275+
* @align: The required alignment for the objects.
276+
* @flags: SLAB flags
277+
* @useroffset: Usercopy region offset
278+
* @usersize: Usercopy region size
279+
* @ctor: A constructor for the objects.
280+
*
281+
* Cannot be called within a interrupt, but can be interrupted.
282+
* The @ctor is run when new pages are allocated by the cache.
283+
*
284+
* The flags are
285+
*
286+
* %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5)
287+
* to catch references to uninitialised memory.
288+
*
289+
* %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check
290+
* for buffer overruns.
291+
*
292+
* %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
293+
* cacheline. This can be beneficial if you're counting cycles as closely
294+
* as davem.
295+
*
296+
* Return: a pointer to the cache on success, NULL on failure.
297+
*/
298+
static inline struct kmem_cache *
299+
kmem_cache_create_usercopy(const char *name, unsigned int size,
300+
unsigned int align, slab_flags_t flags,
301+
unsigned int useroffset, unsigned int usersize,
302+
void (*ctor)(void *))
303+
{
304+
struct kmem_cache_args kmem_args = {
305+
.align = align,
306+
.ctor = ctor,
307+
.useroffset = useroffset,
308+
.usersize = usersize,
309+
};
310+
311+
return __kmem_cache_create_args(name, size, &kmem_args, flags);
312+
}
274313

275314
/* If NULL is passed for @args, use this variant with default arguments. */
276315
static inline struct kmem_cache *

mm/slab_common.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -337,51 +337,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name,
337337
}
338338
EXPORT_SYMBOL(__kmem_cache_create_args);
339339

340-
/**
341-
* kmem_cache_create_usercopy - Create a cache with a region suitable
342-
* for copying to userspace
343-
* @name: A string which is used in /proc/slabinfo to identify this cache.
344-
* @size: The size of objects to be created in this cache.
345-
* @align: The required alignment for the objects.
346-
* @flags: SLAB flags
347-
* @useroffset: Usercopy region offset
348-
* @usersize: Usercopy region size
349-
* @ctor: A constructor for the objects.
350-
*
351-
* Cannot be called within a interrupt, but can be interrupted.
352-
* The @ctor is run when new pages are allocated by the cache.
353-
*
354-
* The flags are
355-
*
356-
* %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5)
357-
* to catch references to uninitialised memory.
358-
*
359-
* %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check
360-
* for buffer overruns.
361-
*
362-
* %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
363-
* cacheline. This can be beneficial if you're counting cycles as closely
364-
* as davem.
365-
*
366-
* Return: a pointer to the cache on success, NULL on failure.
367-
*/
368-
struct kmem_cache *
369-
kmem_cache_create_usercopy(const char *name, unsigned int size,
370-
unsigned int align, slab_flags_t flags,
371-
unsigned int useroffset, unsigned int usersize,
372-
void (*ctor)(void *))
373-
{
374-
struct kmem_cache_args kmem_args = {
375-
.align = align,
376-
.ctor = ctor,
377-
.useroffset = useroffset,
378-
.usersize = usersize,
379-
};
380-
381-
return __kmem_cache_create_args(name, size, &kmem_args, flags);
382-
}
383-
EXPORT_SYMBOL(kmem_cache_create_usercopy);
384-
385340
/**
386341
* __kmem_cache_create - Create a cache.
387342
* @name: A string which is used in /proc/slabinfo to identify this cache.

0 commit comments

Comments
 (0)