diff options
Diffstat (limited to 'mm/slob.c')
-rw-r--r-- | mm/slob.c | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -65,6 +65,7 @@ | |||
65 | #include <linux/module.h> | 65 | #include <linux/module.h> |
66 | #include <linux/rcupdate.h> | 66 | #include <linux/rcupdate.h> |
67 | #include <linux/list.h> | 67 | #include <linux/list.h> |
68 | #include <trace/kmemtrace.h> | ||
68 | #include <asm/atomic.h> | 69 | #include <asm/atomic.h> |
69 | 70 | ||
70 | /* | 71 | /* |
@@ -463,27 +464,40 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node) | |||
463 | { | 464 | { |
464 | unsigned int *m; | 465 | unsigned int *m; |
465 | int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); | 466 | int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); |
467 | void *ret; | ||
468 | |||
469 | lockdep_trace_alloc(flags); | ||
466 | 470 | ||
467 | if (size < PAGE_SIZE - align) { | 471 | if (size < PAGE_SIZE - align) { |
468 | if (!size) | 472 | if (!size) |
469 | return ZERO_SIZE_PTR; | 473 | return ZERO_SIZE_PTR; |
470 | 474 | ||
471 | m = slob_alloc(size + align, gfp, align, node); | 475 | m = slob_alloc(size + align, gfp, align, node); |
476 | |||
472 | if (!m) | 477 | if (!m) |
473 | return NULL; | 478 | return NULL; |
474 | *m = size; | 479 | *m = size; |
475 | return (void *)m + align; | 480 | ret = (void *)m + align; |
481 | |||
482 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC, | ||
483 | _RET_IP_, ret, | ||
484 | size, size + align, gfp, node); | ||
476 | } else { | 485 | } else { |
477 | void *ret; | 486 | unsigned int order = get_order(size); |
478 | 487 | ||
479 | ret = slob_new_page(gfp | __GFP_COMP, get_order(size), node); | 488 | ret = slob_new_page(gfp | __GFP_COMP, order, node); |
480 | if (ret) { | 489 | if (ret) { |
481 | struct page *page; | 490 | struct page *page; |
482 | page = virt_to_page(ret); | 491 | page = virt_to_page(ret); |
483 | page->private = size; | 492 | page->private = size; |
484 | } | 493 | } |
485 | return ret; | 494 | |
495 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC, | ||
496 | _RET_IP_, ret, | ||
497 | size, PAGE_SIZE << order, gfp, node); | ||
486 | } | 498 | } |
499 | |||
500 | return ret; | ||
487 | } | 501 | } |
488 | EXPORT_SYMBOL(__kmalloc_node); | 502 | EXPORT_SYMBOL(__kmalloc_node); |
489 | 503 | ||
@@ -501,6 +515,8 @@ void kfree(const void *block) | |||
501 | slob_free(m, *m + align); | 515 | slob_free(m, *m + align); |
502 | } else | 516 | } else |
503 | put_page(&sp->page); | 517 | put_page(&sp->page); |
518 | |||
519 | kmemtrace_mark_free(KMEMTRACE_TYPE_KMALLOC, _RET_IP_, block); | ||
504 | } | 520 | } |
505 | EXPORT_SYMBOL(kfree); | 521 | EXPORT_SYMBOL(kfree); |
506 | 522 | ||
@@ -570,10 +586,19 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node) | |||
570 | { | 586 | { |
571 | void *b; | 587 | void *b; |
572 | 588 | ||
573 | if (c->size < PAGE_SIZE) | 589 | if (c->size < PAGE_SIZE) { |
574 | b = slob_alloc(c->size, flags, c->align, node); | 590 | b = slob_alloc(c->size, flags, c->align, node); |
575 | else | 591 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_CACHE, |
592 | _RET_IP_, b, c->size, | ||
593 | SLOB_UNITS(c->size) * SLOB_UNIT, | ||
594 | flags, node); | ||
595 | } else { | ||
576 | b = slob_new_page(flags, get_order(c->size), node); | 596 | b = slob_new_page(flags, get_order(c->size), node); |
597 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_CACHE, | ||
598 | _RET_IP_, b, c->size, | ||
599 | PAGE_SIZE << get_order(c->size), | ||
600 | flags, node); | ||
601 | } | ||
577 | 602 | ||
578 | if (c->ctor) | 603 | if (c->ctor) |
579 | c->ctor(b); | 604 | c->ctor(b); |
@@ -609,6 +634,8 @@ void kmem_cache_free(struct kmem_cache *c, void *b) | |||
609 | } else { | 634 | } else { |
610 | __kmem_cache_free(b, c->size); | 635 | __kmem_cache_free(b, c->size); |
611 | } | 636 | } |
637 | |||
638 | kmemtrace_mark_free(KMEMTRACE_TYPE_CACHE, _RET_IP_, b); | ||
612 | } | 639 | } |
613 | EXPORT_SYMBOL(kmem_cache_free); | 640 | EXPORT_SYMBOL(kmem_cache_free); |
614 | 641 | ||