MIPS: Add missing VZ accessor microMIPS encodings
[linux-2.6-block.git] / include / linux / slab_def.h
CommitLineData
2e892f43
CL
1#ifndef _LINUX_SLAB_DEF_H
2#define _LINUX_SLAB_DEF_H
3
809fa972
HFS
4#include <linux/reciprocal_div.h>
5
2e892f43
CL
6/*
7 * Definitions unique to the original Linux SLAB allocator.
8eae985f
PE
8 */
9
10struct kmem_cache {
bf0dea23
JK
11 struct array_cache __percpu *cpu_cache;
12
24755e2e 13/* 1) Cache tunables. Protected by slab_mutex */
8eae985f
PE
14 unsigned int batchcount;
15 unsigned int limit;
16 unsigned int shared;
17
3b0efdfa 18 unsigned int size;
809fa972 19 struct reciprocal_value reciprocal_buffer_size;
b56efcf0 20/* 2) touched by every alloc & free from the backend */
8eae985f
PE
21
22 unsigned int flags; /* constant flags */
23 unsigned int num; /* # of objs per slab */
24
b56efcf0 25/* 3) cache_grow/shrink */
8eae985f
PE
26 /* order of pgs per slab (2^n) */
27 unsigned int gfporder;
28
29 /* force GFP flags, e.g. GFP_DMA */
a618e89f 30 gfp_t allocflags;
8eae985f
PE
31
32 size_t colour; /* cache colouring range */
33 unsigned int colour_off; /* colour offset */
8456a648
JK
34 struct kmem_cache *freelist_cache;
35 unsigned int freelist_size;
8eae985f
PE
36
37 /* constructor func */
38 void (*ctor)(void *obj);
39
b56efcf0 40/* 4) cache creation/removal */
8eae985f 41 const char *name;
3b0efdfa
CL
42 struct list_head list;
43 int refcount;
44 int object_size;
45 int align;
8eae985f 46
b56efcf0 47/* 5) statistics */
8eae985f
PE
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;
d31676df
JK
63#ifdef CONFIG_DEBUG_SLAB_LEAK
64 atomic_t store_user_clean;
65#endif
8eae985f
PE
66
67 /*
68 * If debugging is enabled, then the allocator can add additional
3b0efdfa 69 * fields and/or padding to every object. size contains the total
8eae985f
PE
70 * object size including these internal fields, the following two
71 * variables contain the offset to the user object and its size.
72 */
73 int obj_offset;
8eae985f 74#endif /* CONFIG_DEBUG_SLAB */
127424c8
JW
75
76#ifdef CONFIG_MEMCG
f7ce3190 77 struct memcg_cache_params memcg_params;
ba6c496e 78#endif
7ed2f9e6
AP
79#ifdef CONFIG_KASAN
80 struct kasan_cache kasan_info;
81#endif
8eae985f 82
bf0dea23 83 struct kmem_cache_node *node[MAX_NUMNODES];
8eae985f
PE
84};
85
7ed2f9e6
AP
86static inline void *nearest_obj(struct kmem_cache *cache, struct page *page,
87 void *x) {
88 void *object = x - (x - page->s_mem) % cache->size;
89 void *last_object = page->s_mem + (cache->num - 1) * cache->size;
90
91 if (unlikely(object > last_object))
92 return last_object;
93 else
94 return object;
95}
96
2e892f43 97#endif /* _LINUX_SLAB_DEF_H */