|
|
Log in / Subscribe / Register

mm/zram: route block swap I/O through swap_ops

From:  Jianyue Wu <wujianyue000-AT-gmail.com>
To:  Andrew Morton <akpm-AT-linux-foundation.org>
Subject:  [PATCH 0/3] mm/zram: route block swap I/O through swap_ops
Date:  Sun, 14 Jun 2026 23:35:28 +0800
Message-ID:  <20260614-zram-swap-ops-block-register-v1-0-6c1a6639c222@gmail.com>
Cc:  Christoph Hellwig <hch-AT-lst.de>, Chris Li <chrisl-AT-kernel.org>, Baoquan He <bhe-AT-redhat.com>, Nhat Pham <nphamcs-AT-gmail.com>, Barry Song <baohua-AT-kernel.org>, Kairui Song <kasong-AT-tencent.com>, Kemeng Shi <shikemeng-AT-huaweicloud.com>, Youngjun Park <youngjun.park-AT-lge.com>, Minchan Kim <minchan-AT-kernel.org>, Sergey Senozhatsky <senozhatsky-AT-chromium.org>, Jens Axboe <axboe-AT-kernel.dk>, "Matthew Wilcox (Oracle)" <willy-AT-infradead.org>, Jan Kara <jack-AT-suse.cz>, linux-mm-AT-kvack.org, linux-kernel-AT-vger.kernel.org, linux-block-AT-vger.kernel.org, linux-doc-AT-vger.kernel.org, Jianyue Wu <wujianyue000-AT-gmail.com>
Archive-link:  Article

This series builds on Christoph Hellwig's swap batching rework that
moves block swap onto struct swap_iocb and per-backend struct
swap_ops handlers [1].  Christoph's patches unify batching for
ordinary block devices and swap files.  zram still needs a custom
path because swap slots map to compressed pages, not disk sectors.

The first patch adds swap_register_block_ops() so a block driver can
install custom submit_read/submit_write handlers when swapon targets
its block device.  The default swap_bdev_ops path is unchanged for
devices that do not register.

The second patch registers zram_swap_ops at module init.  On write,
the swap core still batches folios into a swap_iocb.  zram maps each
folio to a slot index and stores it through zram_write_page() instead
of building one bio per page.  Read handling keeps slot_lock and
mark_slot_accessed() in one critical section.  Writeback-enabled zram
falls back to swap_bdev_submit_read() for ZRAM_WB slots.

The third patch moves slot_free_notify into swap_ops next to the
other zram swap callbacks, and documents the locking contract for
that hook.

Applied on top of Christoph Hellwig's "better block swap batching and
a different take on swap_ops" series [1].

[1] https://lore.kernel.org/linux-mm/?q=better+block+swap+bat...

To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chris Li <chrisl@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Youngjun Park <youngjun.park@lge.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-block@vger.kernel.org
Cc: linux-doc@vger.kernel.org

Signed-off-by: Jianyue Wu <wujianyue000@gmail.com>
---
Jianyue Wu (3):
      mm/page_io: let block drivers register custom swap I/O ops
      mm/zram: handle swap read/write via swap_ops
      mm/swap: route slot free notifications through swap_ops

 Documentation/filesystems/locking.rst |   5 -
 drivers/block/zram/zram_drv.c         | 215 +++++++++++++++++++++++++++-------
 include/linux/blkdev.h                |   2 -
 include/linux/swap.h                  |  47 ++++++++
 mm/page_io.c                          | 187 ++++++++++++++++++++++++++++-
 mm/swap.h                             |  18 +--
 mm/swapfile.c                         |  17 +--
 rust/kernel/block/mq/gen_disk.rs      |   1 -
 8 files changed, 414 insertions(+), 78 deletions(-)
---
base-commit: 842f51deada6449843f811bfa22e536a01ae5a0c
change-id: 20260614-zram-swap-ops-block-register-a1b2c3d4e5f6

Best regards,
-- 
Jianyue Wu <wujianyue000@gmail.com>




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds