From: albin_yang@163.com
To: youngjun.park@lge.com
Cc: akpm@linux-foundation.org, albin_yang@163.com,
albinwyang@tencent.com, baohua@kernel.org, baoquan.he@linux.dev,
chrisl@kernel.org, kasong@tencent.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
nphamcs@gmail.com
Subject: Re: [PATCH v2] mm/swap: skip devices without SWP_PAGE_DISCARD in swap_sync_discard()
Date: Sat, 5 Dec 2026 10:55:16 +0800 [thread overview]
Message-ID: <20261205025516.308616-1-albin_yang@163.com> (raw)
In-Reply-To: <axJG9m93sTXfrYmU@yjaykim-PowerEdge-T330>
Hi Youngjun,
On Fri, 4 Dec 2026 13:52:06 +0900, Youngjun Park wrote:
> Looking at your use case, there seems to be no discard device at all.
>
> What about counting SWP_PAGE_DISCARD devices like nr_rotate_swap, so we
> can skip the walk (and swap_lock) entirely when it's zero? Might be a
> bit local, but swap on discard devices isn't that common.
> It is just opinion for curios about your thought. no serious consideration plz :)
Interesting idea, but a counter would need to stay consistent with
swap_active_head across swapon/swapoff, and it only saves the last
lock/unlock pair now that the scan is down to 2 operations. Better to
leave that to the structural rework and keep this fix minimal.
> This inner check should be redundant now, right? Can we drop it?
Yes. All runtime writes to si->flags for an enabled device hold
swap_lock, so the loop-head check is stable. After the unlock those
writes only touch SWP_WRITEOK/SWP_HIBERNATION; the only runtime place
clearing SWP_PAGE_DISCARD is swapoff's p->flags = 0, which comes after
percpu_ref_kill(), so a live ref from get_swap_device_info() cannot
reach it. The inner check is therefore always true, and is itself a
read outside swap_lock. I'll drop it in v3.
Thanks,
Wei Yang
prev parent reply other threads:[~2026-12-05 2:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 2:44 albin_yang
2026-12-04 4:52 ` Youngjun Park
2026-12-05 2:55 ` albin_yang [this message]
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=20261205025516.308616-1-albin_yang@163.com \
--to=albin_yang@163.com \
--cc=akpm@linux-foundation.org \
--cc=albinwyang@tencent.com \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chrisl@kernel.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=youngjun.park@lge.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
all inboxes | Powered by JetHome®