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=66feb16c0b4138fba64ff95aade75335f3bed699;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.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 706f705c2e0a..0b842160168b 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1520,7 +1520,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(); } }