From: Catalin Marinas <catalin.marinas@arm.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] kmemleak: Allow rescheduling during an object scanning
Date: Fri, 24 Jul 2009 17:12:13 +0100 [thread overview]
Message-ID: <20090724161213.5752.41867.stgit@pc1117.cambridge.arm.com> (raw)
In-Reply-To: <20090724161026.5752.52503.stgit@pc1117.cambridge.arm.com>
If the object size is bigger than a predefined value (4K in this case),
release the object lock during scanning and call cond_resched().
Re-acquire the lock after rescheduling and test whether the object is
still valid.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
mm/kmemleak.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 7e8e4b0..c665626 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -107,6 +107,7 @@
#define SECS_FIRST_SCAN 60 /* delay before the first scan */
#define SECS_SCAN_WAIT 600 /* subsequent auto scanning delay */
#define GRAY_LIST_PASSES 25 /* maximum number of gray list scans */
+#define MAX_SCAN_SIZE 4096 /* maximum size of a scanned block */
#define BYTES_PER_POINTER sizeof(void *)
@@ -950,10 +951,20 @@ static void scan_object(struct kmemleak_object *object)
if (!(object->flags & OBJECT_ALLOCATED))
/* already freed object */
goto out;
- if (hlist_empty(&object->area_list))
- scan_block((void *)object->pointer,
- (void *)(object->pointer + object->size), object, 0);
- else
+ if (hlist_empty(&object->area_list)) {
+ void *start = (void *)object->pointer;
+ void *end = (void *)(object->pointer + object->size);
+
+ while (start < end && (object->flags & OBJECT_ALLOCATED)) {
+ scan_block(start, min(start + MAX_SCAN_SIZE, end),
+ object, 0);
+ start += MAX_SCAN_SIZE;
+
+ spin_unlock_irqrestore(&object->lock, flags);
+ cond_resched();
+ spin_lock_irqsave(&object->lock, flags);
+ }
+ } else
hlist_for_each_entry(area, elem, &object->area_list, node)
scan_block((void *)(object->pointer + area->offset),
(void *)(object->pointer + area->offset
next prev parent reply other threads:[~2009-07-24 16:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-24 16:12 [PATCH 0/8] Kmemleak patches for 2.6.32 Catalin Marinas
2009-07-24 16:12 ` [PATCH 1/8] kmemleak: Dump object information on request Catalin Marinas
2009-07-24 16:12 ` Catalin Marinas [this message]
2009-07-24 16:12 ` [PATCH 3/8] kmemleak: Mark the early log buffer as __initdata Catalin Marinas
2009-07-24 16:12 ` [PATCH 4/8] kmemleak: Save the stack trace for early allocations Catalin Marinas
2009-07-24 16:12 ` [PATCH 5/8] kmemleak: Do not report alloc_bootmem blocks as leaks Catalin Marinas
2009-07-24 16:12 ` [PATCH 6/8] kmemleak: Printing of the objects hex dump Catalin Marinas
2009-07-24 16:12 ` [PATCH 7/8] kmemleak: Inform kmemleak about kernel stack allocation Catalin Marinas
2009-07-24 16:12 ` [PATCH 8/8] kmemleak: Always scan the task stacks Catalin Marinas
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=20090724161213.5752.41867.stgit@pc1117.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-kernel@vger.kernel.org \
/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®