diff options
author | Christoph Lameter <clameter@sgi.com> | 2008-04-14 12:11:31 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@cs.helsinki.fi> | 2008-04-27 11:28:17 -0400 |
commit | 834f3d119234b35a1985a2449831d99356637937 (patch) | |
tree | 3106946ecbe174935daa7ac2ff4c7806cc3004b8 /include/linux/slub_def.h | |
parent | 224a88be40c45c0da5bdc45a8118004a37c60e8a (diff) |
slub: Add kmem_cache_order_objects struct
Pack the order and the number of objects into a single word.
This saves some memory in the kmem_cache_structure and more importantly
allows us to fetch both values atomically.
Later the slab orders become runtime configurable and we need to fetch these
two items together in order to properly allocate a slab and initialize its
objects.
Fix the race by fetching the order and the number of objects in one word.
[penberg@cs.helsinki.fi: fix memset() page order in new_slab()]
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'include/linux/slub_def.h')
-rw-r--r-- | include/linux/slub_def.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 79d59c937fac..4131e5fbd18b 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -53,6 +53,15 @@ struct kmem_cache_node { | |||
53 | }; | 53 | }; |
54 | 54 | ||
55 | /* | 55 | /* |
56 | * Word size structure that can be atomically updated or read and that | ||
57 | * contains both the order and the number of objects that a slab of the | ||
58 | * given order would contain. | ||
59 | */ | ||
60 | struct kmem_cache_order_objects { | ||
61 | unsigned long x; | ||
62 | }; | ||
63 | |||
64 | /* | ||
56 | * Slab cache management. | 65 | * Slab cache management. |
57 | */ | 66 | */ |
58 | struct kmem_cache { | 67 | struct kmem_cache { |
@@ -61,7 +70,7 @@ struct kmem_cache { | |||
61 | int size; /* The size of an object including meta data */ | 70 | int size; /* The size of an object including meta data */ |
62 | int objsize; /* The size of an object without meta data */ | 71 | int objsize; /* The size of an object without meta data */ |
63 | int offset; /* Free pointer offset. */ | 72 | int offset; /* Free pointer offset. */ |
64 | int order; /* Current preferred allocation order */ | 73 | struct kmem_cache_order_objects oo; |
65 | 74 | ||
66 | /* | 75 | /* |
67 | * Avoid an extra cache line for UP, SMP and for the node local to | 76 | * Avoid an extra cache line for UP, SMP and for the node local to |
@@ -70,7 +79,6 @@ struct kmem_cache { | |||
70 | struct kmem_cache_node local_node; | 79 | struct kmem_cache_node local_node; |
71 | 80 | ||
72 | /* Allocation and freeing of slabs */ | 81 | /* Allocation and freeing of slabs */ |
73 | int objects; /* Number of objects in slab */ | ||
74 | gfp_t allocflags; /* gfp flags to use on each alloc */ | 82 | gfp_t allocflags; /* gfp flags to use on each alloc */ |
75 | int refcount; /* Refcount for slab cache destroy */ | 83 | int refcount; /* Refcount for slab cache destroy */ |
76 | void (*ctor)(struct kmem_cache *, void *); | 84 | void (*ctor)(struct kmem_cache *, void *); |