Hi Chris,

On Tue, Nov 03, 2026 at 06:50:28PM +0000, Chris Wiseman wrote:
> verity_ctr() creates a dedicated dm_io_client (v->io) for every
> dm-verity target, but its only caller is verity_recheck(), which reads
> a single data block into a page from v->recheck_pool after a hash
> mismatch.  Because dm_io_client_create() preallocates a mempool of 16
> bios and 16 biovec-max (4 KiB) vectors per target, each dm-verity
> target permanently pins ~70 KiB of unreclaimable slab that a single-page
> read never uses (~2.4 MiB across 35 targets on Android, or ~4.1 MiB
> across 59 targets).
> 
> Replace dm_io() in verity_recheck() with bdev_rw_virt() and remove
> v->io.  bdev_rw_virt() puts the bio and single bio_vec on the stack and
> waits for completion, while keeping v->recheck_pool per-target.
> 
> Fixes: 9177f3c0dea6 ("dm-verity: recheck the hash after a failure")
> Link: 
> https://lore.kernel.org/dm-devel/[email protected]/
> Signed-off-by: Chris Wiseman <[email protected]>
> ---
> TEST (ARM64 QEMU, 59 dm-verity targets, sha256, 4K blocks, mem_profiling=1):
> 
> /proc/allocinfo growth from 0 to 35 targets (bytes):
>                                      BASE     PATCHED       DELTA
>   bio.c:biovec_init_pool        4,587,520   2,293,760  -2,293,760
>   bio.c:bioset_init             1,196,160   1,052,800    -143,360
>   dm-io.c:dm_io_client_create     107,520      53,760     -53,760
>   mempool.c:mempool_init_node      36,680      23,240     -13,440
>   Total (35 targets)            5,927,880   3,423,560  -2,504,320 (-71,552 
> B/target)
> 
> Unreclaimable slab saved by target count:
>    8 targets:   572,416 B (  559 KiB)
>   15 targets: 1,073,280 B (1,048 KiB)
>   35 targets: 2,504,320 B (2,446 KiB)  [SUnreclaim: BASE +8,436 kB vs PATCHED 
> +5,960 kB]
>   59 targets: 4,221,568 B (4,123 KiB)
> 
>  drivers/md/dm-verity-target.c | 24 +++---------------------
>  drivers/md/dm-verity.h        |  2 --
>  2 files changed, 3 insertions(+), 23 deletions(-)

Looks like a nice improvement!

Reviewed-by: Sami Tolvanen <[email protected]>

Sami

Reply via email to