LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3 linux-next] Revert "mm,shmem: fix a typo in shmem_swapin_page()"
@ 2021-08-10 20:29 Yang Shi
  2021-08-10 20:29 ` [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff" Yang Shi
  2021-08-10 20:29 ` [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not" Yang Shi
  0 siblings, 2 replies; 7+ messages in thread
From: Yang Shi @ 2021-08-10 20:29 UTC (permalink / raw)
  To: hughd, ying.huang, linmiaohe, Andrew Morton
  Cc: shy828301, linux-mm, linux-kernel

Due to the change about how block layer detects congestion the
justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
is congested or not") doesn't stand anymore, so the commit could be just
reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
fix shmem_swapin() race with swapoff"), so the fix commit and this fix's fix
commit could be reverted as well.

Suggested-by: Hugh Dickins <hughd@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Yang Shi <shy828301@gmail.com>
---
This revert is for linux-next/-mm tree only since this commit has not
merged into Linus's tree yet.

 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 1bea7f50825b..dcc07d14162e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1711,7 +1711,7 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
 	/* Prevent swapoff from happening to us. */
 	si = get_swap_device(swap);
 	if (!si) {
-		error = -EINVAL;
+		error = EINVAL;
 		goto failed;
 	}
 	/* Look it up and read it in.. */
-- 
2.26.2


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

* [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff"
  2021-08-10 20:29 [PATCH 1/3 linux-next] Revert "mm,shmem: fix a typo in shmem_swapin_page()" Yang Shi
@ 2021-08-10 20:29 ` Yang Shi
  2021-08-10 23:14   ` Yang Shi
  2021-08-10 20:29 ` [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not" Yang Shi
  1 sibling, 1 reply; 7+ messages in thread
From: Yang Shi @ 2021-08-10 20:29 UTC (permalink / raw)
  To: hughd, ying.huang, linmiaohe, Andrew Morton
  Cc: shy828301, linux-mm, linux-kernel

Due to the change about how block layer detects congestion the
justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
is congested or not") doesn't stand anymore, so the commit could be just
reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
fix shmem_swapin() race with swapoff"), so the fix commit could be just
reverted as well.

Suggested-by: Hugh Dickins <hughd@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Yang Shi <shy828301@gmail.com>
---
 mm/shmem.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index dcc07d14162e..d5427de5bf02 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1699,8 +1699,7 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
 	struct address_space *mapping = inode->i_mapping;
 	struct shmem_inode_info *info = SHMEM_I(inode);
 	struct mm_struct *charge_mm = vma ? vma->vm_mm : NULL;
-	struct swap_info_struct *si;
-	struct page *page = NULL;
+	struct page *page;
 	swp_entry_t swap;
 	int error;
 
@@ -1708,12 +1707,6 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
 	swap = radix_to_swp_entry(*pagep);
 	*pagep = NULL;
 
-	/* Prevent swapoff from happening to us. */
-	si = get_swap_device(swap);
-	if (!si) {
-		error = EINVAL;
-		goto failed;
-	}
 	/* Look it up and read it in.. */
 	page = lookup_swap_cache(swap, NULL, 0);
 	if (!page) {
@@ -1775,8 +1768,6 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
 	swap_free(swap);
 
 	*pagep = page;
-	if (si)
-		put_swap_device(si);
 	return 0;
 failed:
 	if (!shmem_confirm_swap(mapping, index, swap))
@@ -1787,9 +1778,6 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
 		put_page(page);
 	}
 
-	if (si)
-		put_swap_device(si);
-
 	return error;
 }
 
-- 
2.26.2


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

* [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not"
  2021-08-10 20:29 [PATCH 1/3 linux-next] Revert "mm,shmem: fix a typo in shmem_swapin_page()" Yang Shi
  2021-08-10 20:29 ` [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff" Yang Shi
@ 2021-08-10 20:29 ` Yang Shi
  2021-08-10 21:08   ` Hugh Dickins
  1 sibling, 1 reply; 7+ messages in thread
From: Yang Shi @ 2021-08-10 20:29 UTC (permalink / raw)
  To: hughd, ying.huang, linmiaohe, Andrew Morton
  Cc: shy828301, linux-mm, linux-kernel

Due to the change about how block layer detects congestion the
justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
is congested or not") doesn't stand anymore, so the commit could be just
reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
fix shmem_swapin() race with swapoff"). The fix was reverted by the
previous patch.

Suggested-by: Hugh Dickins <hughd@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Yang Shi <shy828301@gmail.com>
---
 mm/swap_state.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index 1a29b4f98208..8d4104242100 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -628,13 +628,6 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
 	if (!mask)
 		goto skip;
 
-	/* Test swap type to make sure the dereference is safe */
-	if (likely(si->flags & (SWP_BLKDEV | SWP_FS_OPS))) {
-		struct inode *inode = si->swap_file->f_mapping->host;
-		if (inode_read_congested(inode))
-			goto skip;
-	}
-
 	do_poll = false;
 	/* Read a page_cluster sized and aligned cluster around offset. */
 	start_offset = offset & ~mask;
-- 
2.26.2


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

* Re: [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not"
  2021-08-10 20:29 ` [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not" Yang Shi
@ 2021-08-10 21:08   ` Hugh Dickins
  2021-08-10 21:30     ` Yang Shi
  0 siblings, 1 reply; 7+ messages in thread
From: Hugh Dickins @ 2021-08-10 21:08 UTC (permalink / raw)
  To: Yang Shi
  Cc: hughd, ying.huang, linmiaohe, Andrew Morton, linux-mm, linux-kernel

On Tue, 10 Aug 2021, Yang Shi wrote:

> Due to the change about how block layer detects congestion the
> justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
> is congested or not") doesn't stand anymore, so the commit could be just
> reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
> fix shmem_swapin() race with swapoff"). The fix was reverted by the
> previous patch.
> 
> Suggested-by: Hugh Dickins <hughd@google.com>
> Cc: "Huang, Ying" <ying.huang@intel.com>
> Cc: Miaohe Lin <linmiaohe@huawei.com>
> Signed-off-by: Yang Shi <shy828301@gmail.com>

Thanks for doing these,
Acked-by: Hugh Dickins <hughd@google.com>
to all three.

I guess 1/3 will vanish now, since what it's reverting has not yet gone
forward to Linus: it would have been nice for 2/3 to have mentioned that
what it's reverting is kindof buggy: but then you'd have to explain the
"kindof", and that takes more words than it's worth - maybe a lore Link
to the discussion?

But you've done the work that I've not yet got around to:
so thank you, and ignore my gripes.

Hugh

> ---
>  mm/swap_state.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index 1a29b4f98208..8d4104242100 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -628,13 +628,6 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
>  	if (!mask)
>  		goto skip;
>  
> -	/* Test swap type to make sure the dereference is safe */
> -	if (likely(si->flags & (SWP_BLKDEV | SWP_FS_OPS))) {
> -		struct inode *inode = si->swap_file->f_mapping->host;
> -		if (inode_read_congested(inode))
> -			goto skip;
> -	}
> -
>  	do_poll = false;
>  	/* Read a page_cluster sized and aligned cluster around offset. */
>  	start_offset = offset & ~mask;
> -- 
> 2.26.2

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

* Re: [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not"
  2021-08-10 21:08   ` Hugh Dickins
@ 2021-08-10 21:30     ` Yang Shi
  2021-08-10 21:57       ` Hugh Dickins
  0 siblings, 1 reply; 7+ messages in thread
From: Yang Shi @ 2021-08-10 21:30 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Huang Ying, Miaohe Lin, Andrew Morton, Linux MM,
	Linux Kernel Mailing List

On Tue, Aug 10, 2021 at 2:08 PM Hugh Dickins <hughd@google.com> wrote:
>
> On Tue, 10 Aug 2021, Yang Shi wrote:
>
> > Due to the change about how block layer detects congestion the
> > justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
> > is congested or not") doesn't stand anymore, so the commit could be just
> > reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
> > fix shmem_swapin() race with swapoff"). The fix was reverted by the
> > previous patch.
> >
> > Suggested-by: Hugh Dickins <hughd@google.com>
> > Cc: "Huang, Ying" <ying.huang@intel.com>
> > Cc: Miaohe Lin <linmiaohe@huawei.com>
> > Signed-off-by: Yang Shi <shy828301@gmail.com>
>
> Thanks for doing these,
> Acked-by: Hugh Dickins <hughd@google.com>
> to all three.
>
> I guess 1/3 will vanish now, since what it's reverting has not yet gone
> forward to Linus: it would have been nice for 2/3 to have mentioned that
> what it's reverting is kindof buggy: but then you'd have to explain the
> "kindof", and that takes more words than it's worth - maybe a lore Link
> to the discussion?

It is fine, I think this one is the best elaborated the problem:
https://lore.kernel.org/linux-mm/24187e5e-069-9f3f-cefe-39ac70783753@google.com/

>
> But you've done the work that I've not yet got around to:
> so thank you, and ignore my gripes.
>
> Hugh
>
> > ---
> >  mm/swap_state.c | 7 -------
> >  1 file changed, 7 deletions(-)
> >
> > diff --git a/mm/swap_state.c b/mm/swap_state.c
> > index 1a29b4f98208..8d4104242100 100644
> > --- a/mm/swap_state.c
> > +++ b/mm/swap_state.c
> > @@ -628,13 +628,6 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
> >       if (!mask)
> >               goto skip;
> >
> > -     /* Test swap type to make sure the dereference is safe */
> > -     if (likely(si->flags & (SWP_BLKDEV | SWP_FS_OPS))) {
> > -             struct inode *inode = si->swap_file->f_mapping->host;
> > -             if (inode_read_congested(inode))
> > -                     goto skip;
> > -     }
> > -
> >       do_poll = false;
> >       /* Read a page_cluster sized and aligned cluster around offset. */
> >       start_offset = offset & ~mask;
> > --
> > 2.26.2

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

* Re: [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not"
  2021-08-10 21:30     ` Yang Shi
@ 2021-08-10 21:57       ` Hugh Dickins
  0 siblings, 0 replies; 7+ messages in thread
From: Hugh Dickins @ 2021-08-10 21:57 UTC (permalink / raw)
  To: Yang Shi
  Cc: Hugh Dickins, Huang Ying, Miaohe Lin, Andrew Morton, Linux MM,
	Linux Kernel Mailing List

On Tue, 10 Aug 2021, Yang Shi wrote:
> On Tue, Aug 10, 2021 at 2:08 PM Hugh Dickins <hughd@google.com> wrote:
> >
> > I guess 1/3 will vanish now, since what it's reverting has not yet gone
> > forward to Linus: it would have been nice for 2/3 to have mentioned that
> > what it's reverting is kindof buggy: but then you'd have to explain the
> > "kindof", and that takes more words than it's worth - maybe a lore Link
> > to the discussion?
> 
> It is fine, I think this one is the best elaborated the problem:
> https://lore.kernel.org/linux-mm/24187e5e-069-9f3f-cefe-39ac70783753@google.com/

Yes, that best elaborated the problem when I thought it was a problem, then
https://lore.kernel.org/linux-mm/e82380b9-3ad4-4a52-be50-6d45c7f2b5da@google.com/
explained why I later came to think that it wasn't a problem after all.

Hence "kindof" buggy: but good to be reverted anyway.

Whatever!
Thanks,
Hugh

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

* Re: [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff"
  2021-08-10 20:29 ` [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff" Yang Shi
@ 2021-08-10 23:14   ` Yang Shi
  0 siblings, 0 replies; 7+ messages in thread
From: Yang Shi @ 2021-08-10 23:14 UTC (permalink / raw)
  To: Hugh Dickins, Huang Ying, Miaohe Lin, Andrew Morton
  Cc: Linux MM, Linux Kernel Mailing List

On Tue, Aug 10, 2021 at 1:29 PM Yang Shi <shy828301@gmail.com> wrote:
>
> Due to the change about how block layer detects congestion the
> justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
> is congested or not") doesn't stand anymore, so the commit could be just
> reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
> fix shmem_swapin() race with swapoff"), so the fix commit could be just
> reverted as well.

The updated commit log per the discussion with Hugh:

Due to the change about how block layer detects congestion the
justification of commit 8fd2e0b505d1 ("mm: swap: check if swap backing device
is congested or not") doesn't stand anymore, so the commit could be just
reverted in order to solve the race reported by commit 2efa33fc7f6e ("mm/shmem:
fix shmem_swapin() race with swapoff"), so the fix commit could be just
reverted as well.

And that fix is also kind of buggy as discussed by [1] and [2].

[1] https://lore.kernel.org/linux-mm/24187e5e-069-9f3f-cefe-39ac70783753@google.com/
[2] https://lore.kernel.org/linux-mm/e82380b9-3ad4-4a52-be50-6d45c7f2b5da@google.com/

>
> Suggested-by: Hugh Dickins <hughd@google.com>
> Cc: "Huang, Ying" <ying.huang@intel.com>
> Cc: Miaohe Lin <linmiaohe@huawei.com>
> Signed-off-by: Yang Shi <shy828301@gmail.com>
> ---
>  mm/shmem.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index dcc07d14162e..d5427de5bf02 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1699,8 +1699,7 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
>         struct address_space *mapping = inode->i_mapping;
>         struct shmem_inode_info *info = SHMEM_I(inode);
>         struct mm_struct *charge_mm = vma ? vma->vm_mm : NULL;
> -       struct swap_info_struct *si;
> -       struct page *page = NULL;
> +       struct page *page;
>         swp_entry_t swap;
>         int error;
>
> @@ -1708,12 +1707,6 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
>         swap = radix_to_swp_entry(*pagep);
>         *pagep = NULL;
>
> -       /* Prevent swapoff from happening to us. */
> -       si = get_swap_device(swap);
> -       if (!si) {
> -               error = EINVAL;
> -               goto failed;
> -       }
>         /* Look it up and read it in.. */
>         page = lookup_swap_cache(swap, NULL, 0);
>         if (!page) {
> @@ -1775,8 +1768,6 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
>         swap_free(swap);
>
>         *pagep = page;
> -       if (si)
> -               put_swap_device(si);
>         return 0;
>  failed:
>         if (!shmem_confirm_swap(mapping, index, swap))
> @@ -1787,9 +1778,6 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
>                 put_page(page);
>         }
>
> -       if (si)
> -               put_swap_device(si);
> -
>         return error;
>  }
>
> --
> 2.26.2
>

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

end of thread, other threads:[~2021-08-10 23:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 20:29 [PATCH 1/3 linux-next] Revert "mm,shmem: fix a typo in shmem_swapin_page()" Yang Shi
2021-08-10 20:29 ` [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff" Yang Shi
2021-08-10 23:14   ` Yang Shi
2021-08-10 20:29 ` [PATCH 3/3] Revert "mm: swap: check if swap backing device is congested or not" Yang Shi
2021-08-10 21:08   ` Hugh Dickins
2021-08-10 21:30     ` Yang Shi
2021-08-10 21:57       ` Hugh Dickins

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