* [PATCH v2] kmemleak: add scheduling point to kmemleak_scan
@ 2017-11-23 12:23 ` Yisheng Xie
0 siblings, 0 replies; 4+ messages in thread
From: Yisheng Xie @ 2017-11-23 12:23 UTC (permalink / raw)
To: akpm, catalin.marinas, mhocko; +Cc: linux-mm, linux-kernel, xieyisheng1
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:
[ 220.561051] watchdog: BUG: soft lockup - CPU#53 stuck for 22s! [bash:10287]
[...]
[ 220.753837] Call Trace:
[ 220.756296] kmemleak_scan+0x21a/0x4c0
[ 220.760034] kmemleak_write+0x312/0x350
[ 220.763866] ? do_wp_page+0x147/0x4c0
[ 220.767521] full_proxy_write+0x5a/0xa0
[ 220.771351] __vfs_write+0x33/0x150
[ 220.774833] ? __inode_security_revalidate+0x4c/0x60
[ 220.779782] ? selinux_file_permission+0xda/0x130
[ 220.784479] ? _cond_resched+0x15/0x30
[ 220.788221] vfs_write+0xad/0x1a0
[ 220.791529] SyS_write+0x52/0xc0
[ 220.794758] do_syscall_64+0x61/0x1a0
[ 220.798411] entry_SYSCALL64_slow_path+0x25/0x25
Fix this by adding cond_resched every MAX_SCAN_SIZE.
Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
v2:
* call cond_resched() every MAX_SCAN_SIZE for consistency with the other places
* fix the subject of the patch. - Both per Catalin
mm/kmemleak.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index e4738d5..3d47817 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1523,6 +1523,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();
--
1.7.12.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] kmemleak: add scheduling point to kmemleak_scan
@ 2017-11-23 12:23 ` Yisheng Xie
0 siblings, 0 replies; 4+ messages in thread
From: Yisheng Xie @ 2017-11-23 12:23 UTC (permalink / raw)
To: akpm, catalin.marinas, mhocko; +Cc: linux-mm, linux-kernel, xieyisheng1
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:
[ 220.561051] watchdog: BUG: soft lockup - CPU#53 stuck for 22s! [bash:10287]
[...]
[ 220.753837] Call Trace:
[ 220.756296] kmemleak_scan+0x21a/0x4c0
[ 220.760034] kmemleak_write+0x312/0x350
[ 220.763866] ? do_wp_page+0x147/0x4c0
[ 220.767521] full_proxy_write+0x5a/0xa0
[ 220.771351] __vfs_write+0x33/0x150
[ 220.774833] ? __inode_security_revalidate+0x4c/0x60
[ 220.779782] ? selinux_file_permission+0xda/0x130
[ 220.784479] ? _cond_resched+0x15/0x30
[ 220.788221] vfs_write+0xad/0x1a0
[ 220.791529] SyS_write+0x52/0xc0
[ 220.794758] do_syscall_64+0x61/0x1a0
[ 220.798411] entry_SYSCALL64_slow_path+0x25/0x25
Fix this by adding cond_resched every MAX_SCAN_SIZE.
Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
v2:
* call cond_resched() every MAX_SCAN_SIZE for consistency with the other places
* fix the subject of the patch. - Both per Catalin
mm/kmemleak.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index e4738d5..3d47817 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1523,6 +1523,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();
--
1.7.12.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] kmemleak: add scheduling point to kmemleak_scan
2017-11-23 12:23 ` Yisheng Xie
@ 2017-11-23 14:38 ` Catalin Marinas
-1 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2017-11-23 14:38 UTC (permalink / raw)
To: Yisheng Xie; +Cc: akpm, mhocko, linux-mm, linux-kernel
On Thu, Nov 23, 2017 at 08:23:08PM +0800, Yisheng Xie wrote:
> 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:
>
> [ 220.561051] watchdog: BUG: soft lockup - CPU#53 stuck for 22s! [bash:10287]
> [...]
> [ 220.753837] Call Trace:
> [ 220.756296] kmemleak_scan+0x21a/0x4c0
> [ 220.760034] kmemleak_write+0x312/0x350
> [ 220.763866] ? do_wp_page+0x147/0x4c0
> [ 220.767521] full_proxy_write+0x5a/0xa0
> [ 220.771351] __vfs_write+0x33/0x150
> [ 220.774833] ? __inode_security_revalidate+0x4c/0x60
> [ 220.779782] ? selinux_file_permission+0xda/0x130
> [ 220.784479] ? _cond_resched+0x15/0x30
> [ 220.788221] vfs_write+0xad/0x1a0
> [ 220.791529] SyS_write+0x52/0xc0
> [ 220.794758] do_syscall_64+0x61/0x1a0
> [ 220.798411] entry_SYSCALL64_slow_path+0x25/0x25
>
> Fix this by adding cond_resched every MAX_SCAN_SIZE.
>
> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] kmemleak: add scheduling point to kmemleak_scan
@ 2017-11-23 14:38 ` Catalin Marinas
0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2017-11-23 14:38 UTC (permalink / raw)
To: Yisheng Xie; +Cc: akpm, mhocko, linux-mm, linux-kernel
On Thu, Nov 23, 2017 at 08:23:08PM +0800, Yisheng Xie wrote:
> 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:
>
> [ 220.561051] watchdog: BUG: soft lockup - CPU#53 stuck for 22s! [bash:10287]
> [...]
> [ 220.753837] Call Trace:
> [ 220.756296] kmemleak_scan+0x21a/0x4c0
> [ 220.760034] kmemleak_write+0x312/0x350
> [ 220.763866] ? do_wp_page+0x147/0x4c0
> [ 220.767521] full_proxy_write+0x5a/0xa0
> [ 220.771351] __vfs_write+0x33/0x150
> [ 220.774833] ? __inode_security_revalidate+0x4c/0x60
> [ 220.779782] ? selinux_file_permission+0xda/0x130
> [ 220.784479] ? _cond_resched+0x15/0x30
> [ 220.788221] vfs_write+0xad/0x1a0
> [ 220.791529] SyS_write+0x52/0xc0
> [ 220.794758] do_syscall_64+0x61/0x1a0
> [ 220.798411] entry_SYSCALL64_slow_path+0x25/0x25
>
> Fix this by adding cond_resched every MAX_SCAN_SIZE.
>
> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-23 14:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 12:23 [PATCH v2] kmemleak: add scheduling point to kmemleak_scan Yisheng Xie
2017-11-23 12:23 ` Yisheng Xie
2017-11-23 14:38 ` Catalin Marinas
2017-11-23 14:38 ` Catalin Marinas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.