mm/kmemleak.c: make cond_resched() rate-limiting more efficient
authorAndrew Morton <akpm@linux-foundation.org>
Thu, 14 Dec 2017 23:32:31 +0000 (15:32 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 09:42:57 +0000 (11:42 +0200)
commit3cb026dc28b774cf540c280a18bbdb1377b57535
tree6dbd62bf762eb1b646402e9b6ed8878ba29453ec
parent2e454ae63b4c6086fdd21ac3f8810071df2c2e1d
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 <torvalds@linux-foundation.org>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/kmemleak.c