linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <shy828301@gmail.com>
To: Hugh Dickins <hughd@google.com>,
	Huang Ying <ying.huang@intel.com>,
	 Miaohe Lin <linmiaohe@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Linux MM <linux-mm@kvack.org>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] Revert "mm/shmem: fix shmem_swapin() race with swapoff"
Date: Tue, 10 Aug 2021 16:14:49 -0700	[thread overview]
Message-ID: <CAHbLzkoWyY+SvR2suej8c7nRArTt5Y6490QXrV1RTfdYX0HJVQ@mail.gmail.com> (raw)
In-Reply-To: <20210810202936.2672-2-shy828301@gmail.com>

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
>


  reply	other threads:[~2021-08-10 23:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHbLzkoWyY+SvR2suej8c7nRArTt5Y6490QXrV1RTfdYX0HJVQ@mail.gmail.com \
    --to=shy828301@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox