1#ifndef _LINUX_SLUB_DEF_H
2#define _LINUX_SLUB_DEF_H
3
4
5
6
7
8
9#include <linux/kobject.h>
10
11enum stat_item {
12 ALLOC_FASTPATH,
13 ALLOC_SLOWPATH,
14 FREE_FASTPATH,
15 FREE_SLOWPATH,
16 FREE_FROZEN,
17 FREE_ADD_PARTIAL,
18 FREE_REMOVE_PARTIAL,
19 ALLOC_FROM_PARTIAL,
20 ALLOC_SLAB,
21 ALLOC_REFILL,
22 ALLOC_NODE_MISMATCH,
23 FREE_SLAB,
24 CPUSLAB_FLUSH,
25 DEACTIVATE_FULL,
26 DEACTIVATE_EMPTY,
27 DEACTIVATE_TO_HEAD,
28 DEACTIVATE_TO_TAIL,
29 DEACTIVATE_REMOTE_FREES,
30 DEACTIVATE_BYPASS,
31 ORDER_FALLBACK,
32 CMPXCHG_DOUBLE_CPU_FAIL,
33 CMPXCHG_DOUBLE_FAIL,
34 CPU_PARTIAL_ALLOC,
35 CPU_PARTIAL_FREE,
36 CPU_PARTIAL_NODE,
37 CPU_PARTIAL_DRAIN,
38 NR_SLUB_STAT_ITEMS };
39
40struct kmem_cache_cpu {
41 void **freelist;
42 unsigned long tid;
43 struct page *page;
44 struct page *partial;
45#ifdef CONFIG_SLUB_STATS
46 unsigned stat[NR_SLUB_STAT_ITEMS];
47#endif
48};
49
50
51
52
53
54
55struct kmem_cache_order_objects {
56 unsigned long x;
57};
58
59
60
61
62struct kmem_cache {
63 struct kmem_cache_cpu __percpu *cpu_slab;
64
65 unsigned long flags;
66 unsigned long min_partial;
67 int size;
68 int object_size;
69 int offset;
70 int cpu_partial;
71 struct kmem_cache_order_objects oo;
72
73
74 struct kmem_cache_order_objects max;
75 struct kmem_cache_order_objects min;
76 gfp_t allocflags;
77 int refcount;
78 void (*ctor)(void *);
79 int inuse;
80 int align;
81 int reserved;
82 const char *name;
83 struct list_head list;
84 int red_left_pad;
85#ifdef CONFIG_SYSFS
86 struct kobject kobj;
87#endif
88#ifdef CONFIG_MEMCG
89 struct memcg_cache_params memcg_params;
90 int max_attr_size;
91#ifdef CONFIG_SYSFS
92 struct kset *memcg_kset;
93#endif
94#endif
95
96#ifdef CONFIG_NUMA
97
98
99
100 int remote_node_defrag_ratio;
101#endif
102 struct kmem_cache_node *node[MAX_NUMNODES];
103};
104
105#ifdef CONFIG_SYSFS
106#define SLAB_SUPPORTS_SYSFS
107void sysfs_slab_remove(struct kmem_cache *);
108#else
109static inline void sysfs_slab_remove(struct kmem_cache *s)
110{
111}
112#endif
113
114
115
116
117
118
119
120
121
122
123static inline void *virt_to_obj(struct kmem_cache *s,
124 const void *slab_page,
125 const void *x)
126{
127 return (void *)x - ((x - slab_page) % s->size);
128}
129
130void object_err(struct kmem_cache *s, struct page *page,
131 u8 *object, char *reason);
132
133static inline void *nearest_obj(struct kmem_cache *cache, struct page *page,
134 void *x) {
135 void *object = x - (x - page_address(page)) % cache->size;
136 void *last_object = page_address(page) +
137 (page->objects - 1) * cache->size;
138 if (unlikely(object > last_object))
139 return last_object;
140 else
141 return object;
142}
143
144#endif
145