Commit 61f47105a2c9c60e950ca808b7560f776f9bfa31
Committed by
Linus Torvalds
1 parent
07f361b2be
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
mm/sl[ao]b: always track caller in kmalloc_(node_)track_caller()
Now, we track caller if tracing or slab debugging is enabled. If they are disabled, we could save one argument passing overhead by calling __kmalloc(_node)(). But, I think that it would be marginal. Furthermore, default slab allocator, SLUB, doesn't use this technique so I think that it's okay to change this situation. After this change, we can turn on/off CONFIG_DEBUG_SLAB without full kernel build and remove some complicated '#if' defintion. It looks more benefitial to me. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 3 changed files with 0 additions and 42 deletions Side-by-side Diff
include/linux/slab.h
... | ... | @@ -549,37 +549,15 @@ |
549 | 549 | * allocator where we care about the real place the memory allocation |
550 | 550 | * request comes from. |
551 | 551 | */ |
552 | -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \ | |
553 | - (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \ | |
554 | - (defined(CONFIG_SLOB) && defined(CONFIG_TRACING)) | |
555 | 552 | extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long); |
556 | 553 | #define kmalloc_track_caller(size, flags) \ |
557 | 554 | __kmalloc_track_caller(size, flags, _RET_IP_) |
558 | -#else | |
559 | -#define kmalloc_track_caller(size, flags) \ | |
560 | - __kmalloc(size, flags) | |
561 | -#endif /* DEBUG_SLAB */ | |
562 | 555 | |
563 | 556 | #ifdef CONFIG_NUMA |
564 | -/* | |
565 | - * kmalloc_node_track_caller is a special version of kmalloc_node that | |
566 | - * records the calling function of the routine calling it for slab leak | |
567 | - * tracking instead of just the calling function (confusing, eh?). | |
568 | - * It's useful when the call to kmalloc_node comes from a widely-used | |
569 | - * standard allocator where we care about the real place the memory | |
570 | - * allocation request comes from. | |
571 | - */ | |
572 | -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \ | |
573 | - (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \ | |
574 | - (defined(CONFIG_SLOB) && defined(CONFIG_TRACING)) | |
575 | 557 | extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long); |
576 | 558 | #define kmalloc_node_track_caller(size, flags, node) \ |
577 | 559 | __kmalloc_node_track_caller(size, flags, node, \ |
578 | 560 | _RET_IP_) |
579 | -#else | |
580 | -#define kmalloc_node_track_caller(size, flags, node) \ | |
581 | - __kmalloc_node(size, flags, node) | |
582 | -#endif | |
583 | 561 | |
584 | 562 | #else /* CONFIG_NUMA */ |
585 | 563 |
mm/slab.c
... | ... | @@ -3496,7 +3496,6 @@ |
3496 | 3496 | return kmem_cache_alloc_node_trace(cachep, flags, node, size); |
3497 | 3497 | } |
3498 | 3498 | |
3499 | -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING) | |
3500 | 3499 | void *__kmalloc_node(size_t size, gfp_t flags, int node) |
3501 | 3500 | { |
3502 | 3501 | return __do_kmalloc_node(size, flags, node, _RET_IP_); |
... | ... | @@ -3509,13 +3508,6 @@ |
3509 | 3508 | return __do_kmalloc_node(size, flags, node, caller); |
3510 | 3509 | } |
3511 | 3510 | EXPORT_SYMBOL(__kmalloc_node_track_caller); |
3512 | -#else | |
3513 | -void *__kmalloc_node(size_t size, gfp_t flags, int node) | |
3514 | -{ | |
3515 | - return __do_kmalloc_node(size, flags, node, 0); | |
3516 | -} | |
3517 | -EXPORT_SYMBOL(__kmalloc_node); | |
3518 | -#endif /* CONFIG_DEBUG_SLAB || CONFIG_TRACING */ | |
3519 | 3511 | #endif /* CONFIG_NUMA */ |
3520 | 3512 | |
3521 | 3513 | /** |
... | ... | @@ -3541,8 +3533,6 @@ |
3541 | 3533 | return ret; |
3542 | 3534 | } |
3543 | 3535 | |
3544 | - | |
3545 | -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING) | |
3546 | 3536 | void *__kmalloc(size_t size, gfp_t flags) |
3547 | 3537 | { |
3548 | 3538 | return __do_kmalloc(size, flags, _RET_IP_); |
... | ... | @@ -3554,14 +3544,6 @@ |
3554 | 3544 | return __do_kmalloc(size, flags, caller); |
3555 | 3545 | } |
3556 | 3546 | EXPORT_SYMBOL(__kmalloc_track_caller); |
3557 | - | |
3558 | -#else | |
3559 | -void *__kmalloc(size_t size, gfp_t flags) | |
3560 | -{ | |
3561 | - return __do_kmalloc(size, flags, 0); | |
3562 | -} | |
3563 | -EXPORT_SYMBOL(__kmalloc); | |
3564 | -#endif | |
3565 | 3547 | |
3566 | 3548 | /** |
3567 | 3549 | * kmem_cache_free - Deallocate an object |
mm/slob.c
... | ... | @@ -468,7 +468,6 @@ |
468 | 468 | } |
469 | 469 | EXPORT_SYMBOL(__kmalloc); |
470 | 470 | |
471 | -#ifdef CONFIG_TRACING | |
472 | 471 | void *__kmalloc_track_caller(size_t size, gfp_t gfp, unsigned long caller) |
473 | 472 | { |
474 | 473 | return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, caller); |
... | ... | @@ -480,7 +479,6 @@ |
480 | 479 | { |
481 | 480 | return __do_kmalloc_node(size, gfp, node, caller); |
482 | 481 | } |
483 | -#endif | |
484 | 482 | #endif |
485 | 483 | |
486 | 484 | void kfree(const void *block) |