Re: [PATCH] mm/kmemleak: Move up cond_resched() call in page scanning loop

From: Catalin Marinas
Date: Sun Aug 27 2023 - 09:08:55 EST


On Fri, Aug 25, 2023 at 12:49:47PM -0400, Waiman Long wrote:
> Commit bde5f6bc68db ("kmemleak: add scheduling point to kmemleak_scan()")
> added a cond_resched() call to the struct page scanning loop to prevent
> soft lockup from happening. However, soft lockup can still happen in
> that loop in some corner cases when the pages that satisfy the "!(pfn &
> 63)" check are skipped for some reasons.
>
> Fix this corner case by moving up the cond_resched() check so that it
> will be called every 64 pages unconditionally.
>
> Fixes: bde5f6bc68db ("kmemleak: add scheduling point to kmemleak_scan()")
> Signed-off-by: Waiman Long <longman@xxxxxxxxxx>

Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx>