From: Andrew Morton Date: Thu, 14 Dec 2017 23:32:31 +0000 (-0800) Subject: mm/kmemleak.c: make cond_resched() rate-limiting more efficient X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3cb026dc28b774cf540c280a18bbdb1377b57535;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git mm/kmemleak.c: make cond_resched() rate-limiting more efficient commit 13ab183d138f607d885e995d625e58d47678bf97 upstream. Commit bde5f6bc68db ("kmemleak: add scheduling point to kmemleak_scan()") tries to rate-limit the frequency of cond_resched() calls, but does it in a way which might incur an expensive division operation in the inner loop. Simplify this. Fixes: bde5f6bc68db5 ("kmemleak: add scheduling point to kmemleak_scan()") Suggested-by: Linus Torvalds Cc: Yisheng Xie Cc: Catalin Marinas Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/kmemleak.c b/mm/kmemleak.c index d05133b37b17..59bb2b9ec0e2 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1442,7 +1442,7 @@ static void kmemleak_scan(void) if (page_count(page) == 0) continue; scan_block(page, page + 1, NULL); - if (!(pfn % (MAX_SCAN_SIZE / sizeof(*page)))) + if (!(pfn & 63)) cond_resched(); } }