From: Sami Tolvanen <samitolvanen@google.com>
To: Chris Wiseman <chriswiseman@google.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
dm-devel@lists.linux.dev,
Benjamin Marzinski <bmarzins@redhat.com>,
Eric Biggers <ebiggers@kernel.org>,
Christoph Hellwig <hch@lst.de>,
LongPing Wei <weilongping@oppo.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dm-verity: use bdev_rw_virt() in verity_recheck()
Date: Wed, 4 Nov 2026 00:50:24 +0000 [thread overview]
Message-ID: <20261104005024.GA1247794@google.com> (raw)
In-Reply-To: <18e49db5e159b72d.3137322e32332e3235332e313736.1d9cee.0000sendgmr@google.com>
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/20250423115013.4004577-1-weilongping@oppo.com/
> Signed-off-by: Chris Wiseman <chriswiseman@google.com>
> ---
> 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 <samitolvanen@google.com>
Sami
prev parent reply other threads:[~2026-11-04 0:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 18:50 Chris Wiseman
2026-11-03 22:11 ` Eric Biggers
2026-11-04 0:50 ` Sami Tolvanen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104005024.GA1247794@google.com \
--to=samitolvanen@google.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=chriswiseman@google.com \
--cc=dm-devel@lists.linux.dev \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
--cc=weilongping@oppo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®