mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: linux-kernel@vger.kernel.org
Cc: Dave Jones <davej@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Sergey Senozhatsky <sergey.senozhatsky@mail.by>
Subject: [PATCH 4/4] kmemleak: Slightly change the policy on newly allocated objects
Date: Fri, 26 Jun 2009 15:12:58 +0100	[thread overview]
Message-ID: <20090626141258.31504.36983.stgit@pc1117.cambridge.arm.com> (raw)
In-Reply-To: <20090626140847.31504.79381.stgit@pc1117.cambridge.arm.com>

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>
---
 mm/kmemleak.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index e96e0ec..c37e8e5 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -190,7 +190,9 @@ static unsigned long max_addr;
 static unsigned long next_scan_yield;
 static struct task_struct *scan_thread;
 static unsigned long jiffies_scan_yield;
+/* used to avoid reporting of recently allocated objects */
 static unsigned long jiffies_min_age;
+static unsigned long jiffies_last_scan;
 /* delay between automatic memory scannings */
 static signed long jiffies_scan_wait;
 /* enables or disables the task stacks scanning */
@@ -284,7 +286,8 @@ static int color_gray(const struct kmemleak_object *object)
 static int unreferenced_object(struct kmemleak_object *object)
 {
 	return (object->flags & OBJECT_ALLOCATED) && color_white(object) &&
-		time_is_before_eq_jiffies(object->jiffies + jiffies_min_age);
+		time_before_eq(object->jiffies + jiffies_min_age,
+			       jiffies_last_scan);
 }
 
 /*
@@ -927,6 +930,8 @@ static void kmemleak_scan(void)
 	int i;
 	int new_leaks = 0;
 
+	jiffies_last_scan = jiffies;
+
 	/* prepare the kmemleak_object's */
 	rcu_read_lock();
 	list_for_each_entry_rcu(object, &object_list, object_list) {


      parent reply	other threads:[~2009-06-26 14:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-26 14:12 [PATCH 0/4] Kmemleak improvements on false positives Catalin Marinas
2009-06-26 14:12 ` [PATCH 1/4] kmemleak: Enable task stacks scanning by default Catalin Marinas
2009-06-26 14:12 ` [PATCH 2/4] kmemleak: Simplify the reports logged by the scanning thread Catalin Marinas
2009-06-26 14:12 ` [PATCH 3/4] kmemleak: Do not trigger a scan when reading the debug/kmemleak file Catalin Marinas
2009-06-26 14:12 ` Catalin Marinas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090626141258.31504.36983.stgit@pc1117.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=sergey.senozhatsky@mail.by \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®