1KMEM_CACHE_CREATE(9) Memory Management in Linux KMEM_CACHE_CREATE(9)
2
3
4
6 kmem_cache_create - Create a cache.
7
9 struct kmem_cache * kmem_cache_create(const char * name, size_t size,
10 size_t align,
11 unsigned long flags,
12 void (*ctor) (void *));
13
15 name
16 A string which is used in /proc/slabinfo to identify this cache.
17
18 size
19 The size of objects to be created in this cache.
20
21 align
22 The required alignment for the objects.
23
24 flags
25 SLAB flags
26
27 ctor
28 A constructor for the objects.
29
31 Returns a ptr to the cache on success, NULL on failure. Cannot be
32 called within a int, but can be interrupted. The ctor is run when new
33 pages are allocated by the cache.
34
35 name must be valid until the cache is destroyed. This implies that the
36 module calling this has to destroy the cache before getting unloaded.
37 Note that kmem_cache_name is not guaranteed to return the same pointer,
38 therefore applications must manage it themselves.
39
40 The flags are
41
42 SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) to
43 catch references to uninitialised memory.
44
45 SLAB_RED_ZONE - Insert `Red' zones around the allocated memory to check
46 for buffer overruns.
47
48 SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
49 cacheline. This can be beneficial if you're counting cycles as closely
50 as davem.
51
53Kernel Hackers Manual 2.6. November 2011 KMEM_CACHE_CREATE(9)