diff options
Diffstat (limited to 'include/linux/slub_def.h')
-rw-r--r-- | include/linux/slub_def.h | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index c6c1f4a120e3..0764c829d967 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -40,7 +40,6 @@ struct kmem_cache { | |||
40 | int objects; /* Number of objects in slab */ | 40 | int objects; /* Number of objects in slab */ |
41 | int refcount; /* Refcount for slab cache destroy */ | 41 | int refcount; /* Refcount for slab cache destroy */ |
42 | void (*ctor)(void *, struct kmem_cache *, unsigned long); | 42 | void (*ctor)(void *, struct kmem_cache *, unsigned long); |
43 | void (*dtor)(void *, struct kmem_cache *, unsigned long); | ||
44 | int inuse; /* Offset to metadata */ | 43 | int inuse; /* Offset to metadata */ |
45 | int align; /* Alignment */ | 44 | int align; /* Alignment */ |
46 | const char *name; /* Name (only for display!) */ | 45 | const char *name; /* Name (only for display!) */ |
@@ -59,17 +58,6 @@ struct kmem_cache { | |||
59 | */ | 58 | */ |
60 | #define KMALLOC_SHIFT_LOW 3 | 59 | #define KMALLOC_SHIFT_LOW 3 |
61 | 60 | ||
62 | #ifdef CONFIG_LARGE_ALLOCS | ||
63 | #define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT) =< 25 ? \ | ||
64 | (MAX_ORDER + PAGE_SHIFT - 1) : 25) | ||
65 | #else | ||
66 | #if !defined(CONFIG_MMU) || NR_CPUS > 512 || MAX_NUMNODES > 256 | ||
67 | #define KMALLOC_SHIFT_HIGH 20 | ||
68 | #else | ||
69 | #define KMALLOC_SHIFT_HIGH 18 | ||
70 | #endif | ||
71 | #endif | ||
72 | |||
73 | /* | 61 | /* |
74 | * We keep the general caches in an array of slab caches that are used for | 62 | * We keep the general caches in an array of slab caches that are used for |
75 | * 2^x bytes of allocations. | 63 | * 2^x bytes of allocations. |
@@ -80,7 +68,7 @@ extern struct kmem_cache kmalloc_caches[KMALLOC_SHIFT_HIGH + 1]; | |||
80 | * Sorry that the following has to be that ugly but some versions of GCC | 68 | * Sorry that the following has to be that ugly but some versions of GCC |
81 | * have trouble with constant propagation and loops. | 69 | * have trouble with constant propagation and loops. |
82 | */ | 70 | */ |
83 | static inline int kmalloc_index(int size) | 71 | static inline int kmalloc_index(size_t size) |
84 | { | 72 | { |
85 | /* | 73 | /* |
86 | * We should return 0 if size == 0 but we use the smallest object | 74 | * We should return 0 if size == 0 but we use the smallest object |
@@ -88,7 +76,7 @@ static inline int kmalloc_index(int size) | |||
88 | */ | 76 | */ |
89 | WARN_ON_ONCE(size == 0); | 77 | WARN_ON_ONCE(size == 0); |
90 | 78 | ||
91 | if (size > (1 << KMALLOC_SHIFT_HIGH)) | 79 | if (size > KMALLOC_MAX_SIZE) |
92 | return -1; | 80 | return -1; |
93 | 81 | ||
94 | if (size > 64 && size <= 96) | 82 | if (size > 64 && size <= 96) |
@@ -111,17 +99,13 @@ static inline int kmalloc_index(int size) | |||
111 | if (size <= 64 * 1024) return 16; | 99 | if (size <= 64 * 1024) return 16; |
112 | if (size <= 128 * 1024) return 17; | 100 | if (size <= 128 * 1024) return 17; |
113 | if (size <= 256 * 1024) return 18; | 101 | if (size <= 256 * 1024) return 18; |
114 | #if KMALLOC_SHIFT_HIGH > 18 | ||
115 | if (size <= 512 * 1024) return 19; | 102 | if (size <= 512 * 1024) return 19; |
116 | if (size <= 1024 * 1024) return 20; | 103 | if (size <= 1024 * 1024) return 20; |
117 | #endif | ||
118 | #if KMALLOC_SHIFT_HIGH > 20 | ||
119 | if (size <= 2 * 1024 * 1024) return 21; | 104 | if (size <= 2 * 1024 * 1024) return 21; |
120 | if (size <= 4 * 1024 * 1024) return 22; | 105 | if (size <= 4 * 1024 * 1024) return 22; |
121 | if (size <= 8 * 1024 * 1024) return 23; | 106 | if (size <= 8 * 1024 * 1024) return 23; |
122 | if (size <= 16 * 1024 * 1024) return 24; | 107 | if (size <= 16 * 1024 * 1024) return 24; |
123 | if (size <= 32 * 1024 * 1024) return 25; | 108 | if (size <= 32 * 1024 * 1024) return 25; |
124 | #endif | ||
125 | return -1; | 109 | return -1; |
126 | 110 | ||
127 | /* | 111 | /* |
@@ -146,7 +130,12 @@ static inline struct kmem_cache *kmalloc_slab(size_t size) | |||
146 | if (index == 0) | 130 | if (index == 0) |
147 | return NULL; | 131 | return NULL; |
148 | 132 | ||
149 | if (index < 0) { | 133 | /* |
134 | * This function only gets expanded if __builtin_constant_p(size), so | ||
135 | * testing it here shouldn't be needed. But some versions of gcc need | ||
136 | * help. | ||
137 | */ | ||
138 | if (__builtin_constant_p(size) && index < 0) { | ||
150 | /* | 139 | /* |
151 | * Generate a link failure. Would be great if we could | 140 | * Generate a link failure. Would be great if we could |
152 | * do something to stop the compile here. | 141 | * do something to stop the compile here. |