aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slob.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/slob.c')
-rw-r--r--mm/slob.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/mm/slob.c b/mm/slob.c
index 1264799df5d1..596152926a8d 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -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,6 +464,7 @@ 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;
466 468
467 lockdep_trace_alloc(flags); 469 lockdep_trace_alloc(flags);
468 470
@@ -471,21 +473,31 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
471 return ZERO_SIZE_PTR; 473 return ZERO_SIZE_PTR;
472 474
473 m = slob_alloc(size + align, gfp, align, node); 475 m = slob_alloc(size + align, gfp, align, node);
476
474 if (!m) 477 if (!m)
475 return NULL; 478 return NULL;
476 *m = size; 479 *m = size;
477 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);
478 } else { 485 } else {
479 void *ret; 486 unsigned int order = get_order(size);
480 487
481 ret = slob_new_page(gfp | __GFP_COMP, get_order(size), node); 488 ret = slob_new_page(gfp | __GFP_COMP, order, node);
482 if (ret) { 489 if (ret) {
483 struct page *page; 490 struct page *page;
484 page = virt_to_page(ret); 491 page = virt_to_page(ret);
485 page->private = size; 492 page->private = size;
486 } 493 }
487 return ret; 494
495 kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC,
496 _RET_IP_, ret,
497 size, PAGE_SIZE << order, gfp, node);
488 } 498 }
499
500 return ret;
489} 501}
490EXPORT_SYMBOL(__kmalloc_node); 502EXPORT_SYMBOL(__kmalloc_node);
491 503
@@ -503,6 +515,8 @@ void kfree(const void *block)
503 slob_free(m, *m + align); 515 slob_free(m, *m + align);
504 } else 516 } else
505 put_page(&sp->page); 517 put_page(&sp->page);
518
519 kmemtrace_mark_free(KMEMTRACE_TYPE_KMALLOC, _RET_IP_, block);
506} 520}
507EXPORT_SYMBOL(kfree); 521EXPORT_SYMBOL(kfree);
508 522
@@ -523,6 +537,7 @@ size_t ksize(const void *block)
523 } else 537 } else
524 return sp->page.private; 538 return sp->page.private;
525} 539}
540EXPORT_SYMBOL(ksize);
526 541
527struct kmem_cache { 542struct kmem_cache {
528 unsigned int size, align; 543 unsigned int size, align;
@@ -571,10 +586,19 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
571{ 586{
572 void *b; 587 void *b;
573 588
574 if (c->size < PAGE_SIZE) 589 if (c->size < PAGE_SIZE) {
575 b = slob_alloc(c->size, flags, c->align, node); 590 b = slob_alloc(c->size, flags, c->align, node);
576 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 {
577 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 }
578 602
579 if (c->ctor) 603 if (c->ctor)
580 c->ctor(b); 604 c->ctor(b);
@@ -610,6 +634,8 @@ void kmem_cache_free(struct kmem_cache *c, void *b)
610 } else { 634 } else {
611 __kmem_cache_free(b, c->size); 635 __kmem_cache_free(b, c->size);
612 } 636 }
637
638 kmemtrace_mark_free(KMEMTRACE_TYPE_CACHE, _RET_IP_, b);
613} 639}
614EXPORT_SYMBOL(kmem_cache_free); 640EXPORT_SYMBOL(kmem_cache_free);
615 641