]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: avoid unpinning pages under maple tree spinlock
authorMing Lei <tom.leiming@gmail.com>
Thu, 23 Apr 2026 03:30:58 +0000 (11:30 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 23 Apr 2026 10:52:47 +0000 (04:52 -0600)
commit309e02dccf64e1b7bd2067abedc270e33b0aadf3
tree60c12baee4f3adc7ce62a8588bd3ced055a8aabb
parentea1db795de5fe9ea6844f3152483c4d3a02c0480
ublk: avoid unpinning pages under maple tree spinlock

ublk_shmem_remove_ranges() calls unpin_user_pages() while holding the
maple tree spinlock (mas_lock). Although unpin_user_pages() is safe in
atomic context, holding the spinlock across potentially many page
unpinning operations is not ideal.

Split into __ublk_shmem_remove_ranges() which erases up to 64 ranges
under mas_lock, collecting base_pfn and nr_pages into a temporary
xarray. Then drop the lock and unpin pages outside spinlock context.
ublk_shmem_remove_ranges() loops until all matching ranges are
processed.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20260423033058.2805135-4-tom.leiming@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c