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#ifdef CONFIG_SYSFS
85 struct kobject kobj;
86#endif
87#ifdef CONFIG_MEMCG_KMEM
88 struct memcg_cache_params memcg_params;
89 int max_attr_size;
90#ifdef CONFIG_SYSFS
91 struct kset *memcg_kset;
92#endif
93#endif
94
95#ifdef CONFIG_NUMA
96
97
98
99 int remote_node_defrag_ratio;
100#endif
101 struct kmem_cache_node *node[MAX_NUMNODES];
102};
103
104#ifdef CONFIG_SYSFS
105#define SLAB_SUPPORTS_SYSFS
106void sysfs_slab_remove(struct kmem_cache *);
107#else
108static inline void sysfs_slab_remove(struct kmem_cache *s)
109{
110}
111#endif
112
113
114
115
116
117
118
119
120
121
122static inline void *virt_to_obj(struct kmem_cache *s,
123 const void *slab_page,
124 const void *x)
125{
126 return (void *)x - ((x - slab_page) % s->size);
127}
128
129void object_err(struct kmem_cache *s, struct page *page,
130 u8 *object, char *reason);
131
132#endif
133