mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Sarthak Kukreti <sarthakkukreti@google.com>
Cc: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Eric Biggers <ebiggers@kernel.org>,
	Brian Geffon <bgeffon@google.com>,
	David Stevens <stevensd@chromium.org>,
	dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dm-verity: export verify_wq to sysfs
Date: Tue, 17 Nov 2026 14:44:09 -0500	[thread overview]
Message-ID: <avyuiWKNFN19BSJB@redhat.com> (raw)
In-Reply-To: <20261116223301.1706170-1-sarthakkukreti@google.com>

On Mon, Nov 16, 2026 at 02:33:01PM -0800, Sarthak Kukreti wrote:
> Under heavy concurrent read bursts, dm-verity workers blocking on
> dm-bufio reads or locks can cause workqueue concurrency management to
> spawn hundreds of per-CPU kverityd threads across the system.
> 
> Export verify_wq to sysfs via WQ_SYSFS so userspace can inspect and
> configure workqueue attributes (such as max_active) per dm-verity
> device under /sys/bus/workqueue/devices/kverityd-<dev>-<id>/.
> 
> Co-developed-by: Brian Geffon <bgeffon@google.com>
> Signed-off-by: Brian Geffon <bgeffon@google.com>
> Co-developed-by: David Stevens <stevensd@chromium.org>
> Signed-off-by: David Stevens <stevensd@chromium.org>
> Signed-off-by: Sarthak Kukreti <sarthakkukreti@google.com>

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

> ---
>  drivers/md/dm-verity-target.c | 22 ++++++++++++++++++----
>  drivers/md/dm-verity.h        |  1 +
>  2 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
> index 306ed1f6c118..730adf931494 100644
> --- a/drivers/md/dm-verity-target.c
> +++ b/drivers/md/dm-verity-target.c
> @@ -18,6 +18,7 @@
>  #include "dm-verity-verify-sig.h"
>  #include "dm-audit.h"
>  #include <linux/hex.h>
> +#include <linux/idr.h>
>  #include <linux/module.h>
>  #include <linux/reboot.h>
>  #include <linux/string.h>
> @@ -26,6 +27,8 @@
>  
>  #define DM_MSG_PREFIX			"verity"
>  
> +static DEFINE_IDA(workqueue_ida);
> +
>  #define DM_VERITY_ENV_LENGTH		46
>  #define DM_VERITY_ENV_VAR_NAME		"DM_VERITY_ERR_BLOCK_NR"
>  
> @@ -1065,6 +1068,8 @@ static void verity_dtr(struct dm_target *ti)
>  
>  	if (v->verify_wq)
>  		destroy_workqueue(v->verify_wq);
> +	if (v->workqueue_id)
> +		ida_free(&workqueue_ida, v->workqueue_id);
>  
>  	mempool_exit(&v->recheck_pool);
>  	if (v->io)
> @@ -1421,7 +1426,7 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>  	struct dm_arg_set as;
>  	unsigned int num;
>  	unsigned long long num_ll;
> -	int r;
> +	int r, wq_id;
>  	int i;
>  	sector_t hash_position;
>  	char dummy;
> @@ -1637,6 +1642,14 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>  		goto bad;
>  	}
>  
> +	wq_id = ida_alloc_min(&workqueue_ida, 1, GFP_KERNEL);
> +	if (wq_id < 0) {
> +		ti->error = "Cannot allocate workqueue id";
> +		r = wq_id;
> +		goto bad;
> +	}
> +	v->workqueue_id = wq_id;
> +
>  	/*
>  	 * Using WQ_HIGHPRI improves throughput and completion latency by
>  	 * reducing wait times when reading from a dm-verity device.
> @@ -1646,9 +1659,10 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>  	 * will fall-back to using it for error handling (or if the bufio cache
>  	 * doesn't have required hashes).
>  	 */
> -	v->verify_wq = alloc_workqueue("kverityd",
> -				       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU,
> -				       0);
> +	v->verify_wq = alloc_workqueue("kverityd-%s-%d",
> +				       WQ_MEM_RECLAIM | WQ_HIGHPRI |
> +				       WQ_PERCPU | WQ_SYSFS, 0,
> +				       dm_table_device_name(ti->table), wq_id);
>  	if (!v->verify_wq) {
>  		ti->error = "Cannot allocate workqueue";
>  		r = -ENOMEM;
> diff --git a/drivers/md/dm-verity.h b/drivers/md/dm-verity.h
> index e104a651c657..53f894f259d3 100644
> --- a/drivers/md/dm-verity.h
> +++ b/drivers/md/dm-verity.h
> @@ -71,6 +71,7 @@ struct dm_verity {
>  	atomic_t corrupted_errs;/* Number of errors for corrupted blocks */
>  
>  	struct workqueue_struct *verify_wq;
> +	int workqueue_id;
>  
>  	/* starting blocks for each tree level. 0 is the lowest level. */
>  	sector_t hash_level_block[DM_VERITY_MAX_LEVELS];
> -- 
> 2.56.0.679.gc527c65306-goog


      reply	other threads:[~2026-11-17 19:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 22:33 Sarthak Kukreti
2026-11-17 19:44 ` Benjamin Marzinski [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=avyuiWKNFN19BSJB@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=agk@redhat.com \
    --cc=bgeffon@google.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=ebiggers@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=sarthakkukreti@google.com \
    --cc=snitzer@kernel.org \
    --cc=stevensd@chromium.org \
    /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®