From: Youngjun Park <youngjun.park@lge.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Nhat Pham <nphamcs@gmail.com>, Baoquan He <baoquan.he@linux.dev>,
Barry Song <baohua@kernel.org>,
her0gyugyu@gmail.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/2] mm/swap: skip empty clusters in the swapoff scan
Date: Fri, 7 Aug 2026 15:41:22 +0900 [thread overview]
Message-ID: <anV+EoxWGKdU9da0@yjaykim-PowerEdge-T330> (raw)
In-Reply-To: <20260806130655.420e16bf621b580cc5f08040@linux-foundation.org>
On Thu, Aug 06, 2026 at 01:06:55PM -0700, Andrew Morton wrote:
> On Fri, 7 Aug 2026 04:32:26 +0900 Youngjun Park <youngjun.park@lge.com> wrote:
>
> > find_next_to_unuse() walks a swap device one offset at a time. Slot
> > state now lives in a per cluster swap table, so patch 2 dismisses an
> > empty cluster with one counter read instead of SWAPFILE_CLUSTER table
> > reads.
>
> Thanks.
>
> Can you help us understand how significant this change is for users?
> If "not very" then I'd prefer to defer consideraton of the series until
> after 7.3-rc1.
Hello Andrew
"Not very" in the common case, though there is a case where the win is clear.
No bug and no user report.
For now I would rather defer to after 7.3-rc1.
And for your reference, here is the details.
Every swapoff does a little less work now, because the scan steps over an
unused area one cluster at a time.
But IMHO most of the swapoff time goes to unuse_mm() and to reading the pages back in.
The gain shows on a large swap device that is almost empty, when the last
pages still in use are near the end of it. The scan has to walk up to
them, and today it looks at every slot on the way. Now the empty clusters
in between are skipped in one step.
I have no measured times yet, since that case has to be set up on purpose.
What I did is the arithmetic for the case that skips best,
For example 1T of swap with 256M slots with SWAPFILE_CLUSTER = 512
and everything free but the far end:
- today: 256M table reads
- with the skip: 512K counter reads
That should be around half a second of scan saved.
What I have checked is that empty clusters are skipped as intended, so the
scan does less work. That work is a small part of swapoff, so depending on
the situation it may be too small to see in clock time.
Thanks,
Youngjun
next prev parent reply other threads:[~2026-08-07 6:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 19:32 [PATCH v3 0/2] mm/swap: skip empty clusters in the swapoff scan Youngjun Park
2026-08-06 19:32 ` [PATCH v3 1/2] mm/swap: fix stale comment on swap_info_struct::cluster_info Youngjun Park
2026-08-06 19:32 ` [PATCH v3 2/2] mm/swap: scan by cluster in find_next_to_unuse() Youngjun Park
2026-08-07 7:33 ` Kairui Song
2026-08-07 9:52 ` Baoquan He
2026-08-06 20:06 ` [PATCH v3 0/2] mm/swap: skip empty clusters in the swapoff scan Andrew Morton
2026-08-07 6:41 ` Youngjun Park [this message]
2026-08-07 6:59 ` Youngjun Park
2026-08-07 8:42 ` Baoquan He
2026-08-07 9:59 ` Youngjun Park
2026-08-07 21:42 ` Andrew Morton
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=anV+EoxWGKdU9da0@yjaykim-PowerEdge-T330 \
--to=youngjun.park@lge.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chrisl@kernel.org \
--cc=her0gyugyu@gmail.com \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=shikemeng@huaweicloud.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