mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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. [[email protected]: fix memset() page order in new_slab()] Signed-off-by: Christoph Lameter <[email protected]> Signed-off-by: Pekka Enberg <[email protected]>
This commit is contained in:
parent
224a88be40
commit
834f3d1192
2 changed files with 61 additions and 27 deletions
|
|
@ -52,6 +52,15 @@ struct kmem_cache_node {
|
|||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* Word size structure that can be atomically updated or read and that
|
||||
* contains both the order and the number of objects that a slab of the
|
||||
* given order would contain.
|
||||
*/
|
||||
struct kmem_cache_order_objects {
|
||||
unsigned long x;
|
||||
};
|
||||
|
||||
/*
|
||||
* Slab cache management.
|
||||
*/
|
||||
|
|
@ -61,7 +70,7 @@ struct kmem_cache {
|
|||
int size; /* The size of an object including meta data */
|
||||
int objsize; /* The size of an object without meta data */
|
||||
int offset; /* Free pointer offset. */
|
||||
int order; /* Current preferred allocation order */
|
||||
struct kmem_cache_order_objects oo;
|
||||
|
||||
/*
|
||||
* Avoid an extra cache line for UP, SMP and for the node local to
|
||||
|
|
@ -70,7 +79,6 @@ struct kmem_cache {
|
|||
struct kmem_cache_node local_node;
|
||||
|
||||
/* Allocation and freeing of slabs */
|
||||
int objects; /* Number of objects in slab */
|
||||
gfp_t allocflags; /* gfp flags to use on each alloc */
|
||||
int refcount; /* Refcount for slab cache destroy */
|
||||
void (*ctor)(struct kmem_cache *, void *);
|
||||
|
|
|
|||
Loading…
Reference in a new issue