Hang with v4.15-rc trying to swap back in
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Reverting these three patches fixes the problem:
commit aa8d22a11da933dbf880b4933b58931f4aefe91c
Author: Minchan Kim <[email protected]>
Date:A A A Wed Nov 15 17:33:11 2017 -0800
A A A A mm: swap: SWP_SYNCHRONOUS_IO: skip swapcache only if swapped page has no other reference
commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]>
Date:A A A Wed Nov 15 17:33:07 2017 -0800
A A A A mm, swap: skip swapcache for swapin of synchronous device
Also need to revert:
commit e9a6effa500526e2a19d5ad042cb758b55b1ef93
Author: Huang Ying <[email protected]>
Date:A A A Wed Nov 15 17:33:15 2017 -0800
A A A A mm, swap: fix false error message in __swp_swapcount()
(The latter is simply because it used a function that is eliminated by one of the other reversions). A They came into the merge window via the -mm tree as part of a 4 part series:
Subject: [PATCH v2 0/4] skip swapcache for super fast device
Message-Id: <[email protected]
Quoted 1 line
James
Quoted 49 lines · James Bottomley
I think I've seen this a lot shutting down systems, but never manged to trace it before. A Now I can reproduce it starting kvm on a 4GB system with 3GB of memory and booting up a linux OS. A What eventually happens (after logging into the virtual system) is that kvm itself hangs, although the stuck process is one of the kworkers in D wait hung on this stack trace:
[<0>] io_schedule+0x12/0x40 [<0>] __lock_page_or_retry+0x2b8/0x300 [<0>] do_swap_page+0x1b9/0x910 [<0>] __handle_mm_fault+0x7ee/0xe20 [<0>] handle_mm_fault+0xce/0x1e0 [<0>] __get_user_pages+0x104/0x6c0 [<0>] get_user_pages_remote+0x84/0x1f0 [<0>] async_pf_execute+0x67/0x1a0 [kvm] [<0>] process_one_work+0x13c/0x370 [<0>] worker_thread+0x44/0x3e0 [<0>] kthread+0xf5/0x130 [<0>] ret_from_fork+0x1f/0x30[<0>]
0xffffffffffffffffThe
async_pf_execute()is a kvm async callback, failure to execute it appears to be causing the kvm hang.Next to go is kswapd
[<0>] io_schedule+0x12/0x40 [<0>] __lock_page+0xec/0x120 [<0>] deferred_split_scan+0x21b/0x2a0 [<0>] shrink_slab+0x24a/0x460 [<0>] shrink_node+0x2e6/0x2f0 [<0>] kswapd+0x2ad/0x730 [<0>] kthread+0xf5/0x130 [<0>] ret_from_fork+0x1f/0x30[<0>]
0xffffffffffffffffAnd finally systemd-logind hangs making it very difficult to get into the system (and impossible to shut it down)
[<0>] call_rwsem_down_write_failed+0x13/0x20 [<0>] register_shrinker+0x45/0xa0 [<0>] sget_userns+0x44d/0x480 [<0>] mount_nodev+0x2a/0xa0 [<0>] mount_fs+0x34/0x150 [<0>] vfs_kern_mount+0x62/0x120 [<0>] do_mount+0x1d7/0xbf0 [<0>] SyS_mount+0x7e/0xd0 [<0>] do_syscall_64+0x5b/0x100 [<0>] entry_SYSCALL64_slow_path+0x25/0x25
Quoted 6 lines
[<0>]
0xffffffffffffffffI've seen this with -rc1 and -rc5, so I think it's some problem with merge window code.
James
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello James,
Quoted 27 lines · James Bottomley
Reverting these three patches fixes the problem:
commit
aa8d22a11da933dbf880b4933b58931f4aefe91cAuthor: Minchan Kim <[email protected]> Date: Wed Nov 15 17:33:11 2017 -0800mm: swap:
SWP_SYNCHRONOUS_IO: skip swapcache only if swapped page
has no other referencecommit
0bcac06f27d7528591c27ac2b093ccd71c5d0168Author: Minchan Kim <[email protected]> Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
Also need to revert:
commit
e9a6effa500526e2a19d5ad042cb758b55b1ef93Author: Huang Ying <[email protected]> Date: Wed Nov 15 17:33:15 2017 -0800mm, swap: fix false error message in
__swp_swapcount()(The latter is simply because it used a function that is eliminated by one of the other reversions). They came into the merge window via the -mm tree as part of a 4 part series:
Quoted 5 lines
Subject: [PATCH v2 0/4] skip swapcache for super fast device
Message-Id: <[email protected]Quoted 1 line
James
Thanks for the report.
Patches are related to synchronous swap devices like brd, zram, nvdimm so
1. What swap device do you use among them?
2. Could you tell me how you can reproduce it?
Thanks.
Quoted 56 lines · James Bottomley
Quoted 54 lines
I think I've seen this a lot shutting down systems, but never manged to trace it before. Now I can reproduce it starting kvm on a 4GB system with 3GB of memory and booting up a linux OS. What eventually happens (after logging into the virtual system) is that kvm itself hangs, although the stuck process is one of the kworkers in D wait hung on this stack trace:
[<0>] io_schedule+0x12/0x40 [<0>] __lock_page_or_retry+0x2b8/0x300 [<0>] do_swap_page+0x1b9/0x910 [<0>] __handle_mm_fault+0x7ee/0xe20 [<0>] handle_mm_fault+0xce/0x1e0 [<0>] __get_user_pages+0x104/0x6c0 [<0>] get_user_pages_remote+0x84/0x1f0 [<0>] async_pf_execute+0x67/0x1a0 [kvm] [<0>] process_one_work+0x13c/0x370 [<0>] worker_thread+0x44/0x3e0 [<0>] kthread+0xf5/0x130 [<0>] ret_from_fork+0x1f/0x30[<0>]
0xffffffffffffffffThe
async_pf_execute()is a kvm async callback, failure to execute it appears to be causing the kvm hang.Next to go is kswapd
[<0>] io_schedule+0x12/0x40 [<0>] __lock_page+0xec/0x120 [<0>] deferred_split_scan+0x21b/0x2a0 [<0>] shrink_slab+0x24a/0x460 [<0>] shrink_node+0x2e6/0x2f0 [<0>] kswapd+0x2ad/0x730 [<0>] kthread+0xf5/0x130 [<0>] ret_from_fork+0x1f/0x30[<0>]
0xffffffffffffffffAnd finally systemd-logind hangs making it very difficult to get into the system (and impossible to shut it down)
[<0>] call_rwsem_down_write_failed+0x13/0x20 [<0>] register_shrinker+0x45/0xa0 [<0>] sget_userns+0x44d/0x480 [<0>] mount_nodev+0x2a/0xa0 [<0>] mount_fs+0x34/0x150 [<0>] vfs_kern_mount+0x62/0x120 [<0>] do_mount+0x1d7/0xbf0 [<0>] SyS_mount+0x7e/0xd0 [<0>] do_syscall_64+0x5b/0x100 [<0>] entry_SYSCALL64_slow_path+0x25/0x25[<0>]
0xffffffffffffffffI've seen this with -rc1 and -rc5, so I think it's some problem with merge window code.
Quoted 7 lines
Quoted 1 line
James
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 40 lines · Minchan Kim
Hello James,
Quoted 37 lines · James Bottomley
Reverting these three patches fixes the problem:
commit
aa8d22a11da933dbf880b4933b58931f4aefe91c
Author: Minchan Kim <[email protected]> Date:A A A Wed Nov 15 17:33:11 2017 -0800A A A A mm: swap:
SWP_SYNCHRONOUS_IO: skip swapcache only if swapped page
has no other referencecommit
0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]> Date:A A A Wed Nov 15 17:33:07 2017 -0800A A A A mm, swap: skip swapcache for swapin of synchronous device
Also need to revert:
commit
e9a6effa500526e2a19d5ad042cb758b55b1ef93
Author: Huang Ying <[email protected]> Date:A A A Wed Nov 15 17:33:15 2017 -0800A A A A mm, swap: fix false error message in
__swp_swapcount()(The latter is simply because it used a function that is eliminated by
one of the other reversions). A They came into the merge window via the
-mm tree as part of a 4 part series:Subject: [PATCH v2 0/4] skip swapcache for super fast device
Message-Id: <1505886205-9671-1-git-send-email-minchan@kernel
.orgQuoted 2 lines
Quoted 7 lines
Quoted 1 line
James
Thanks for the report.
Patches are related to synchronous swap devices like brd, zram, nvdimm so1. What swap device do you use among them?
I've reproduced on nvme and sata spinning rust.
Quoted 1 line
2. Could you tell me how you can reproduce it?
The way to reproduce is to force something to swap and then get it to try to touch the page again. A I do this on my systems by using a large virtual machine, as I said in the email. A There isn't really any definitive reproduction method beyond that.
James
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 49 lines · James Bottomley
Quoted 40 lines · Minchan Kim
Hello James,
Quoted 37 lines · James Bottomley
Reverting these three patches fixes the problem:
commit
aa8d22a11da933dbf880b4933b58931f4aefe91cAuthor: Minchan Kim <[email protected]> Date: Wed Nov 15 17:33:11 2017 -0800mm: swap:
SWP_SYNCHRONOUS_IO: skip swapcache only if swapped
page
has no other referencecommit
0bcac06f27d7528591c27ac2b093ccd71c5d0168Author: Minchan Kim <[email protected]> Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
Also need to revert:
commit
e9a6effa500526e2a19d5ad042cb758b55b1ef93Author: Huang Ying <[email protected]> Date: Wed Nov 15 17:33:15 2017 -0800mm, swap: fix false error message in
__swp_swapcount()(The latter is simply because it used a function that is eliminated by
one of the other reversions). They came into the merge window via the
-mm tree as part of a 4 part series:Subject: [PATCH v2 0/4] skip swapcache for super fast device
Message-Id: <1505886205-9671-1-git-send-email-minchan@kernel
.orgQuoted 2 lines
Quoted 7 lines
Quoted 1 line
James
Thanks for the report.
Patches are related to synchronous swap devices like brd, zram, nvdimm so1. What swap device do you use among them?
Quoted 9 lines
I've reproduced on nvme and sata spinning rust.
Quoted 1 line
2. Could you tell me how you can reproduce it?
The way to reproduce is to force something to swap and then get it to try to touch the page again. I do this on my systems by using a large virtual machine, as I said in the email. There isn't really any definitive reproduction method beyond that.
Thanks for the information.
It seems I made a bug on do_swap_page. I want to confirm before sending formal patch.
Could you try on it?
mm/memory.c +4 -1
@@ -2889,9 +2889,12 @@ int do_swap_page(struct vm_fault *vmf)delayacct_set_flag (DELAYACCT_PF_SWAPIN ); -if (!page) +if (!page) { page =lookup_swap_cache (entry, vma_readahead ? vma :NULL , vmf->address); + swapcache = page; + } +if (!page) {struct swap_info_struct *si =swp_swap_info (entry);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 79 lines · Minchan Kim
Quoted 54 lines · James Bottomley
Quoted 41 lines · Minchan Kim
Hello James,
Quoted 37 lines · James Bottomley
Reverting these three patches fixes the problem:
commit
aa8d22a11da933dbf880b4933b58931f4aefe91c
Author: Minchan Kim <[email protected]>
Date:A A A Wed Nov 15 17:33:11 2017 -0800A A A A mm: swap:
SWP_SYNCHRONOUS_IO: skip swapcache only if swapped page has no other referencecommit
0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]>
Date:A A A Wed Nov 15 17:33:07 2017 -0800A A A A mm, swap: skip swapcache for swapin of synchronous device
Also need to revert:
commit
e9a6effa500526e2a19d5ad042cb758b55b1ef93
Author: Huang Ying <[email protected]> Date:A A A Wed Nov 15 17:33:15 2017 -0800A A A A mm, swap: fix false error message in
__swp_swapcount()(The latter is simply because it used a function that is eliminated by one of the other reversions). A They came into the merge window via the -mm tree as part of a 4 part series:
Subject: [PATCH v2 0/4] skip swapcache for super fast
device
Message-Id: <1505886205-9671-1-git-send-email-
[email protected]Quoted 3 lines
Quoted 7 lines
Quoted 1 line
James
Thanks for the report.
Patches are related to synchronous swap devices like brd, zram, nvdimm so1. What swap device do you use among them?
I've reproduced on nvme and sata spinning rust.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
2. Could you tell me how you can reproduce it?
The way to reproduce is to force something to swap and then get it to try to touch the page again. A I do this on my systems by using a large virtual machine, as I said in the email. A There isn't really any definitive reproduction method beyond that.
Thanks for the information. It seems I made a bug on
do_swap_page. I want to confirm before sending formal patch. Could you try on it?mm/memory.c +0
-0@@ -2889,9 +2889,12 @@ int do_swap_page(struct vm_fault *vmf)A
A
Adelayacct_set_flag(DELAYACCT_PF_SWAPIN);mm/memory.c +1
-1-if (!page) +if (!page) {A page = lookup_swap_cache(entry,
vma_readahead? vma
: NULL,
A Avmf->address);
mm/memory.c int do_swap_page(struct vm_fault *vmf) · line 2897
Quoted 3 lines
mm/memory.c +3
-0+ swapcache = page; + } +
This hangs in precisely the same way first kworker then kswapd with the same stack trace.
I'd guess that since they're both in io_schedule, the problem is that the io_scheduler is taking far too long servicing the requests due to some priority issue you've introduced.
Since we're at -rc5, soon to be -rc6, let's just revert the whole series and you can retry it for 4.16. A The whole point seems to be for zram, which isn't really a huge use case.
James
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · James Bottomley
I'd guess that since they're both in
io_schedule, the problem is that theio_scheduleris taking far too long servicing the requests due to some priority issue you've introduced.
OK, so after some analysis, that turned out to be incorrect. A The problem seems to be that we're exiting do_swap_page() with locked pages that have been read in from swap.
Your changelogs are entirely unclear on why you changed the swapcache setting logic in this patch:
commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]>
Date:A A A Wed Nov 15 17:33:07 2017 -0800
A A A A mm, swap: skip swapcache for swapin of synchronous device
But I think you're using swapcache == NULL as a signal the page came from a synchronous device. A In which case the bug is that you've forgotten we may already have picked up a page in swap_readahead_detect() which you're wrongly keeping swapcache == NULL for and the fix is this (it works on my system, although I'm still getting an unaccountable shutdown delay).
I still think we should revert this series, because this may not be the only bug lurking in the code, so it should go through a lot more rigorous testing than it has.
James
---
mm/memory.c +2 -1
@@ -2847,7 +2847,7 @@ EXPORT_SYMBOL(unmap_mapping_range);int do_swap_page (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma; -struct page *page =NULL , *swapcache =NULL ; +struct page *page =NULL , *swapcache;struct mem_cgroup *memcg;struct vma_swap_readahead swap_ra;swp_entry_t entry;
@@ -2892,6 +2892,7 @@ int do_swap_page(struct vm_fault *vmf)if (!page) page =lookup_swap_cache (entry, vma_readahead ? vma :NULL , vmf->address); + swapcache = page;if (!page) {struct swap_info_struct *si =swp_swap_info (entry);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · James Bottomley
Quoted 3 lines · James Bottomley
I'd guess that since they're both in
io_schedule, the problem is that theio_scheduleris taking far too long servicing the requests due to some priority issue you've introduced.OK, so after some analysis, that turned out to be incorrect. The problem seems to be that we're exiting
do_swap_page()with locked pages that have been read in from swap.Your changelogs are entirely unclear on why you changed the swapcache setting logic in this patch:
Quoted 8 lines
commit
0bcac06f27d7528591c27ac2b093ccd71c5d0168Author: Minchan Kim <[email protected]> Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
But I think you're using swapcache == NULL as a signal the page came from a synchronous device. In which case the bug is that you've
Exactly. Because the patchset aims for skipping swap cache for synchronous device and some logics of do_swap_page has has assumed the page is on swap cache.
Quoted 4 lines
forgotten we may already have picked up a page in
swap_readahead_detect()which you're wrongly keeping swapcache == NULL for and the fix is this (it works on my system, although I'm still getting an unaccountable shutdown delay).
SIGH. I missed that.
Quoted 4 lines
I still think we should revert this series, because this may not be the only bug lurking in the code, so it should go through a lot more rigorous testing than it has.
I have no problem. It's not urgent.
Andrew, this is reverting patch based on 4.15-rc5. And I need to send another revert patch against on mmotm because it would have conflict due to vma-based readahead restructuring patch. I will send soon.
Thanks.
Quoted 38 lines · Minchan Kim
Quoted 12 lines · James Bottomley
Quoted 3 lines · James Bottomley
I'd guess that since they're both in
io_schedule, the problem is that theio_scheduleris taking far too long servicing the requests due to some priority issue you've introduced.OK, so after some analysis, that turned out to be incorrect. The problem seems to be that we're exiting
do_swap_page()with locked pages that have been read in from swap.Your changelogs are entirely unclear on why you changed the swapcache setting logic in this patch:
Quoted 8 lines
commit
0bcac06f27d7528591c27ac2b093ccd71c5d0168Author: Minchan Kim <[email protected]> Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
But I think you're using swapcache == NULL as a signal the page came from a synchronous device. In which case the bug is that you've
Exactly. Because the patchset aims for skipping swap cache for synchronous device and some logics of
do_swap_pagehas has assumed the page is on swap cache.Quoted 4 lines
forgotten we may already have picked up a page in
swap_readahead_detect()which you're wrongly keeping swapcache == NULL for and the fix is this (it works on my system, although I'm still getting an unaccountable shutdown delay).SIGH. I missed that.
Quoted 4 lines
I still think we should revert this series, because this may not be the only bug lurking in the code, so it should go through a lot more rigorous testing than it has.
Quoted 6 lines
I have no problem. It's not urgent.
Andrew, this is reverting patch based on 4.15-rc5. And I need to send another revert patch against on mmotm because it would have conflict due to vma-based readahead restructuring patch. I will send soon.
We should revert (23c47d2ada9f, bdi: introduce BDI_CAP_SYNCHRONOUS_IO) as well. I resend reverting patch with including 23c47d2ada9f.
Andrew, Pleas take this patch for linus-tree. Sorry for the confusion.
Quoted 25 lines · James Bottomley
Quoted 3 lines · James Bottomley
I'd guess that since they're both in
io_schedule, the problem is that theio_scheduleris taking far too long servicing the requests due to some priority issue you've introduced.OK, so after some analysis, that turned out to be incorrect. The problem seems to be that we're exiting
do_swap_page()with locked pages that have been read in from swap.Your changelogs are entirely unclear on why you changed the swapcache setting logic in this patch:
commit
0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]>
Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
But I think you're using swapcache == NULL as a signal the page came from a synchronous device. In which case the bug is that you've forgotten we may already have picked up a page in
swap_readahead_detect()which you're wrongly keeping swapcache == NULL for and the fix is this (it works on my system, although I'm still getting an unaccountable shutdown delay).
Quoted 3 lines
I still think we should revert this series, because this may not be the only bug lurking in the code, so it should go through a lot more rigorous testing than it has.
Andrew, neither the fix below (works for me, though I have seen other swap funniness, most probably unrelated), nor the reversion preferred by James and Minchan (later in this linux-mm thread), was in 4.15-rc8:
the sands of time are running out...
Hugh
Quoted 26 lines
James
---
mm/memory.c +2
-1@@ -2847,7 +2847,7 @@ EXPORT_SYMBOL(unmap_mapping_range);int do_swap_page (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma; -struct page *page =NULL , *swapcache =NULL ; +struct page *page =NULL , *swapcache;struct mem_cgroup *memcg;struct vma_swap_readahead swap_ra;swp_entry_t entry;@@ -2892,6 +2892,7 @@ int do_swap_page(struct vm_fault *vmf)if (!page) page =lookup_swap_cache (entry, vma_readahead ? vma :NULL , vmf->address); + swapcache = page;if (!page) {struct swap_info_struct *si =swp_swap_info (entry);
Andrew Morton
maintainerQuoted 26 lines · On Wed, 17 Jan 2018 14:33:21 -0800 (PST) Hugh Dickins <[email protected]> wrote:
Quoted 25 lines · James Bottomley
Quoted 3 lines · James Bottomley
I'd guess that since they're both in
io_schedule, the problem is that theio_scheduleris taking far too long servicing the requests due to some priority issue you've introduced.OK, so after some analysis, that turned out to be incorrect. The problem seems to be that we're exiting
do_swap_page()with locked pages that have been read in from swap.Your changelogs are entirely unclear on why you changed the swapcache setting logic in this patch:
commit
0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]>
Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
But I think you're using swapcache == NULL as a signal the page came from a synchronous device. In which case the bug is that you've forgotten we may already have picked up a page in
swap_readahead_detect()which you're wrongly keeping swapcache == NULL for and the fix is this (it works on my system, although I'm still getting an unaccountable shutdown delay).
Quoted 8 lines
Quoted 3 lines
I still think we should revert this series, because this may not be the only bug lurking in the code, so it should go through a lot more rigorous testing than it has.
Andrew, neither the fix below (works for me, though I have seen other swap funniness, most probably unrelated), nor the reversion preferred by James and Minchan (later in this linux-mm thread), was in 4.15-rc8:
the sands of time are running out...
Yup. I'm actually planning on sending in this one. OK by you?
From: Minchan Kim <[email protected]>
Subject: mm/memory.c: release locked page in do_swap_page()
James reported a bug in swap paging-in from his testing. It is that do_swap_page doesn't release locked page so system hang-up happens due to a deadlock on PG_locked.
It was introduced by 0bcac06f27d7 ("mm, swap: skip swapcache for swapin of synchronous device") because I missed swap cache hit places to update swapcache variable to work well with other logics against swapcache in do_swap_page.
This patch fixes it.
Debugged by James Bottomley.
---
mm/memory.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mm/memory.c renamed from mm/memory.c~mm-release-locked-page-in-do_swap_page +8 -2
@@ -2857,8 +2857,11 @@ int do_swap_page(struct vm_fault *vmf)int ret =0 ;bool vma_readahead =swap_use_vma_readahead (); -if (vma_readahead) +if (vma_readahead) { page =swap_readahead_detect (vmf, &swap_ra); + swapcache = page; + } +if (!pte_unmap_same (vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) {if (page)put_page (page);
@@ -2889,9 +2892,12 @@ int do_swap_page(struct vm_fault *vmf)delayacct_set_flag (DELAYACCT_PF_SWAPIN ); -if (!page) +if (!page) { page =lookup_swap_cache (entry, vma_readahead ? vma :NULL , vmf->address); + swapcache = page; + } +if (!page) {struct swap_info_struct *si =swp_swap_info (entry);
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hugh Dickins
Acked-byQuoted 31 lines · Andrew Morton
Quoted 30 lines · On Wed, 17 Jan 2018 14:33:21 -0800 (PST) Hugh Dickins <[email protected]> wrote:
Quoted 28 lines · James Bottomley
Quoted 3 lines · James Bottomley
I'd guess that since they're both in
io_schedule, the problem is that theio_scheduleris taking far too long servicing the requests due to some priority issue you've introduced.OK, so after some analysis, that turned out to be incorrect. The problem seems to be that we're exiting
do_swap_page()with locked pages that have been read in from swap.Your changelogs are entirely unclear on why you changed the swapcache setting logic in this patch:
commit
0bcac06f27d7528591c27ac2b093ccd71c5d0168
Author: Minchan Kim <[email protected]>
Date: Wed Nov 15 17:33:07 2017 -0800mm, swap: skip swapcache for swapin of synchronous device
But I think you're using swapcache == NULL as a signal the page came from a synchronous device. In which case the bug is that you've forgotten we may already have picked up a page in
swap_readahead_detect()which you're wrongly keeping swapcache == NULL for and the fix is this (it works on my system, although I'm still getting an unaccountable shutdown delay).I still think we should revert this series, because this may not be the only bug lurking in the code, so it should go through a lot more rigorous testing than it has.
Quoted 6 lines
Quoted 4 lines
Andrew, neither the fix below (works for me, though I have seen other swap funniness, most probably unrelated), nor the reversion preferred by James and Minchan (later in this linux-mm thread), was in 4.15-rc8:
the sands of time are running out...Yup. I'm actually planning on sending in this one. OK by you?
Thanks, yes, that looks equivalent to what I've been running with.
Quoted 16 lines
From: Minchan Kim <[email protected]>
Subject:mm/memory.c: release locked page indo_swap_page()James reported a bug in swap paging-in from his testing. It is that
do_swap_pagedoesn't release locked page so system hang-up happens due to a deadlock onPG_locked.It was introduced by
0bcac06f27d7("mm, swap: skip swapcache for swapin of synchronous device") because I missed swap cache hit places to update swapcache variable to work well with other logics against swapcache indo_swap_page.This patch fixes it.
Quoted 7 lines
Debugged by James Bottomley.
Signed-off-by Minchan Kim <[email protected]>Reported-by James Bottomley <[email protected]>Cc Hugh Dickins <[email protected]>
Quoted 39 lines
Cc Sergey Senozhatsky <[email protected]>Cc Huang Ying <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
mm/memory.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)diff -puN
mm/memory.c~mm-release-locked-page-in-do_swap_pagemm/memory.cmm/memory.c renamed from mm/memory.c~mm-release-locked-page-in-do_swap_page +8
-2@@ -2857,8 +2857,11 @@ int do_swap_page(struct vm_fault *vmf)int ret =0 ;bool vma_readahead =swap_use_vma_readahead (); -if (vma_readahead) +if (vma_readahead) { page =swap_readahead_detect (vmf, &swap_ra); + swapcache = page; + } +if (!pte_unmap_same (vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) {if (page)put_page (page);@@ -2889,9 +2892,12 @@ int do_swap_page(struct vm_fault *vmf)delayacct_set_flag (DELAYACCT_PF_SWAPIN ); -if (!page) +if (!page) { page =lookup_swap_cache (entry, vma_readahead ? vma :NULL , vmf->address); + swapcache = page; + } +if (!page) {struct swap_info_struct *si =swp_swap_info (entry);_