memcg: set page->private before calling swap_readpage
Subsystems (3)
PATCH 1/1 memcg: set page->private before calling swap_readpage
The function swap_readpage() (and other functions it call) extracts swap entry from page->private. However for SWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set the page->private with the swap entry before calling swap_readpage().
---
Andrew, please squash this into "memcg: charge before adding to swapcache on swapin" patch.
mm/memory.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/memory.c +4 -0
@@ -3324,7 +3324,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)workingset_refault (page, shadow);lru_cache_add (page); + +/* To provide entry to swap_readpage() */ +set_page_private (page, entry.val);swap_readpage (page, true); +set_page_private (page,0 ); } }else { page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
Quoted 20 lines · Shakeel Butt
The function
swap_readpage()(and other functions it call) extracts swap entry frompage->private. However forSWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set thepage->privatewith the swap entry before callingswap_readpage().Signed-off-by Shakeel Butt <[email protected]>Reported-by Heiko Carstens <[email protected]>---
Andrew, please squash this into "memcg: charge before adding to swapcache on swapin" patch.
mm/memory.c | 4 ++++ 1 file changed, 4 insertions(+)mm/memory.c +0
-0
mm/memory.c vm_fault_t do_swap_page(struct vm_fault *vmf) · line 3331
Quoted 8 lines
mm/memory.c +4
-0@@ -3324,7 +3324,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)workingset_refault (page, shadow);lru_cache_add (page); + +/* To provide entry to swap_readpage() */ +set_page_private (page, entry.val);swap_readpage (page, true); +set_page_private (page,0 );
Yes, this seems to fix it. Thanks a lot!
Michal Hocko
reviewerQuoted 4 lines · Shakeel Butt
The function
swap_readpage()(and other functions it call) extracts swap entry frompage->private. However forSWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set thepage->privatewith the swap entry before callingswap_readpage().
One thing that is not really clear to me is whether/why this is only needed with your patch. Can you expand a bit on that please? Maybe I am just missing something obvious but I just do not see any connection.
Quoted 29 lines
Signed-off-by Shakeel Butt <[email protected]>Reported-by Heiko Carstens <[email protected]>---
Andrew, please squash this into "memcg: charge before adding to swapcache on swapin" patch.
mm/memory.c | 4 ++++ 1 file changed, 4 insertions(+)mm/memory.c +4
-0@@ -3324,7 +3324,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)workingset_refault (page, shadow);lru_cache_add (page); + +/* To provide entry to swap_readpage() */ +set_page_private (page, entry.val);swap_readpage (page, true); +set_page_private (page,0 ); } }else { page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
Signature · 2 lines
Michal Hocko SUSE Labs
Johannes Weiner
maintainerQuoted 9 lines · Michal Hocko
Quoted 4 lines · Shakeel Butt
The function
swap_readpage()(and other functions it call) extracts swap entry frompage->private. However forSWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set thepage->privatewith the swap entry before callingswap_readpage().One thing that is not really clear to me is whether/why this is only needed with your patch. Can you expand a bit on that please? Maybe I am just missing something obvious but I just do not see any connection.
It was always needed, his original patch erroneously removed it.
Michal Hocko
reviewerQuoted 7 lines · Johannes Weiner
Quoted 6 lines · Michal Hocko
Quoted 4 lines · Shakeel Butt
The function
swap_readpage()(and other functions it call) extracts swap entry frompage->private. However forSWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set thepage->privatewith the swap entry before callingswap_readpage().
Quoted 5 lines
Quoted 3 lines
One thing that is not really clear to me is whether/why this is only needed with your patch. Can you expand a bit on that please? Maybe I am just missing something obvious but I just do not see any connection.
It was always needed, his original patch erroneously removed it.
Ahh, I can see it now. I must have been blind. Thanks!
Signature · 2 lines
Michal Hocko SUSE Labs
Johannes Weiner
maintainerQuoted 7 lines · Shakeel Butt
The function
swap_readpage()(and other functions it call) extracts swap entry frompage->private. However forSWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set thepage->privatewith the swap entry before callingswap_readpage().Signed-off-by Shakeel Butt <[email protected]>Reported-by Heiko Carstens <[email protected]>
LGTM