Skip to content

Commit 781aee7

Browse files
braunertehcaster
authored andcommitted
slab: make __kmem_cache_create() static inline
Make __kmem_cache_create() 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 0c9050b commit 781aee7

File tree

2 files changed

+10
-41
lines changed

2 files changed

+10
-41
lines changed

include/linux/slab.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,17 @@ struct kmem_cache *__kmem_cache_create_args(const char *name,
262262
unsigned int object_size,
263263
struct kmem_cache_args *args,
264264
slab_flags_t flags);
265+
static inline struct kmem_cache *
266+
__kmem_cache_create(const char *name, unsigned int size, unsigned int align,
267+
slab_flags_t flags, void (*ctor)(void *))
268+
{
269+
struct kmem_cache_args kmem_args = {
270+
.align = align,
271+
.ctor = ctor,
272+
};
265273

266-
struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size,
267-
unsigned int align, slab_flags_t flags,
268-
void (*ctor)(void *));
274+
return __kmem_cache_create_args(name, size, &kmem_args, flags);
275+
}
269276

270277
/**
271278
* kmem_cache_create_usercopy - Create a cache with a region suitable

mm/slab_common.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -337,44 +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 - Create a cache.
342-
* @name: A string which is used in /proc/slabinfo to identify this cache.
343-
* @size: The size of objects to be created in this cache.
344-
* @align: The required alignment for the objects.
345-
* @flags: SLAB flags
346-
* @ctor: A constructor for the objects.
347-
*
348-
* Cannot be called within a interrupt, but can be interrupted.
349-
* The @ctor is run when new pages are allocated by the cache.
350-
*
351-
* The flags are
352-
*
353-
* %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5)
354-
* to catch references to uninitialised memory.
355-
*
356-
* %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check
357-
* for buffer overruns.
358-
*
359-
* %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
360-
* cacheline. This can be beneficial if you're counting cycles as closely
361-
* as davem.
362-
*
363-
* Return: a pointer to the cache on success, NULL on failure.
364-
*/
365-
struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size,
366-
unsigned int align, slab_flags_t flags,
367-
void (*ctor)(void *))
368-
{
369-
struct kmem_cache_args kmem_args = {
370-
.align = align,
371-
.ctor = ctor,
372-
};
373-
374-
return __kmem_cache_create_args(name, size, &kmem_args, flags);
375-
}
376-
EXPORT_SYMBOL(__kmem_cache_create);
377-
378340
static struct kmem_cache *kmem_buckets_cache __ro_after_init;
379341

380342
/**

0 commit comments

Comments
 (0)