From: Baoquan He <bhe@redhat.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, chrisl@kernel.org,
kasong@tencent.com, shikemeng@huaweicloud.com, baohua@kernel.org,
youngjun.park@lge.com
Subject: Re: [PATCH 2/3] mm/swap: use swap_ops to register swap device's methods
Date: Tue, 3 Mar 2026 11:01:37 +0800 [thread overview]
Message-ID: <aaZPEcnpscHMjSKO@MiWiFi-R3L-srv> (raw)
In-Reply-To: <CAKEwX=Pb=W8WShjS5uq=8iWxZYjTiskhKUO-MgxJzD1HgHmX7w@mail.gmail.com>
On 03/02/26 at 01:21pm, Nhat Pham wrote:
> On Mon, Mar 2, 2026 at 2:40 AM Baoquan He <bhe@redhat.com> wrote:
...snip...
> > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > index 915bc93964db..af498f9af328 100644
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -3625,6 +3625,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
> > /* Sets SWP_WRITEOK, resurrect the percpu ref, expose the swap device */
> > enable_swap_info(si);
> >
> > + probe_swap_fs(si);
> > +
> > pr_info("Adding %uk swap on %s. Priority:%d extents:%d across:%lluk %s%s%s%s\n",
> > K(si->pages), name->name, si->prio, nr_extents,
> > K((unsigned long long)span),
> > diff --git a/mm/zswap.c b/mm/zswap.c
> > index a399f7a10830..7ce906249c7a 100644
> > --- a/mm/zswap.c
> > +++ b/mm/zswap.c
> > @@ -1055,7 +1055,8 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
> > folio_set_reclaim(folio);
> >
> > /* start writeback */
> > - __swap_writepage(folio, NULL);
> > + if (si->ops && si->ops->write_folio)
> > + si->ops->write_folio(si, folio, NULL);
>
> This one seems really weird to me TBH...
>
> What's the point of a zswap writeback to a backend without writeback
> operation...? We're loading the coldest zswap objects back into
> memory...?
>
> More generally, do you anticipate a swap backend with no write_folio?
> I can't imagine such backend.
>
> That said, if they exist, they should be exempted from zswap
> writeback. At the very least, move this check to the beginning of
> zswap_writeback_entry(), right after swap device pinning
> (get_swap_device()):
>
> 1. If swap device has no writeback op, just bail. Don't even bother
> allocate swap cache, decompression, etc.
>
> 2. If you anticipate that this case will never happen, add a warn.
Good point. Currently, there's no case where a swap backend without
write_folio. While in the future there could be, assume you have noticed
the swap tier patchset introduced by Youngjun.
Here, the si->ops checking is purely defensive programming. I can add a
warn at the beginnin of zswap_writeback_entry(). If there's any case
involving no read/write_folio, adaption can be made at that time.
next prev parent reply other threads:[~2026-03-03 3:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 10:40 [PATCH 0/3] " Baoquan He
2026-03-02 10:40 ` [PATCH 1/3] mm/swap: rename mm/page_io.c to mm/swap_io.c Baoquan He
2026-03-02 10:56 ` Barry Song
2026-03-02 13:25 ` Baoquan He
2026-03-02 21:12 ` Nhat Pham
2026-03-02 10:40 ` [PATCH 2/3] mm/swap: use swap_ops to register swap device's methods Baoquan He
2026-03-02 11:11 ` Barry Song
2026-03-02 14:47 ` Baoquan He
2026-03-02 19:28 ` Chris Li
2026-03-02 12:20 ` YoungJun Park
2026-03-02 14:09 ` YoungJun Park
2026-03-02 19:35 ` Chris Li
2026-03-02 14:53 ` Usama Arif
2026-03-02 21:21 ` Nhat Pham
2026-03-03 3:01 ` Baoquan He [this message]
2026-03-02 10:40 ` [PATCH 3/3] mm/swap_io.c: rename swap_writepage_* to swap_write_folio_* Baoquan He
2026-03-02 11:28 ` Barry Song
2026-03-02 21:11 ` Nhat Pham
2026-03-02 14:43 ` [PATCH 0/3] mm/swap: use swap_ops to register swap device's methods 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=aaZPEcnpscHMjSKO@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=chrisl@kernel.org \
--cc=kasong@tencent.com \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=shikemeng@huaweicloud.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