All of lore.kernel.org
 help / color / mirror / Atom feed
From: YoungJun Park <youngjun.park@lge.com>
To: Baoquan He <bhe@redhat.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, chrisl@kernel.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 23:09:55 +0900	[thread overview]
Message-ID: <aaWaM57jui+iuEj1@yjaykim-PowerEdge-T330> (raw)
In-Reply-To: <20260302104016.163542-3-bhe@redhat.com>

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
considering a more complete integration, including activate/deactivate
and swap_rw from aops, rather than only adding read/write hooks.

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.)

How do you think? 

Thanks
Youngjun Park


  parent reply	other threads:[~2026-03-02 14:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 10:40 [PATCH 0/3] mm/swap: use swap_ops to register swap device's methods 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-03  7:24     ` Baoquan He
2026-03-04  6:40   ` Kairui Song
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 [this message]
2026-03-02 19:35     ` Chris Li
2026-03-03  7:14       ` Baoquan He
2026-03-02 14:53   ` Usama Arif
2026-03-03 10:41     ` Baoquan He
2026-03-02 21:21   ` Nhat Pham
2026-03-03  3:01     ` Baoquan He
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
2026-03-05  5:18   ` Baoquan He
2026-03-05  8:09     ` 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=aaWaM57jui+iuEj1@yjaykim-PowerEdge-T330 \
    --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=linux-mm@kvack.org \
    --cc=nphamcs@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 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.