]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/ublk: add shared memory zero-copy support in kublk
authorMing Lei <ming.lei@redhat.com>
Tue, 31 Mar 2026 15:31:56 +0000 (23:31 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 7 Apr 2026 13:41:55 +0000 (07:41 -0600)
commit166b476b8dee61dc6501f6eb91619d28c3430f75
treed2a7637f271a990746c9fc051d472876b7a34b83
parent8a34e88769f617dc980edb5a0079e347bd1b9a89
selftests/ublk: add shared memory zero-copy support in kublk

Add infrastructure for UBLK_F_SHMEM_ZC shared memory zero-copy:

- kublk.h: struct ublk_shmem_entry and table for tracking registered
  shared memory buffers
- kublk.c: per-device unix socket listener that accepts memfd
  registrations from clients via SCM_RIGHTS fd passing. The listener
  mmaps the memfd and registers the VA range with the kernel for PFN
  matching. Also adds --shmem_zc command line option.
- kublk.c: --htlb <path> option to open a pre-allocated hugetlbfs
  file, mmap it with MAP_SHARED|MAP_POPULATE, and register it with
  the kernel via ublk_ctrl_reg_buf(). Any process that mmaps the same
  hugetlbfs file shares the same physical pages, enabling zero-copy
  without socket-based fd passing.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://patch.msgid.link/20260331153207.3635125-6-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
tools/testing/selftests/ublk/kublk.c
tools/testing/selftests/ublk/kublk.h