Re: kmemleak: Protect the seq start/next/stop sequence byrcu_read_lock()

From: Catalin Marinas
Date: Wed Aug 12 2009 - 11:39:48 EST


On Wed, 2009-08-12 at 08:32 -0700, Linus Torvalds wrote:
>
> On Wed, 12 Aug 2009, Catalin Marinas wrote:
> >
> > If the object size is bigger than a predefined value (4K in this case),
> > release the object lock during scanning and call cond_resched().
>
> What guarantees that the object isn't released during this?

There is no guarantee but the while() loop rechecks that object->flags
still has the OBJECT_ALLOCATED bit set after every cond_resched():

+ 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);
+ }

It seems to be working fine with LTP running in parallel with kmemleak
scanning for nearly a day.

--
Catalin

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/