summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorYisheng Xie <xieyisheng1@huawei.com>2017-11-29 16:11:08 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-03 17:04:29 +0100
commit51d2967fe5d518cbc17dcbe1db159a6e92eaa615 (patch)
tree02525ac08683524d786760a0d7b9c64063a3e9e5 /mm
parentff8417176a69482e40f30036b4e9eb07360ec759 (diff)
downloadlinux-stable-51d2967fe5d518cbc17dcbe1db159a6e92eaa615.tar.gz
linux-stable-51d2967fe5d518cbc17dcbe1db159a6e92eaa615.tar.bz2
linux-stable-51d2967fe5d518cbc17dcbe1db159a6e92eaa615.zip
kmemleak: add scheduling point to kmemleak_scan()
[ Upstream commit bde5f6bc68db51128f875a756e9082a6c6ff7b4c ] kmemleak_scan() will scan struct page for each node and it can be really large and resulting in a soft lockup. We have seen a soft lockup when do scan while compile kernel: watchdog: BUG: soft lockup - CPU#53 stuck for 22s! [bash:10287] [...] Call Trace: kmemleak_scan+0x21a/0x4c0 kmemleak_write+0x312/0x350 full_proxy_write+0x5a/0xa0 __vfs_write+0x33/0x150 vfs_write+0xad/0x1a0 SyS_write+0x52/0xc0 do_syscall_64+0x61/0x1a0 entry_SYSCALL64_slow_path+0x25/0x25 Fix this by adding cond_resched every MAX_SCAN_SIZE. Link: http://lkml.kernel.org/r/1511439788-20099-1-git-send-email-xieyisheng1@huawei.com Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com> Suggested-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: 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: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/kmemleak.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 19423a45d7d7..1914ab9009d9 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1394,6 +1394,8 @@ static void kmemleak_scan(void)
if (page_count(page) == 0)
continue;
scan_block(page, page + 1, NULL);
+ if (!(pfn % (MAX_SCAN_SIZE / sizeof(*page))))
+ cond_resched();
}
}
put_online_mems();