From: Chris Li <chrisl@kernel.org>
To: YoungJun Park <youngjun.park@lge.com>
Cc: Baoquan He <bhe@redhat.com>,
linux-mm@kvack.org, akpm@linux-foundation.org,
kasong@tencent.com, shikemeng@huaweicloud.com,
nphamcs@gmail.com, baohua@kernel.org
Subject: Re: [PATCH 2/3] mm/swap: use swap_ops to register swap device's methods
Date: Mon, 2 Mar 2026 11:35:52 -0800 [thread overview]
Message-ID: <CACePvbUr+xEs3zM_g6ZhwosF=Qt2=2W5fjYPs4gDL6MTo9rmrw@mail.gmail.com> (raw)
In-Reply-To: <aaWaM57jui+iuEj1@yjaykim-PowerEdge-T330>
On Mon, Mar 2, 2026 at 6:10 AM YoungJun Park <youngjun.park@lge.com> wrote:
>
> On Mon, Mar 02, 2026 at 06:40:15PM +0800, Baoquan He wrote:
> > This simplifies codes and makes logic clearer. And also makes later any
> > new swap device type being added easier to handle.
> >
> > Currently there are three types of swap devices: bdev_fs, bdev_sync
> > and bdev_async, and only operations read_folio and write_folio are
> > included. In the future, there could be more swap device types added
> > and more appropriate opeations adapted into swap_ops.
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > ---
> > include/linux/swap.h | 13 ++++++
> > mm/swap.h | 1 -
> > mm/swap_io.c | 102 +++++++++++++++++++++++++------------------
> > mm/swapfile.c | 2 +
> > mm/zswap.c | 3 +-
> > 5 files changed, 76 insertions(+), 45 deletions(-)
> >
> > diff --git a/include/linux/swap.h b/include/linux/swap.h
> > index 0effe3cc50f5..448e5e66ec5c 100644
> > --- a/include/linux/swap.h
> > +++ b/include/linux/swap.h
> > @@ -19,6 +19,7 @@
> > struct notifier_block;
> >
> > struct bio;
> > +struct swap_iocb;
> >
> > struct pagevec;
> >
> > @@ -222,6 +223,17 @@ enum {
> > #define SWAP_CLUSTER_MAX_SKIPPED (SWAP_CLUSTER_MAX << 10)
> > #define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
> >
> > +struct swap_ops {
> > + void (*read_folio)(struct swap_info_struct *sis,
> > + struct folio *folio,
> > + struct swap_iocb **plug);
> > + void (*write_folio)(struct swap_info_struct *sis,
> > + struct folio *folio,
> > + struct swap_iocb **plug);
> > +};
>
> I think swap_iocb is only required for fs-swap
> (swap_folio_read_fs/swap_folio_write_fs).
>
> If the goal is to support fs-swap through swap_ops, it might be worth
Consider this series as a starting point for discussion. Nothing is
set to stone.
> considering a more complete integration, including activate/deactivate
> and swap_rw from aops, rather than only adding read/write hooks.
Can be add as follow up patches to introduce active/deactive and
swap_rw from aops. In fact I want to see it as incremental patches
rather than add every possible swap_ops in one go. It is likely easier
to review as well.
>
> So.. we could keep SWP_FS_OPS as-is for now and just split
> sync/async paths, and revisit a cleaner fs-swap integration later.
> (I mean removing fs ops, and call swap_read/write_folio_fs on sync/async ops.)
You can propose incremental patches to add your additional swap ops
and into the series as the later iteration.
The sync/async split is just a MVP to introduce the first step of the swap_ops.
Chris
next prev parent reply other threads:[~2026-03-02 19:36 UTC|newest]
Thread overview: 18+ 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 [this message]
2026-03-02 14:53 ` Usama Arif
2026-03-02 21:21 ` Nhat Pham
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='CACePvbUr+xEs3zM_g6ZhwosF=Qt2=2W5fjYPs4gDL6MTo9rmrw@mail.gmail.com' \
--to=chrisl@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--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