linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mm/swap_state: Skip meaningless swap cache readahead when ra_info.win == 0
@ 2020-10-26  2:46 linmiaohe
  0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-10-26  2:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Hugh Dickins

Andrew Morton <akpm@linux-foundation.org> wrote:
> On Fri, 9 Oct 2020 09:30:59 -0400 Miaohe Lin <linmiaohe@huawei.com> wrote:
>
>> swap_ra_info() may leave ra_info untouched in non_swap_entry() case as 
>> page table lock is not held. In this case, we have ra_info.nr_pte == 0 
>> and it is meaningless to continue with swap cache readahead. Skip such 
>> ops by init ra_info.win = 1.
>> 
>
>Looks right.  But I think it would be better to fix this in
>swap_ra_info() - make it more consistent in its return state.
>

I think modernify the struct initializer is better because it means we have to swap in one page at least.
Many thanks.

>Otherwise, let's modernify that struct initializer:
>
>--- a/mm/swap_state.c~mm-swap_state-skip-meaningless-swap-cache-readahead-when-ra_infowin-==-0-fix
>+++ a/mm/swap_state.c
>@@ -839,7 +839,9 @@ static struct page *swap_vma_readahead(s
> 	swp_entry_t entry;
> 	unsigned int i;
> 	bool page_allocated;
>-	struct vma_swap_readahead ra_info = {1,};
>+	struct vma_swap_readahead ra_info = {
>+		.win = 1,
>+	};
> 
> 	swap_ra_info(vmf, &ra_info);
> 	if (ra_info.win == 1)
>_
>


^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH] mm/swap_state: Skip meaningless swap cache readahead when ra_info.win == 0
@ 2020-10-09 13:30 Miaohe Lin
  2020-10-25 23:59 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Miaohe Lin @ 2020-10-09 13:30 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

swap_ra_info() may leave ra_info untouched in non_swap_entry() case as page
table lock is not held. In this case, we have ra_info.nr_pte == 0 and it is
meaningless to continue with swap cache readahead. Skip such ops by init
ra_info.win = 1.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/swap_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index ee465827420e..b9013c3f94c9 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -839,7 +839,7 @@ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask,
 	swp_entry_t entry;
 	unsigned int i;
 	bool page_allocated;
-	struct vma_swap_readahead ra_info = {0,};
+	struct vma_swap_readahead ra_info = {1,};
 
 	swap_ra_info(vmf, &ra_info);
 	if (ra_info.win == 1)
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-26  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26  2:46 [PATCH] mm/swap_state: Skip meaningless swap cache readahead when ra_info.win == 0 linmiaohe
  -- strict thread matches above, loose matches on Subject: below --
2020-10-09 13:30 Miaohe Lin
2020-10-25 23:59 ` Andrew Morton

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).