aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2012-06-13 11:24:57 -0400
committerPekka Enberg <penberg@kernel.org>2012-06-14 02:20:16 -0400
commit3b0efdfa1e719303536c04d9abca43abeb40f80a (patch)
tree6a429eebb3febe5cc2101615ec7c7ea4d10fd97b /include
parent350260889b251821e770573dfd65cd851b4ef781 (diff)
mm, sl[aou]b: Extract common fields from struct kmem_cache
Define a struct that describes common fields used in all slab allocators. A slab allocator either uses the common definition (like SLOB) or is required to provide members of kmem_cache with the definition given. After that it will be possible to share code that only operates on those fields of kmem_cache. The patch basically takes the slob definition of kmem cache and uses the field namees for the other allocators. It also standardizes the names used for basic object lengths in allocators: object_size Struct size specified at kmem_cache_create. Basically the payload expected to be used by the subsystem. size The size of memory allocator for each object. This size is larger than object_size and includes padding, alignment and extra metadata for each object (f.e. for debugging and rcu). Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/slab.h24
-rw-r--r--include/linux/slab_def.h10
-rw-r--r--include/linux/slub_def.h2
3 files changed, 31 insertions, 5 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 67d5d94b783a..0dd2dfa7beca 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -93,6 +93,30 @@
93 (unsigned long)ZERO_SIZE_PTR) 93 (unsigned long)ZERO_SIZE_PTR)
94 94
95/* 95/*
96 * Common fields provided in kmem_cache by all slab allocators
97 * This struct is either used directly by the allocator (SLOB)
98 * or the allocator must include definitions for all fields
99 * provided in kmem_cache_common in their definition of kmem_cache.
100 *
101 * Once we can do anonymous structs (C11 standard) we could put a
102 * anonymous struct definition in these allocators so that the
103 * separate allocations in the kmem_cache structure of SLAB and
104 * SLUB is no longer needed.
105 */
106#ifdef CONFIG_SLOB
107struct kmem_cache {
108 unsigned int object_size;/* The original size of the object */
109 unsigned int size; /* The aligned/padded/added on size */
110 unsigned int align; /* Alignment as calculated */
111 unsigned long flags; /* Active flags on the slab */
112 const char *name; /* Slab name for sysfs */
113 int refcount; /* Use counter */
114 void (*ctor)(void *); /* Called on object slot creation */
115 struct list_head list; /* List of all slab caches on the system */
116};
117#endif
118
119/*
96 * struct kmem_cache related prototypes 120 * struct kmem_cache related prototypes
97 */ 121 */
98void __init kmem_cache_init(void); 122void __init kmem_cache_init(void);
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index fbd1117fdfde..1d93f27d81de 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -27,7 +27,7 @@ struct kmem_cache {
27 unsigned int limit; 27 unsigned int limit;
28 unsigned int shared; 28 unsigned int shared;
29 29
30 unsigned int buffer_size; 30 unsigned int size;
31 u32 reciprocal_buffer_size; 31 u32 reciprocal_buffer_size;
32/* 2) touched by every alloc & free from the backend */ 32/* 2) touched by every alloc & free from the backend */
33 33
@@ -52,7 +52,10 @@ struct kmem_cache {
52 52
53/* 4) cache creation/removal */ 53/* 4) cache creation/removal */
54 const char *name; 54 const char *name;
55 struct list_head next; 55 struct list_head list;
56 int refcount;
57 int object_size;
58 int align;
56 59
57/* 5) statistics */ 60/* 5) statistics */
58#ifdef CONFIG_DEBUG_SLAB 61#ifdef CONFIG_DEBUG_SLAB
@@ -73,12 +76,11 @@ struct kmem_cache {
73 76
74 /* 77 /*
75 * If debugging is enabled, then the allocator can add additional 78 * If debugging is enabled, then the allocator can add additional
76 * fields and/or padding to every object. buffer_size contains the total 79 * fields and/or padding to every object. size contains the total
77 * object size including these internal fields, the following two 80 * object size including these internal fields, the following two
78 * variables contain the offset to the user object and its size. 81 * variables contain the offset to the user object and its size.
79 */ 82 */
80 int obj_offset; 83 int obj_offset;
81 int obj_size;
82#endif /* CONFIG_DEBUG_SLAB */ 84#endif /* CONFIG_DEBUG_SLAB */
83 85
84/* 6) per-cpu/per-node data, touched during every alloc/free */ 86/* 6) per-cpu/per-node data, touched during every alloc/free */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index ebdcf4ba42ee..df448adb7283 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -82,7 +82,7 @@ struct kmem_cache {
82 unsigned long flags; 82 unsigned long flags;
83 unsigned long min_partial; 83 unsigned long min_partial;
84 int size; /* The size of an object including meta data */ 84 int size; /* The size of an object including meta data */
85 int objsize; /* The size of an object without meta data */ 85 int object_size; /* The size of an object without meta data */
86 int offset; /* Free pointer offset. */ 86 int offset; /* Free pointer offset. */
87 int cpu_partial; /* Number of per cpu partial objects to keep around */ 87 int cpu_partial; /* Number of per cpu partial objects to keep around */
88 struct kmem_cache_order_objects oo; 88 struct kmem_cache_order_objects oo;