Skip to contentSkip to conversation

mm/kmemleak.c: make cond_resched() rate-limiting more efficient

PATCH New [email protected] 1 participant 1 message Dec 14, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 3/17 mm/kmemleak.c: make cond_resched() rate-limiting more efficient

From: Andrew Morton <[email protected]>
Subject: mm/kmemleak.c: make cond_resched() rate-limiting more efficient

bde5f6bc68db5 ("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()")
Cc Yisheng Xie <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Michal Hocko <[email protected]>

---

 mm/kmemleak.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c renamed from mm/kmemleak.c~mm-kmemleakc-make-cond_resched-rate-limiting-more-efficient +1 -1
diff -puN mm/kmemleak.c~mm-kmemleakc-make-cond_resched-rate-limiting-more-efficient mm/kmemleak.c
@@ -1523,7 +1523,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();
 		}
 	}

_