From: Kairui Song <ryncsn@gmail.com>
To: Barry Song <21cnbao@gmail.com>
Cc: kasong@tencent.com, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Chris Li <chrisl@kernel.org>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Nhat Pham <nphamcs@gmail.com>, Baoquan He <bhe@redhat.com>,
Carsten Grohmann <mail@carstengrohmann.de>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org,
"open list:SUSPEND TO RAM" <linux-pm@vger.kernel.org>,
Carsten Grohmann <carstengrohmann@gmx.de>
Subject: Re: [PATCH v3 3/3] mm, swap: merge common convention and simplify allocation helper
Date: Mon, 16 Feb 2026 15:53:56 +0800 [thread overview]
Message-ID: <aZLLaEXeVVB9277S@KASONG-MC4> (raw)
In-Reply-To: <CAGsJ_4xpoC78KhYj_b18aVzjGcFGfXnpt7uLGvg7w1B4Y5cc2g@mail.gmail.com>
On Mon, Feb 16, 2026 at 03:34:54PM +0800, Barry Song wrote:
> On Mon, Feb 16, 2026 at 3:00 AM Kairui Song via B4 Relay
> <devnull+kasong.tencent.com@kernel.org> wrote:
> >
> > From: Kairui Song <kasong@tencent.com>
> >
> > Almost all callers of the cluster scan helper require the: lock -> check
> > usefulness/emptiness check -> allocate -> unlock routine. So merge them
> > into the same helper to simplify the code.
>
> Previously, when !cluster_is_usable(ci, order), we only called
> swap_cluster_unlock(). Now we do more work in this path:
>
>
> out:
> relocate_cluster(si, ci);
> swap_cluster_unlock(ci);
> if (si->flags & SWP_SOLIDSTATE) {
> this_cpu_write(percpu_swap_cluster.offset[order], next);
> this_cpu_write(percpu_swap_cluster.si[order], si);
> } else {
> si->global_cluster->next[order] = next;
> }
> return found;
>
> I assume this is what you want to do as well, but can we add
> some explanation here?
Yes, that's fine. alloc_swap_scan_cluster is suppose to update the
percpu offset cache so if the cluster is not usable, writing
SWAP_ENTRY_INVALID to invalidate the cache might even be helpful
for future scan. At lease not harmful, I'll add some explanation,
comments.
>
> Also, it would be better to add a comment that
> alloc_swap_scan_cluster() expects ci->lock to be held on
> entry and releases ci->lock before returning.
Thanks for the suggestion, I even thought about renaming the helper
to indicate it will try update the percpu offset and release the lock.
But didn't have a better idea to naming and we also have
alloc_swap_scan_list, leave the name untouched seems more consistent.
I'll just add some comment then.
prev parent reply other threads:[~2026-02-16 7:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-15 19:00 [PATCH v3 0/3] mm/swap: hibernate: improve hibernate performance with new allocator Kairui Song
2026-02-15 19:00 ` Kairui Song via B4 Relay
2026-02-15 19:00 ` [PATCH v3 1/3] mm, swap: speed up hibernation allocation and writeout Kairui Song
2026-02-15 19:00 ` Kairui Song via B4 Relay
2026-02-15 20:43 ` Barry Song
2026-02-16 6:06 ` Kairui Song
2026-02-15 19:00 ` [PATCH v3 2/3] mm, swap: reduce indention for hibernate allocation helper Kairui Song
2026-02-15 19:00 ` Kairui Song via B4 Relay
2026-02-15 23:20 ` Barry Song
2026-02-16 6:21 ` Kairui Song
2026-02-16 7:37 ` Barry Song
2026-02-15 19:00 ` [PATCH v3 3/3] mm, swap: merge common convention and simplify " Kairui Song
2026-02-15 19:00 ` Kairui Song via B4 Relay
2026-02-16 7:34 ` Barry Song
2026-02-16 7:53 ` Kairui Song [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=aZLLaEXeVVB9277S@KASONG-MC4 \
--to=ryncsn@gmail.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=carstengrohmann@gmx.de \
--cc=chrisl@kernel.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=mail@carstengrohmann.de \
--cc=nphamcs@gmail.com \
--cc=rafael@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.