aboutsummaryrefslogtreecommitdiffstats
path: root/mm/kmemleak.c
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2009-06-26 12:38:29 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2009-06-26 12:38:29 -0400
commitacf4968ec9dea49387ca8b3d36dfaa0850bdb2d5 (patch)
tree5854dfdd96744a404a6222b9fc42aa54f9295313 /mm/kmemleak.c
parent4698c1f2bbe44ce852ef1a6716973c1f5401a4c4 (diff)
kmemleak: Slightly change the policy on newly allocated objects
Newly allocated objects are more likely to be reported as false positives. Kmemleak ignores the reporting of objects younger than 5 seconds. However, this age was calculated after the memory scanning completed which usually takes longer than 5 seconds. This patch make the minimum object age calculation in relation to the start of the memory scanning. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'mm/kmemleak.c')
-rw-r--r--mm/kmemleak.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index e96e0ec6a56e..c37e8e50e4de 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -190,7 +190,9 @@ static unsigned long max_addr;
190static unsigned long next_scan_yield; 190static unsigned long next_scan_yield;
191static struct task_struct *scan_thread; 191static struct task_struct *scan_thread;
192static unsigned long jiffies_scan_yield; 192static unsigned long jiffies_scan_yield;
193/* used to avoid reporting of recently allocated objects */
193static unsigned long jiffies_min_age; 194static unsigned long jiffies_min_age;
195static unsigned long jiffies_last_scan;
194/* delay between automatic memory scannings */ 196/* delay between automatic memory scannings */
195static signed long jiffies_scan_wait; 197static signed long jiffies_scan_wait;
196/* enables or disables the task stacks scanning */ 198/* enables or disables the task stacks scanning */
@@ -284,7 +286,8 @@ static int color_gray(const struct kmemleak_object *object)
284static int unreferenced_object(struct kmemleak_object *object) 286static int unreferenced_object(struct kmemleak_object *object)
285{ 287{
286 return (object->flags & OBJECT_ALLOCATED) && color_white(object) && 288 return (object->flags & OBJECT_ALLOCATED) && color_white(object) &&
287 time_is_before_eq_jiffies(object->jiffies + jiffies_min_age); 289 time_before_eq(object->jiffies + jiffies_min_age,
290 jiffies_last_scan);
288} 291}
289 292
290/* 293/*
@@ -927,6 +930,8 @@ static void kmemleak_scan(void)
927 int i; 930 int i;
928 int new_leaks = 0; 931 int new_leaks = 0;
929 932
933 jiffies_last_scan = jiffies;
934
930 /* prepare the kmemleak_object's */ 935 /* prepare the kmemleak_object's */
931 rcu_read_lock(); 936 rcu_read_lock();
932 list_for_each_entry_rcu(object, &object_list, object_list) { 937 list_for_each_entry_rcu(object, &object_list, object_list) {