From: Benjamin Marzinski <bmarzins@redhat.com>
To: Yongpeng Yang <yangyongpeng.storage@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
dm-devel@lists.linux.dev, Yongpeng Yang <yangyongpeng@xiaomi.com>
Subject: Re: [PATCH 1/4] dm-bufio: make the retain target per client
Date: Tue, 17 Nov 2026 19:41:22 -0500 [thread overview]
Message-ID: <avz0MuIaC8k9V9T8@redhat.com> (raw)
In-Reply-To: <20261117131918.2745193-4-yangyongpeng.storage@gmail.com>
On Tue, Nov 17, 2026 at 09:19:17PM +0800, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> dm_bufio_retain_bytes is a module-wide value shared by every dm-bufio
> user, so raising it to keep one device's metadata cached also makes
> every small, idle device hold on to memory it does not need.
>
> Give each client its own target, initialized from the module parameter
> at creation. The parameter keeps its meaning as the default for new
> clients; clients that already exist are not affected.
>
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
> Assisted-by: LLM
Looks good except one minor nitpick.
> ---
> drivers/md/dm-bufio.c | 31 ++++++++++++++++++++++++++++++-
> include/linux/dm-bufio.h | 7 +++++++
> 2 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index 3b66cf1cb931..75b6e5c027ae 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c
[ ... ]
> @@ -2284,6 +2286,32 @@ void dm_bufio_set_minimum_buffers(struct dm_bufio_client *c, unsigned int n)
> }
> EXPORT_SYMBOL_GPL(dm_bufio_set_minimum_buffers);
>
> +/*
> + * Set the number of bytes this client tries to keep cached; 0 resets it
> + * to the module default. Non-zero values are rounded to a block
> + * boundary, at least one block.
> + */
> +void dm_bufio_set_retain_bytes(struct dm_bufio_client *c, unsigned long bytes)
> +{
> + if (!bytes) {
> + WRITE_ONCE(c->retain_bytes, READ_ONCE(dm_bufio_retain_bytes));
> + return;
> + }
> +
> + bytes -= bytes % c->block_size;
> + if (!bytes)
> + bytes = c->block_size;
Instead of rounding down, except when that would round to 0, why not
always round up, so dm_bufio retains at least as many bytes as
requested?
-Ben
next prev parent reply other threads:[~2026-11-18 0:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 13:19 [PATCH 0/4] dm-bufio: per-client retain target, sysfs and dm-verity cache control Yongpeng Yang
2026-11-17 13:19 ` [PATCH 1/4] dm-bufio: make the retain target per client Yongpeng Yang
2026-11-18 0:41 ` Benjamin Marzinski [this message]
2026-11-17 13:19 ` [PATCH 2/4] dm-bufio: allow exposing a client in sysfs under a caller-chosen kobject Yongpeng Yang
2026-11-17 13:40 ` sashiko-bot
2026-11-17 13:19 ` [PATCH 3/4] dm-verity: size the hash retain target from the hash area Yongpeng Yang
2026-11-17 13:44 ` sashiko-bot
2026-11-17 13:19 ` [PATCH 4/4] dm-verity: add messages to inspect, prefetch and drop hash blocks Yongpeng Yang
2026-11-17 13:49 ` sashiko-bot
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=avz0MuIaC8k9V9T8@redhat.com \
--to=bmarzins@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
--cc=yangyongpeng.storage@gmail.com \
--cc=yangyongpeng@xiaomi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.