diff options
Diffstat (limited to 'include/linux/slub_def.h')
-rw-r--r-- | include/linux/slub_def.h | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index e37b6aa8a9fb..a1f90528e70b 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/gfp.h> | 10 | #include <linux/gfp.h> |
11 | #include <linux/workqueue.h> | 11 | #include <linux/workqueue.h> |
12 | #include <linux/kobject.h> | 12 | #include <linux/kobject.h> |
13 | #include <trace/kmemtrace.h> | ||
13 | 14 | ||
14 | enum stat_item { | 15 | enum stat_item { |
15 | ALLOC_FASTPATH, /* Allocation from cpu slab */ | 16 | ALLOC_FASTPATH, /* Allocation from cpu slab */ |
@@ -217,13 +218,31 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size) | |||
217 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); | 218 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); |
218 | void *__kmalloc(size_t size, gfp_t flags); | 219 | void *__kmalloc(size_t size, gfp_t flags); |
219 | 220 | ||
221 | #ifdef CONFIG_KMEMTRACE | ||
222 | extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags); | ||
223 | #else | ||
224 | static __always_inline void * | ||
225 | kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags) | ||
226 | { | ||
227 | return kmem_cache_alloc(s, gfpflags); | ||
228 | } | ||
229 | #endif | ||
230 | |||
220 | static __always_inline void *kmalloc_large(size_t size, gfp_t flags) | 231 | static __always_inline void *kmalloc_large(size_t size, gfp_t flags) |
221 | { | 232 | { |
222 | return (void *)__get_free_pages(flags | __GFP_COMP, get_order(size)); | 233 | unsigned int order = get_order(size); |
234 | void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order); | ||
235 | |||
236 | kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, _THIS_IP_, ret, | ||
237 | size, PAGE_SIZE << order, flags); | ||
238 | |||
239 | return ret; | ||
223 | } | 240 | } |
224 | 241 | ||
225 | static __always_inline void *kmalloc(size_t size, gfp_t flags) | 242 | static __always_inline void *kmalloc(size_t size, gfp_t flags) |
226 | { | 243 | { |
244 | void *ret; | ||
245 | |||
227 | if (__builtin_constant_p(size)) { | 246 | if (__builtin_constant_p(size)) { |
228 | if (size > SLUB_MAX_SIZE) | 247 | if (size > SLUB_MAX_SIZE) |
229 | return kmalloc_large(size, flags); | 248 | return kmalloc_large(size, flags); |
@@ -234,7 +253,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) | |||
234 | if (!s) | 253 | if (!s) |
235 | return ZERO_SIZE_PTR; | 254 | return ZERO_SIZE_PTR; |
236 | 255 | ||
237 | return kmem_cache_alloc(s, flags); | 256 | ret = kmem_cache_alloc_notrace(s, flags); |
257 | |||
258 | kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, | ||
259 | _THIS_IP_, ret, | ||
260 | size, s->size, flags); | ||
261 | |||
262 | return ret; | ||
238 | } | 263 | } |
239 | } | 264 | } |
240 | return __kmalloc(size, flags); | 265 | return __kmalloc(size, flags); |
@@ -244,8 +269,24 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) | |||
244 | void *__kmalloc_node(size_t size, gfp_t flags, int node); | 269 | void *__kmalloc_node(size_t size, gfp_t flags, int node); |
245 | void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); | 270 | void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); |
246 | 271 | ||
272 | #ifdef CONFIG_KMEMTRACE | ||
273 | extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s, | ||
274 | gfp_t gfpflags, | ||
275 | int node); | ||
276 | #else | ||
277 | static __always_inline void * | ||
278 | kmem_cache_alloc_node_notrace(struct kmem_cache *s, | ||
279 | gfp_t gfpflags, | ||
280 | int node) | ||
281 | { | ||
282 | return kmem_cache_alloc_node(s, gfpflags, node); | ||
283 | } | ||
284 | #endif | ||
285 | |||
247 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) | 286 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) |
248 | { | 287 | { |
288 | void *ret; | ||
289 | |||
249 | if (__builtin_constant_p(size) && | 290 | if (__builtin_constant_p(size) && |
250 | size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) { | 291 | size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) { |
251 | struct kmem_cache *s = kmalloc_slab(size); | 292 | struct kmem_cache *s = kmalloc_slab(size); |
@@ -253,7 +294,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) | |||
253 | if (!s) | 294 | if (!s) |
254 | return ZERO_SIZE_PTR; | 295 | return ZERO_SIZE_PTR; |
255 | 296 | ||
256 | return kmem_cache_alloc_node(s, flags, node); | 297 | ret = kmem_cache_alloc_node_notrace(s, flags, node); |
298 | |||
299 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC, | ||
300 | _THIS_IP_, ret, | ||
301 | size, s->size, flags, node); | ||
302 | |||
303 | return ret; | ||
257 | } | 304 | } |
258 | return __kmalloc_node(size, flags, node); | 305 | return __kmalloc_node(size, flags, node); |
259 | } | 306 | } |