This source file includes following definitions.
- sysfs_slab_unlink
- sysfs_slab_release
- nearest_obj
1
2 #ifndef _LINUX_SLUB_DEF_H
3 #define _LINUX_SLUB_DEF_H
4
5
6
7
8
9
10 #include <linux/kobject.h>
11
12 enum stat_item {
13 ALLOC_FASTPATH,
14 ALLOC_SLOWPATH,
15 FREE_FASTPATH,
16 FREE_SLOWPATH,
17 FREE_FROZEN,
18 FREE_ADD_PARTIAL,
19 FREE_REMOVE_PARTIAL,
20 ALLOC_FROM_PARTIAL,
21 ALLOC_SLAB,
22 ALLOC_REFILL,
23 ALLOC_NODE_MISMATCH,
24 FREE_SLAB,
25 CPUSLAB_FLUSH,
26 DEACTIVATE_FULL,
27 DEACTIVATE_EMPTY,
28 DEACTIVATE_TO_HEAD,
29 DEACTIVATE_TO_TAIL,
30 DEACTIVATE_REMOTE_FREES,
31 DEACTIVATE_BYPASS,
32 ORDER_FALLBACK,
33 CMPXCHG_DOUBLE_CPU_FAIL,
34 CMPXCHG_DOUBLE_FAIL,
35 CPU_PARTIAL_ALLOC,
36 CPU_PARTIAL_FREE,
37 CPU_PARTIAL_NODE,
38 CPU_PARTIAL_DRAIN,
39 NR_SLUB_STAT_ITEMS };
40
41 struct kmem_cache_cpu {
42 void **freelist;
43 unsigned long tid;
44 struct page *page;
45 #ifdef CONFIG_SLUB_CPU_PARTIAL
46 struct page *partial;
47 #endif
48 #ifdef CONFIG_SLUB_STATS
49 unsigned stat[NR_SLUB_STAT_ITEMS];
50 #endif
51 };
52
53 #ifdef CONFIG_SLUB_CPU_PARTIAL
54 #define slub_percpu_partial(c) ((c)->partial)
55
56 #define slub_set_percpu_partial(c, p) \
57 ({ \
58 slub_percpu_partial(c) = (p)->next; \
59 })
60
61 #define slub_percpu_partial_read_once(c) READ_ONCE(slub_percpu_partial(c))
62 #else
63 #define slub_percpu_partial(c) NULL
64
65 #define slub_set_percpu_partial(c, p)
66
67 #define slub_percpu_partial_read_once(c) NULL
68 #endif
69
70
71
72
73
74
75 struct kmem_cache_order_objects {
76 unsigned int x;
77 };
78
79
80
81
82 struct kmem_cache {
83 struct kmem_cache_cpu __percpu *cpu_slab;
84
85 slab_flags_t flags;
86 unsigned long min_partial;
87 unsigned int size;
88 unsigned int object_size;
89 unsigned int offset;
90 #ifdef CONFIG_SLUB_CPU_PARTIAL
91
92 unsigned int cpu_partial;
93 #endif
94 struct kmem_cache_order_objects oo;
95
96
97 struct kmem_cache_order_objects max;
98 struct kmem_cache_order_objects min;
99 gfp_t allocflags;
100 int refcount;
101 void (*ctor)(void *);
102 unsigned int inuse;
103 unsigned int align;
104 unsigned int red_left_pad;
105 const char *name;
106 struct list_head list;
107 #ifdef CONFIG_SYSFS
108 struct kobject kobj;
109 struct work_struct kobj_remove_work;
110 #endif
111 #ifdef CONFIG_MEMCG
112 struct memcg_cache_params memcg_params;
113
114 unsigned int max_attr_size;
115 #ifdef CONFIG_SYSFS
116 struct kset *memcg_kset;
117 #endif
118 #endif
119
120 #ifdef CONFIG_SLAB_FREELIST_HARDENED
121 unsigned long random;
122 #endif
123
124 #ifdef CONFIG_NUMA
125
126
127
128 unsigned int remote_node_defrag_ratio;
129 #endif
130
131 #ifdef CONFIG_SLAB_FREELIST_RANDOM
132 unsigned int *random_seq;
133 #endif
134
135 #ifdef CONFIG_KASAN
136 struct kasan_cache kasan_info;
137 #endif
138
139 unsigned int useroffset;
140 unsigned int usersize;
141
142 struct kmem_cache_node *node[MAX_NUMNODES];
143 };
144
145 #ifdef CONFIG_SLUB_CPU_PARTIAL
146 #define slub_cpu_partial(s) ((s)->cpu_partial)
147 #define slub_set_cpu_partial(s, n) \
148 ({ \
149 slub_cpu_partial(s) = (n); \
150 })
151 #else
152 #define slub_cpu_partial(s) (0)
153 #define slub_set_cpu_partial(s, n)
154 #endif
155
156 #ifdef CONFIG_SYSFS
157 #define SLAB_SUPPORTS_SYSFS
158 void sysfs_slab_unlink(struct kmem_cache *);
159 void sysfs_slab_release(struct kmem_cache *);
160 #else
161 static inline void sysfs_slab_unlink(struct kmem_cache *s)
162 {
163 }
164 static inline void sysfs_slab_release(struct kmem_cache *s)
165 {
166 }
167 #endif
168
169 void object_err(struct kmem_cache *s, struct page *page,
170 u8 *object, char *reason);
171
172 void *fixup_red_left(struct kmem_cache *s, void *p);
173
174 static inline void *nearest_obj(struct kmem_cache *cache, struct page *page,
175 void *x) {
176 void *object = x - (x - page_address(page)) % cache->size;
177 void *last_object = page_address(page) +
178 (page->objects - 1) * cache->size;
179 void *result = (unlikely(object > last_object)) ? last_object : object;
180
181 result = fixup_red_left(cache, result);
182 return result;
183 }
184
185 #endif