Skip to content

Commit 9a63236

Browse files
aryabinintorvalds
authored andcommitted
mm/ksm.c: don't WARN if page is still mapped in remove_stable_node()
It's possible to hit the WARN_ON_ONCE(page_mapped(page)) in remove_stable_node() when it races with __mmput() and squeezes in between ksm_exit() and exit_mmap(). WARNING: CPU: 0 PID: 3295 at mm/ksm.c:888 remove_stable_node+0x10c/0x150 Call Trace: remove_all_stable_nodes+0x12b/0x330 run_store+0x4ef/0x7b0 kernfs_fop_write+0x200/0x420 vfs_write+0x154/0x450 ksys_write+0xf9/0x1d0 do_syscall_64+0x99/0x510 entry_SYSCALL_64_after_hwframe+0x49/0xbe Remove the warning as there is nothing scary going on. Link: http://lkml.kernel.org/r/[email protected] Fixes: cbf86cf ("ksm: remove old stable nodes more thoroughly") Signed-off-by: Andrey Ryabinin <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7ce700b commit 9a63236

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mm/ksm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,13 @@ static int remove_stable_node(struct stable_node *stable_node)
885885
return 0;
886886
}
887887

888-
if (WARN_ON_ONCE(page_mapped(page))) {
889-
/*
890-
* This should not happen: but if it does, just refuse to let
891-
* merge_across_nodes be switched - there is no need to panic.
892-
*/
893-
err = -EBUSY;
894-
} else {
888+
/*
889+
* Page could be still mapped if this races with __mmput() running in
890+
* between ksm_exit() and exit_mmap(). Just refuse to let
891+
* merge_across_nodes/max_page_sharing be switched.
892+
*/
893+
err = -EBUSY;
894+
if (!page_mapped(page)) {
895895
/*
896896
* The stable node did not yet appear stale to get_ksm_page(),
897897
* since that allows for an unmapped ksm page to be recognized

0 commit comments

Comments
 (0)