diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-03-29 19:58:22 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-03-29 19:58:22 -0500 |
commit | 79072f38909e3d9883317238887460c39ddcc4cb (patch) | |
tree | 28369f5a844535ff836565eefd62695b0e890fa3 /include/linux/slab.h | |
parent | 200d5a7684cc49ef4be40e832daf3f217e70dfbb (diff) | |
parent | 55d8ca4f8094246da6e71889a4e04bfafaa78b10 (diff) |
Merge branch 'upstream'
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r-- | include/linux/slab.h | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 8cf52939d0ab..3af03b19c983 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -38,7 +38,6 @@ typedef struct kmem_cache kmem_cache_t; | |||
38 | #define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor (as verifier) */ | 38 | #define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor (as verifier) */ |
39 | #define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */ | 39 | #define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */ |
40 | #define SLAB_POISON 0x00000800UL /* Poison objects */ | 40 | #define SLAB_POISON 0x00000800UL /* Poison objects */ |
41 | #define SLAB_NO_REAP 0x00001000UL /* never reap from the cache */ | ||
42 | #define SLAB_HWCACHE_ALIGN 0x00002000UL /* align objs on a h/w cache lines */ | 41 | #define SLAB_HWCACHE_ALIGN 0x00002000UL /* align objs on a h/w cache lines */ |
43 | #define SLAB_CACHE_DMA 0x00004000UL /* use GFP_DMA memory */ | 42 | #define SLAB_CACHE_DMA 0x00004000UL /* use GFP_DMA memory */ |
44 | #define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* force alignment */ | 43 | #define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* force alignment */ |
@@ -47,6 +46,7 @@ typedef struct kmem_cache kmem_cache_t; | |||
47 | what is reclaimable later*/ | 46 | what is reclaimable later*/ |
48 | #define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */ | 47 | #define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */ |
49 | #define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */ | 48 | #define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */ |
49 | #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ | ||
50 | 50 | ||
51 | /* flags passed to a constructor func */ | 51 | /* flags passed to a constructor func */ |
52 | #define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */ | 52 | #define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */ |
@@ -64,6 +64,7 @@ extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned lo | |||
64 | extern int kmem_cache_destroy(kmem_cache_t *); | 64 | extern int kmem_cache_destroy(kmem_cache_t *); |
65 | extern int kmem_cache_shrink(kmem_cache_t *); | 65 | extern int kmem_cache_shrink(kmem_cache_t *); |
66 | extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); | 66 | extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); |
67 | extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); | ||
67 | extern void kmem_cache_free(kmem_cache_t *, void *); | 68 | extern void kmem_cache_free(kmem_cache_t *, void *); |
68 | extern unsigned int kmem_cache_size(kmem_cache_t *); | 69 | extern unsigned int kmem_cache_size(kmem_cache_t *); |
69 | extern const char *kmem_cache_name(kmem_cache_t *); | 70 | extern const char *kmem_cache_name(kmem_cache_t *); |
@@ -77,11 +78,12 @@ struct cache_sizes { | |||
77 | }; | 78 | }; |
78 | extern struct cache_sizes malloc_sizes[]; | 79 | extern struct cache_sizes malloc_sizes[]; |
79 | 80 | ||
80 | #ifndef CONFIG_DEBUG_SLAB | ||
81 | extern void *__kmalloc(size_t, gfp_t); | 81 | extern void *__kmalloc(size_t, gfp_t); |
82 | #ifndef CONFIG_DEBUG_SLAB | ||
83 | #define ____kmalloc(size, flags) __kmalloc(size, flags) | ||
82 | #else | 84 | #else |
83 | extern void *__kmalloc_track_caller(size_t, gfp_t, void*); | 85 | extern void *__kmalloc_track_caller(size_t, gfp_t, void*); |
84 | #define __kmalloc(size, flags) \ | 86 | #define ____kmalloc(size, flags) \ |
85 | __kmalloc_track_caller(size, flags, __builtin_return_address(0)) | 87 | __kmalloc_track_caller(size, flags, __builtin_return_address(0)) |
86 | #endif | 88 | #endif |
87 | 89 | ||
@@ -108,7 +110,30 @@ found: | |||
108 | return __kmalloc(size, flags); | 110 | return __kmalloc(size, flags); |
109 | } | 111 | } |
110 | 112 | ||
111 | extern void *kzalloc(size_t, gfp_t); | 113 | extern void *__kzalloc(size_t, gfp_t); |
114 | |||
115 | static inline void *kzalloc(size_t size, gfp_t flags) | ||
116 | { | ||
117 | if (__builtin_constant_p(size)) { | ||
118 | int i = 0; | ||
119 | #define CACHE(x) \ | ||
120 | if (size <= x) \ | ||
121 | goto found; \ | ||
122 | else \ | ||
123 | i++; | ||
124 | #include "kmalloc_sizes.h" | ||
125 | #undef CACHE | ||
126 | { | ||
127 | extern void __you_cannot_kzalloc_that_much(void); | ||
128 | __you_cannot_kzalloc_that_much(); | ||
129 | } | ||
130 | found: | ||
131 | return kmem_cache_zalloc((flags & GFP_DMA) ? | ||
132 | malloc_sizes[i].cs_dmacachep : | ||
133 | malloc_sizes[i].cs_cachep, flags); | ||
134 | } | ||
135 | return __kzalloc(size, flags); | ||
136 | } | ||
112 | 137 | ||
113 | /** | 138 | /** |
114 | * kcalloc - allocate memory for an array. The memory is set to zero. | 139 | * kcalloc - allocate memory for an array. The memory is set to zero. |
@@ -118,7 +143,7 @@ extern void *kzalloc(size_t, gfp_t); | |||
118 | */ | 143 | */ |
119 | static inline void *kcalloc(size_t n, size_t size, gfp_t flags) | 144 | static inline void *kcalloc(size_t n, size_t size, gfp_t flags) |
120 | { | 145 | { |
121 | if (n != 0 && size > INT_MAX / n) | 146 | if (n != 0 && size > ULONG_MAX / n) |
122 | return NULL; | 147 | return NULL; |
123 | return kzalloc(n * size, flags); | 148 | return kzalloc(n * size, flags); |
124 | } | 149 | } |
@@ -155,17 +180,18 @@ struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t, | |||
155 | void (*)(void *, struct kmem_cache *, unsigned long)); | 180 | void (*)(void *, struct kmem_cache *, unsigned long)); |
156 | int kmem_cache_destroy(struct kmem_cache *c); | 181 | int kmem_cache_destroy(struct kmem_cache *c); |
157 | void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); | 182 | void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); |
183 | void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); | ||
158 | void kmem_cache_free(struct kmem_cache *c, void *b); | 184 | void kmem_cache_free(struct kmem_cache *c, void *b); |
159 | const char *kmem_cache_name(struct kmem_cache *); | 185 | const char *kmem_cache_name(struct kmem_cache *); |
160 | void *kmalloc(size_t size, gfp_t flags); | 186 | void *kmalloc(size_t size, gfp_t flags); |
161 | void *kzalloc(size_t size, gfp_t flags); | 187 | void *__kzalloc(size_t size, gfp_t flags); |
162 | void kfree(const void *m); | 188 | void kfree(const void *m); |
163 | unsigned int ksize(const void *m); | 189 | unsigned int ksize(const void *m); |
164 | unsigned int kmem_cache_size(struct kmem_cache *c); | 190 | unsigned int kmem_cache_size(struct kmem_cache *c); |
165 | 191 | ||
166 | static inline void *kcalloc(size_t n, size_t size, gfp_t flags) | 192 | static inline void *kcalloc(size_t n, size_t size, gfp_t flags) |
167 | { | 193 | { |
168 | return kzalloc(n * size, flags); | 194 | return __kzalloc(n * size, flags); |
169 | } | 195 | } |
170 | 196 | ||
171 | #define kmem_cache_shrink(d) (0) | 197 | #define kmem_cache_shrink(d) (0) |
@@ -173,6 +199,8 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) | |||
173 | #define kmem_ptr_validate(a, b) (0) | 199 | #define kmem_ptr_validate(a, b) (0) |
174 | #define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f) | 200 | #define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f) |
175 | #define kmalloc_node(s, f, n) kmalloc(s, f) | 201 | #define kmalloc_node(s, f, n) kmalloc(s, f) |
202 | #define kzalloc(s, f) __kzalloc(s, f) | ||
203 | #define ____kmalloc kmalloc | ||
176 | 204 | ||
177 | #endif /* CONFIG_SLOB */ | 205 | #endif /* CONFIG_SLOB */ |
178 | 206 | ||
@@ -182,7 +210,6 @@ extern kmem_cache_t *names_cachep; | |||
182 | extern kmem_cache_t *files_cachep; | 210 | extern kmem_cache_t *files_cachep; |
183 | extern kmem_cache_t *filp_cachep; | 211 | extern kmem_cache_t *filp_cachep; |
184 | extern kmem_cache_t *fs_cachep; | 212 | extern kmem_cache_t *fs_cachep; |
185 | extern kmem_cache_t *signal_cachep; | ||
186 | extern kmem_cache_t *sighand_cachep; | 213 | extern kmem_cache_t *sighand_cachep; |
187 | extern kmem_cache_t *bio_cachep; | 214 | extern kmem_cache_t *bio_cachep; |
188 | 215 | ||