[PATCH v2 0/2] drivers/char/mem: splice the zero page for /dev/zero and /dev/full

From: Kris Pan

Date: Sat Aug 29 2026 - 00:41:11 EST


Commit 1b057bd800c3 ("drivers/char/mem: implement splice() for
/dev/zero, /dev/full") added splice support to /dev/zero and /dev/full
using copy_splice_read(). The author noted that this could be optimized
by pushing references to the global zero page instead of allocating and
zeroing fresh pages for every pipe buffer, deferring it as "an
optimization for another day".

This series implements that optimization by splicing the zero page into
the pipe for /dev/zero and /dev/full, reusing the existing zero-page
splice logic from mm/shmem.c.

v2:
- Move zero_pipe_buf_ops and splice_zeropage_into_pipe() from mm/shmem.c
into fs/splice.c so they can be shared, instead of duplicating the
boilerplate (Max Kellermann's suggestion).
- Rework splice_read_zero() to use the shared helper.

Kris Pan (2):
fs: move splice_zeropage_into_pipe() and zero_pipe_buf_ops to
fs/splice.c
drivers/char/mem: splice the zero page for /dev/zero and /dev/full

drivers/char/mem.c | 29 ++++++++++++++++++--
fs/splice.c | 62 ++++++++++++++++++++++++++++++++++++++++++
include/linux/splice.h | 3 ++
mm/shmem.c | 45 ------------------------------
4 files changed, 92 insertions(+), 47 deletions(-)

--
2.43.0