From: Youngjun Park <youngjun.park@lge.com>
To: linux-pm@vger.kernel.org
Cc: linux-mm@kvack.org, rafael@kernel.org, lenb@kernel.org,
pavel@kernel.org, akpm@linux-foundation.org, chrisl@kernel.org,
kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com,
bhe@redhat.com, baohua@kernel.org, youngjun.park@lge.com
Subject: [RFC PATCH 0/2] kernel/power: fix swap device reference handling in hibernation swap path
Date: Tue, 3 Mar 2026 01:53:32 +0900 [thread overview]
Message-ID: <20260302165334.1278479-1-youngjun.park@lge.com> (raw)
This series addresses two issues in the hibernation swap path.
First, grabbing and releasing the swap device reference on every slot
allocation is inefficient across the entire hibernation swap path.
Second, in the uswsusp path, only the swap type value is retrieved at
lookup time without holding a reference. If swapoff races after the
type is acquired, subsequent slot allocations operate on a stale swap
device.
The fix is to hold the swap device reference from the point the swap
device is looked up, and release it once at each exit path.
Patch 1: Release the reference immediately after each slot allocation
as a preparatory step.
Patch 2: Lift the reference acquisition to the lookup site and place
put_swap_device_by_type() at all relevant cleanup paths in
swap.c and user.c.
This series is based on mm-new.
I'm sending this as RFC because my familiarity with the kernel/power
and snapshot paths is limited. I believe the approach is reasonable,
but I'd appreciate any feedback before moving forward with proper
testing and a formal submission.
Thanks,
Youngjun Park
Youngjun Park (2):
mm/swap: release swap reference on each hibernation slot allocation
kernel/power: hold swap device reference across hibernation swap
operation
include/linux/swap.h | 1 +
kernel/power/swap.c | 12 +++++++---
kernel/power/user.c | 9 +++++++-
mm/swapfile.c | 55 ++++++++++++++++++++++----------------------
4 files changed, 45 insertions(+), 32 deletions(-)
--
2.34.1
next reply other threads:[~2026-03-02 16:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 16:53 Youngjun Park [this message]
2026-03-02 16:53 ` [RFC PATCH 1/2] mm/swap: release swap reference on each hibernation slot allocation Youngjun Park
2026-03-02 16:53 ` [RFC PATCH 2/2] kernel/power: hold swap device reference across hibernation swap operation Youngjun Park
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=20260302165334.1278479-1-youngjun.park@lge.com \
--to=youngjun.park@lge.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--cc=chrisl@kernel.org \
--cc=kasong@tencent.com \
--cc=lenb@kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=nphamcs@gmail.com \
--cc=pavel@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox