* [PATCH] memcg: set page->private before calling swap_readpage
@ 2021-03-18 1:59 Shakeel Butt
2021-03-18 8:55 ` Heiko Carstens
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Shakeel Butt @ 2021-03-18 1:59 UTC (permalink / raw)
To: Hugh Dickins, Johannes Weiner
Cc: Roman Gushchin, Michal Hocko, Andrew Morton, Minchan Kim,
cgroups, linux-mm, linux-kernel, Shakeel Butt, Heiko Carstens
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().
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Reported-by: Heiko Carstens <hca@linux.ibm.com>
---
Andrew, please squash this into "memcg: charge before adding to
swapcache on swapin" patch.
mm/memory.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/memory.c b/mm/memory.c
index aefd158ae1ea..b6f3410b5902 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -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,
--
2.31.0.rc2.261.g7f71774620-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: set page->private before calling swap_readpage
2021-03-18 1:59 [PATCH] memcg: set page->private before calling swap_readpage Shakeel Butt
@ 2021-03-18 8:55 ` Heiko Carstens
2021-03-18 14:01 ` Michal Hocko
2021-03-18 15:03 ` Johannes Weiner
2 siblings, 0 replies; 6+ messages in thread
From: Heiko Carstens @ 2021-03-18 8:55 UTC (permalink / raw)
To: Shakeel Butt
Cc: Hugh Dickins, Johannes Weiner, Roman Gushchin, Michal Hocko,
Andrew Morton, Minchan Kim, cgroups, linux-mm, linux-kernel
On Wed, Mar 17, 2021 at 06:59:59PM -0700, Shakeel Butt wrote:
> 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().
>
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> Reported-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>
> Andrew, please squash this into "memcg: charge before adding to
> swapcache on swapin" patch.
>
> mm/memory.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index aefd158ae1ea..b6f3410b5902 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -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!
Tested-by: Heiko Carstens <hca@linux.ibm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: set page->private before calling swap_readpage
2021-03-18 1:59 [PATCH] memcg: set page->private before calling swap_readpage Shakeel Butt
2021-03-18 8:55 ` Heiko Carstens
@ 2021-03-18 14:01 ` Michal Hocko
2021-03-18 15:02 ` Johannes Weiner
2021-03-18 15:03 ` Johannes Weiner
2 siblings, 1 reply; 6+ messages in thread
From: Michal Hocko @ 2021-03-18 14:01 UTC (permalink / raw)
To: Shakeel Butt
Cc: Hugh Dickins, Johannes Weiner, Roman Gushchin, Andrew Morton,
Minchan Kim, cgroups, linux-mm, linux-kernel, Heiko Carstens
On Wed 17-03-21 18:59:59, Shakeel Butt wrote:
> 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().
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.
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> Reported-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>
> Andrew, please squash this into "memcg: charge before adding to
> swapcache on swapin" patch.
>
> mm/memory.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index aefd158ae1ea..b6f3410b5902 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -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,
> --
> 2.31.0.rc2.261.g7f71774620-goog
>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: set page->private before calling swap_readpage
2021-03-18 14:01 ` Michal Hocko
@ 2021-03-18 15:02 ` Johannes Weiner
2021-03-18 15:08 ` Michal Hocko
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Weiner @ 2021-03-18 15:02 UTC (permalink / raw)
To: Michal Hocko
Cc: Shakeel Butt, Hugh Dickins, Roman Gushchin, Andrew Morton,
Minchan Kim, cgroups, linux-mm, linux-kernel, Heiko Carstens
On Thu, Mar 18, 2021 at 03:01:25PM +0100, Michal Hocko wrote:
> On Wed 17-03-21 18:59:59, Shakeel Butt wrote:
> > 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().
>
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: set page->private before calling swap_readpage
2021-03-18 15:02 ` Johannes Weiner
@ 2021-03-18 15:08 ` Michal Hocko
0 siblings, 0 replies; 6+ messages in thread
From: Michal Hocko @ 2021-03-18 15:08 UTC (permalink / raw)
To: Johannes Weiner
Cc: Shakeel Butt, Hugh Dickins, Roman Gushchin, Andrew Morton,
Minchan Kim, cgroups, linux-mm, linux-kernel, Heiko Carstens
On Thu 18-03-21 11:02:17, Johannes Weiner wrote:
> On Thu, Mar 18, 2021 at 03:01:25PM +0100, Michal Hocko wrote:
> > On Wed 17-03-21 18:59:59, Shakeel Butt wrote:
> > > 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().
> >
> > 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!
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: set page->private before calling swap_readpage
2021-03-18 1:59 [PATCH] memcg: set page->private before calling swap_readpage Shakeel Butt
2021-03-18 8:55 ` Heiko Carstens
2021-03-18 14:01 ` Michal Hocko
@ 2021-03-18 15:03 ` Johannes Weiner
2 siblings, 0 replies; 6+ messages in thread
From: Johannes Weiner @ 2021-03-18 15:03 UTC (permalink / raw)
To: Shakeel Butt
Cc: Hugh Dickins, Roman Gushchin, Michal Hocko, Andrew Morton,
Minchan Kim, cgroups, linux-mm, linux-kernel, Heiko Carstens
On Wed, Mar 17, 2021 at 06:59:59PM -0700, Shakeel Butt wrote:
> 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().
>
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> Reported-by: Heiko Carstens <hca@linux.ibm.com>
LGTM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-03-18 15:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 1:59 [PATCH] memcg: set page->private before calling swap_readpage Shakeel Butt
2021-03-18 8:55 ` Heiko Carstens
2021-03-18 14:01 ` Michal Hocko
2021-03-18 15:02 ` Johannes Weiner
2021-03-18 15:08 ` Michal Hocko
2021-03-18 15:03 ` Johannes Weiner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).