From: Barry Song <21cnbao@gmail.com>
To: Kairui Song <ryncsn@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 2/3] mm, swap: reduce indention for hibernate allocation helper
Date: Mon, 16 Feb 2026 15:37:18 +0800 [thread overview]
Message-ID: <CAGsJ_4wkFZ-uxXO9Rp_Snzym_uXUGD9HDyGF74dF8HmobLfJ3A@mail.gmail.com> (raw)
In-Reply-To: <aZK0B841VeaDQ5w4@KASONG-MC4>
On Mon, Feb 16, 2026 at 2:21 PM Kairui Song <ryncsn@gmail.com> wrote:
>
> On Mon, Feb 16, 2026 at 07:20:49AM +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>
> > >
> > > It doesn't have to check the device flag, as the allocator will also
> > > check the device flag and refuse to allocate if the device is not
> > > writable. This might cause a trivial waste of CPU cycles of hibernate
> > > allocation raced with swapoff, but that is very unlikely to happen.
> > > Removing the check on the common path should be more helpful.
> > >
> > > Signed-off-by: Kairui Song <kasong@tencent.com>
> > > ---
> > > mm/swapfile.c | 38 ++++++++++++++++++--------------------
> > > 1 file changed, 18 insertions(+), 20 deletions(-)
> > >
> > > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > > index 32e0e7545ab8..0d1b17c99221 100644
> > > --- a/mm/swapfile.c
> > > +++ b/mm/swapfile.c
> > > @@ -1936,27 +1936,25 @@ swp_entry_t swap_alloc_hibernation_slot(int type)
> > >
> > > /* This is called for allocating swap entry, not cache */
> > > if (get_swap_device_info(si)) {
> >
> >
> > I guess we could further reduce indentation by doing:
> > if (!get_swap_device_info(si))
> > goto fail;
> >
>
> Agree, I think we can make it even simpler by having:
>
> /* Return empty entry if device is not usable (swapoff or full) */
> if (!si || !get_swap_device_info(si))
> return entry;
>
> Then the `fail` label is also gone.
Yes, this looks even nicer to me. :-)
>
> I'll post a v4 later today combined with your another suggestion. Thanks!
next prev parent reply other threads:[~2026-02-16 7:37 UTC|newest]
Thread overview: 11+ 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 via B4 Relay
2026-02-15 19:00 ` [PATCH v3 1/3] mm, swap: speed up hibernation allocation and writeout 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 via B4 Relay
2026-02-15 23:20 ` Barry Song
2026-02-16 6:21 ` Kairui Song
2026-02-16 7:37 ` Barry Song [this message]
2026-02-15 19:00 ` [PATCH v3 3/3] mm, swap: merge common convention and simplify " Kairui Song via B4 Relay
2026-02-16 7:34 ` Barry Song
2026-02-16 7:53 ` Kairui Song
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=CAGsJ_4wkFZ-uxXO9Rp_Snzym_uXUGD9HDyGF74dF8HmobLfJ3A@mail.gmail.com \
--to=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=ryncsn@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