Christoph Lameter | 2e892f4 | 2006-12-13 00:34:23 -0800 | [diff] [blame] | 1 | #ifndef _LINUX_SLAB_DEF_H |
| 2 | #define _LINUX_SLAB_DEF_H |
| 3 | |
Hannes Frederic Sowa | 809fa97 | 2014-01-22 02:29:41 +0100 | [diff] [blame] | 4 | #include <linux/reciprocal_div.h> |
| 5 | |
Christoph Lameter | 2e892f4 | 2006-12-13 00:34:23 -0800 | [diff] [blame] | 6 | /* |
| 7 | * Definitions unique to the original Linux SLAB allocator. |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | struct kmem_cache { |
Joonsoo Kim | bf0dea2 | 2014-10-09 15:26:27 -0700 | [diff] [blame] | 11 | struct array_cache __percpu *cpu_cache; |
| 12 | |
Fam Zheng | 24755e2 | 2014-01-21 09:12:42 +0800 | [diff] [blame] | 13 | /* 1) Cache tunables. Protected by slab_mutex */ |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 14 | unsigned int batchcount; |
| 15 | unsigned int limit; |
| 16 | unsigned int shared; |
| 17 | |
Christoph Lameter | 3b0efdf | 2012-06-13 10:24:57 -0500 | [diff] [blame] | 18 | unsigned int size; |
Hannes Frederic Sowa | 809fa97 | 2014-01-22 02:29:41 +0100 | [diff] [blame] | 19 | struct reciprocal_value reciprocal_buffer_size; |
Eric Dumazet | b56efcf | 2011-07-20 19:04:23 +0200 | [diff] [blame] | 20 | /* 2) touched by every alloc & free from the backend */ |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 21 | |
| 22 | unsigned int flags; /* constant flags */ |
| 23 | unsigned int num; /* # of objs per slab */ |
| 24 | |
Eric Dumazet | b56efcf | 2011-07-20 19:04:23 +0200 | [diff] [blame] | 25 | /* 3) cache_grow/shrink */ |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 26 | /* order of pgs per slab (2^n) */ |
| 27 | unsigned int gfporder; |
| 28 | |
| 29 | /* force GFP flags, e.g. GFP_DMA */ |
Glauber Costa | a618e89 | 2012-06-14 16:17:21 +0400 | [diff] [blame] | 30 | gfp_t allocflags; |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 31 | |
| 32 | size_t colour; /* cache colouring range */ |
| 33 | unsigned int colour_off; /* colour offset */ |
Joonsoo Kim | 8456a64 | 2013-10-24 10:07:49 +0900 | [diff] [blame] | 34 | struct kmem_cache *freelist_cache; |
| 35 | unsigned int freelist_size; |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 36 | |
| 37 | /* constructor func */ |
| 38 | void (*ctor)(void *obj); |
| 39 | |
Eric Dumazet | b56efcf | 2011-07-20 19:04:23 +0200 | [diff] [blame] | 40 | /* 4) cache creation/removal */ |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 41 | const char *name; |
Christoph Lameter | 3b0efdf | 2012-06-13 10:24:57 -0500 | [diff] [blame] | 42 | struct list_head list; |
| 43 | int refcount; |
| 44 | int object_size; |
| 45 | int align; |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 46 | |
Eric Dumazet | b56efcf | 2011-07-20 19:04:23 +0200 | [diff] [blame] | 47 | /* 5) statistics */ |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 48 | #ifdef CONFIG_DEBUG_SLAB |
| 49 | unsigned long num_active; |
| 50 | unsigned long num_allocations; |
| 51 | unsigned long high_mark; |
| 52 | unsigned long grown; |
| 53 | unsigned long reaped; |
| 54 | unsigned long errors; |
| 55 | unsigned long max_freeable; |
| 56 | unsigned long node_allocs; |
| 57 | unsigned long node_frees; |
| 58 | unsigned long node_overflow; |
| 59 | atomic_t allochit; |
| 60 | atomic_t allocmiss; |
| 61 | atomic_t freehit; |
| 62 | atomic_t freemiss; |
| 63 | |
| 64 | /* |
| 65 | * If debugging is enabled, then the allocator can add additional |
Christoph Lameter | 3b0efdf | 2012-06-13 10:24:57 -0500 | [diff] [blame] | 66 | * fields and/or padding to every object. size contains the total |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 67 | * object size including these internal fields, the following two |
| 68 | * variables contain the offset to the user object and its size. |
| 69 | */ |
| 70 | int obj_offset; |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 71 | #endif /* CONFIG_DEBUG_SLAB */ |
Glauber Costa | ba6c496 | 2012-12-18 14:22:27 -0800 | [diff] [blame] | 72 | #ifdef CONFIG_MEMCG_KMEM |
| 73 | struct memcg_cache_params *memcg_params; |
| 74 | #endif |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 75 | |
Joonsoo Kim | bf0dea2 | 2014-10-09 15:26:27 -0700 | [diff] [blame] | 76 | struct kmem_cache_node *node[MAX_NUMNODES]; |
Pekka Enberg | 8eae985 | 2008-05-09 20:32:44 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
Christoph Lameter | 2e892f4 | 2006-12-13 00:34:23 -0800 | [diff] [blame] | 79 | #endif /* _LINUX_SLAB_DEF_H */ |