linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kairui Song <ryncsn@gmail.com>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: linux-mm <linux-mm@kvack.org>, Chris Li <chrisl@kernel.org>
Subject: Re: cluster_alloc_swap_entry() may change per-cpu cluster of another CPU randomly
Date: Wed, 6 Nov 2024 02:04:12 +0800	[thread overview]
Message-ID: <CAMgjq7DhqCuo5z0DbOqZdbJ-i7k7qSrKnWMb+tddhVEtec8FPw@mail.gmail.com> (raw)
In-Reply-To: <87ed3r8zvy.fsf@yhuang6-desk2.ccr.corp.intel.com>

On Mon, Nov 4, 2024 at 11:06 AM Huang, Ying <ying.huang@intel.com> wrote:
>
> Kairui Song <ryncsn@gmail.com> writes:
>
> I think that the logic of SWP_SCANNING is correct.
>
> As for SWP_WRITEOK, we should avoid to allocate swap entries when other
> task clears it ASAP.  So, the above checking may be too late, because we
> have already allocated the swap entry.  I think that we can check it in
> cluster_reclaim_range() and refuse to allocate swap entry there.

Thanks for the feedback.

Not sure if this is a big issue. With the above patch SWP_WRITEOK will
prevents any new allocations from using the device, already ongoing
allocations may still use this device indeed, but in the end swapoff
will still succeed, maybe very slightly slower as swapoff may have to
unuse a few more entries. I can add another SWP_WRITEOK check to make
it better, will post a patch.

> Combined with the per cpu cluster (cluster->next[]) changing issue we
> discussed in another email of the thread.  I think the long term
> solution could be separate the swap entry allocation and reclaiming a
> bit more.  For example, we could try to allocate some swap entries with
> si->lock held firstly, record possible reclaim offset if any, change
> cluster->next[], then unlock, reclaim, lock.
>
> --
> Best Regards,
> Huang, Ying


  reply	other threads:[~2024-11-05 18:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  3:25 Huang, Ying
2024-10-24  3:50 ` Kairui Song
2024-10-24  3:54   ` Kairui Song
2024-10-25  5:52   ` Huang, Ying
2024-11-03 17:11     ` Kairui Song
2024-11-04  3:02       ` Huang, Ying
2024-11-05 18:04         ` Kairui Song [this message]
2024-11-06  5:24           ` Huang, Ying

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=CAMgjq7DhqCuo5z0DbOqZdbJ-i7k7qSrKnWMb+tddhVEtec8FPw@mail.gmail.com \
    --to=ryncsn@gmail.com \
    --cc=chrisl@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