diff options
author | Waiman Long <longman@redhat.com> | 2017-01-05 15:17:03 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-02-04 03:01:54 -0500 |
commit | c4b73aabd0989d93b82894417ae501690bd1db5e (patch) | |
tree | 1f652ea5b9e58b83e86f299e321bb6e6b5732113 /lib/debugobjects.c | |
parent | 566cf877a1fcb6d6dc0126b076aad062054c2637 (diff) |
debugobjects: Track number of kmem_cache_alloc/kmem_cache_free done
New debugfs stat counters are added to track the numbers of
kmem_cache_alloc() and kmem_cache_free() function calls to get a
sense of how the internal debug objects cache management is performing.
Signed-off-by: Waiman Long <longman@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: "Du Changbin" <changbin.du@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Stancek <jstancek@redhat.com>
Link: http://lkml.kernel.org/r/1483647425-4135-2-git-send-email-longman@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'lib/debugobjects.c')
-rw-r--r-- | lib/debugobjects.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 04c1ef717fe0..d78673e7dc56 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c | |||
@@ -55,6 +55,12 @@ static int debug_objects_enabled __read_mostly | |||
55 | 55 | ||
56 | static struct debug_obj_descr *descr_test __read_mostly; | 56 | static struct debug_obj_descr *descr_test __read_mostly; |
57 | 57 | ||
58 | /* | ||
59 | * Track numbers of kmem_cache_alloc and kmem_cache_free done. | ||
60 | */ | ||
61 | static int debug_objects_alloc; | ||
62 | static int debug_objects_freed; | ||
63 | |||
58 | static void free_obj_work(struct work_struct *work); | 64 | static void free_obj_work(struct work_struct *work); |
59 | static DECLARE_WORK(debug_obj_work, free_obj_work); | 65 | static DECLARE_WORK(debug_obj_work, free_obj_work); |
60 | 66 | ||
@@ -102,6 +108,7 @@ static void fill_pool(void) | |||
102 | 108 | ||
103 | raw_spin_lock_irqsave(&pool_lock, flags); | 109 | raw_spin_lock_irqsave(&pool_lock, flags); |
104 | hlist_add_head(&new->node, &obj_pool); | 110 | hlist_add_head(&new->node, &obj_pool); |
111 | debug_objects_alloc++; | ||
105 | obj_pool_free++; | 112 | obj_pool_free++; |
106 | raw_spin_unlock_irqrestore(&pool_lock, flags); | 113 | raw_spin_unlock_irqrestore(&pool_lock, flags); |
107 | } | 114 | } |
@@ -173,6 +180,7 @@ static void free_obj_work(struct work_struct *work) | |||
173 | obj = hlist_entry(obj_pool.first, typeof(*obj), node); | 180 | obj = hlist_entry(obj_pool.first, typeof(*obj), node); |
174 | hlist_del(&obj->node); | 181 | hlist_del(&obj->node); |
175 | obj_pool_free--; | 182 | obj_pool_free--; |
183 | debug_objects_freed++; | ||
176 | /* | 184 | /* |
177 | * We release pool_lock across kmem_cache_free() to | 185 | * We release pool_lock across kmem_cache_free() to |
178 | * avoid contention on pool_lock. | 186 | * avoid contention on pool_lock. |
@@ -758,6 +766,8 @@ static int debug_stats_show(struct seq_file *m, void *v) | |||
758 | seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free); | 766 | seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free); |
759 | seq_printf(m, "pool_used :%d\n", obj_pool_used); | 767 | seq_printf(m, "pool_used :%d\n", obj_pool_used); |
760 | seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used); | 768 | seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used); |
769 | seq_printf(m, "objects_alloc :%d\n", debug_objects_alloc); | ||
770 | seq_printf(m, "objects_freed :%d\n", debug_objects_freed); | ||
761 | return 0; | 771 | return 0; |
762 | } | 772 | } |
763 | 773 | ||