]> Git Repo - linux.git/commitdiff
mm/kmemleak: move up cond_resched() call in page scanning loop
authorWaiman Long <[email protected]>
Fri, 25 Aug 2023 16:49:47 +0000 (12:49 -0400)
committerAndrew Morton <[email protected]>
Sat, 2 Sep 2023 22:17:34 +0000 (15:17 -0700)
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.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: bde5f6bc68db ("kmemleak: add scheduling point to kmemleak_scan()")
Signed-off-by: Waiman Long <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Yisheng Xie <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/kmemleak.c

index 2918150e31bd9c442d428e91d53dfb467823d2f8..54c2c90d3abc9de0ae7b3b4308eea5011794e322 100644 (file)
@@ -1584,6 +1584,9 @@ static void kmemleak_scan(void)
                for (pfn = start_pfn; pfn < end_pfn; pfn++) {
                        struct page *page = pfn_to_online_page(pfn);
 
+                       if (!(pfn & 63))
+                               cond_resched();
+
                        if (!page)
                                continue;
 
@@ -1594,8 +1597,6 @@ static void kmemleak_scan(void)
                        if (page_count(page) == 0)
                                continue;
                        scan_block(page, page + 1, NULL);
-                       if (!(pfn & 63))
-                               cond_resched();
                }
        }
        put_online_mems();
This page took 0.05673 seconds and 4 git commands to generate.