Message ID | 20240130091300.2968534-9-tj@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-44228-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1095970dyb; Tue, 30 Jan 2024 01:23:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMU39VbzvCaGbo2tvQy4dD//U4CX+KpsYxJwWQI7CN5goDhvCImkiJU+LWMNA76bFLvpsd X-Received: by 2002:a05:6358:79b:b0:176:26f9:6ee with SMTP id n27-20020a056358079b00b0017626f906eemr9243093rwj.31.1706606613981; Tue, 30 Jan 2024 01:23:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706606613; cv=pass; d=google.com; s=arc-20160816; b=eyuzBk6dux5H5CeaKK1RC2jw6chsuctHYUrLW+cDjIMmyjvxnDUp5kdvNf6Mb4qIdm W6Tg+VJUaEgAEZJZiO/DUEJdGavdGTWIic1twSRKoD4heSDfrPV+9YpxPqnH8PVjjjtm dcZD6ZFWrEhce+dDPCjfgMUD6z01KtIqhguwjw0Sl1h07hvUHIaPJVNsjXw+xmStjhwz gx6wuUD+lR7UnpREtzUiTHa8YXui9yJhT7cuily+buMoJWVAivxfws4NC9TEGbCG7rWZ mUZpafyOVdE0auf4jEl7R57IKc1wiz3olnzRL9E0lGYCrMAYs2YlWEKeulYcjZ1Ba9AQ zuVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:sender:dkim-signature; bh=kP7G/zPUbEjcGqCRjgaQMWAAf9wDrODicb4k9l2g++8=; fh=nv48Pg10cxUB7pT5q0M/ZChn1z8xpByQkNe5Mv6KhbA=; b=krgtosZG5ke+RVpuQjYmjAJ/uO6tx77ovp6VjMIvixLvmAnQhtOFz2rW148fSuDsiL E/LMoiKUCYbHjic7Xl9N9S0pK6v09i87mM+OoTZ3JV2j2qyVPLeDHJcB6sbzk/XTIAII tVfBt5EaK5R+fuopJN+YzjpCFr/tEeH8A3sG6bE6oas0J6gT1Zb3BTprjZkXQyMn7fuB atFiyqDwdWkjU4HM7ahqZ+guA3kWk1L5on5Gxq4DFTuosQqKF2mUsX7eN9NdaZ59sCg8 0vjRG1eEMgQ6JJ2h6Pcl1RPCWBbGqs6vXbm1QemM5rQL4AFSNq+JANG/lLOhzLVr8rxO AwKA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V6Pe6k+U; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-44228-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44228-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l26-20020a63701a000000b005b95ee3edc6si7470961pgc.628.2024.01.30.01.23.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:23:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44228-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V6Pe6k+U; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-44228-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44228-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5164C293CF7 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 09:17:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A62CE6A01B; Tue, 30 Jan 2024 09:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V6Pe6k+U" Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11580679EC; Tue, 30 Jan 2024 09:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706605999; cv=none; b=GkDTpyxZi27W9n9AQDn+KqvktuXLyqFrRQjNgf0Xz81EANEftCpI6zkeO+/mzBVXgEEKLw8vC50O+RRfCf7KsKmwHUwuBYiKnubQ03zIS8pU6LLvneYhzwycCuEsri4Nai2uJNg0guSHgLajdgh9EEDwWT8xLFliDT3yvc/PA1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706605999; c=relaxed/simple; bh=yxd9IHSWjzcBrPuUDO7+SCI1N0zvICZf05uTKbbfPXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AvGxjly5iM+H29jokXv6wgFDDUN6c7XxxYyyTis9zougPD3eHiWFy1LpwYNrZhG+mhVTzlezvzGGO7MnJc8zRjFN6N+UuU3sMymfJN1n6pxUMJFx1WlPw4yVd6go6veHfPswnSl85hjr+e4dNFEumlRauUtvGvOq0mpnxKqW6vU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V6Pe6k+U; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6e1214ae9d4so1189040a34.3; Tue, 30 Jan 2024 01:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706605997; x=1707210797; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=kP7G/zPUbEjcGqCRjgaQMWAAf9wDrODicb4k9l2g++8=; b=V6Pe6k+UGrgqV7xqpVrcPSh4/WagxZcW6mVw87SxgkRJqAjxyXUfuq2csLKHoPFYOA wbEWNj/drHXX/UXtPMGayfKC3QAjqL4BkL6SvcXYHK1gUBvDzisitzOiU8/EluqgcxAU yM3wcUZ9bG1xzuosC4eeY1cI5pXwhlprp2M8yYW0nDZeXwOK9dtuHLVM3ys2zeLCCwrt WMoTZp6CKUqK9y7noEWv+KxA0ekazZqNWanG2o8HAMSQIgocy4ipIfENpe+ggCd8bSys vDvkGo0HvH+JYn10rcnvBpFvOk+8aPh7hO8Io8e6fokvd1IPZnQknoZhpICYsZDms35i 04wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706605997; x=1707210797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kP7G/zPUbEjcGqCRjgaQMWAAf9wDrODicb4k9l2g++8=; b=pSkpwMqZzWGQgELxlm9IEkN8M4GHSQMYjjnlCDZCHyMpI2LtV3I7++gKkfjSzo+0FZ FsASvyi1TYC0aKhRLC0qpXJOb/UTMa2f0eQ5PhhY6K0yyNBm3T39vy4fWgUixuDaUTeD RgDyeWSOk5+aWpupZCFLVm7fM87kZyyUqqISZ8KAVe2wS952yj3XByeUU338SFTU3lyD kSdHXdwHRN+LuirjVKDSCCasyJjsYAXuoGyzHFxk1Oc0Y2SY5kzLJ8noAb0FpR6JlQ6y i8ihZWm6mkwMYUhcpekAcN2eZSKwieAGEdwkr87vGkXOnobKKytsfEPwqKEN+o5eVvRA btjw== X-Gm-Message-State: AOJu0Yw7CM89QiNGnN+7I/mM+wrBryMcw5P9ScZW0wew9y6om/UiX2ft zDU1i6h+u3f+m8E3N2QdDEiqE6Endj6QXS/1KLTE2whcaI3jGNtV X-Received: by 2002:a05:6358:7e83:b0:178:7f7d:91a6 with SMTP id o3-20020a0563587e8300b001787f7d91a6mr2601345rwn.46.1706605997066; Tue, 30 Jan 2024 01:13:17 -0800 (PST) Received: from localhost (dhcp-141-239-144-21.hawaiiantel.net. [141.239.144.21]) by smtp.gmail.com with ESMTPSA id b4-20020a056a000a8400b006dde023cce8sm7211721pfl.57.2024.01.30.01.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:13:16 -0800 (PST) Sender: Tejun Heo <htejun@gmail.com> From: Tejun Heo <tj@kernel.org> To: torvalds@linux-foundation.org, mpatocka@redhat.com Cc: linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, msnitzer@redhat.com, ignat@cloudflare.com, damien.lemoal@wdc.com, bob.liu@oracle.com, houtao1@huawei.com, peterz@infradead.org, mingo@kernel.org, netdev@vger.kernel.org, allen.lkml@gmail.com, kernel-team@meta.com, Tejun Heo <tj@kernel.org>, Alasdair Kergon <agk@redhat.com>, Mike Snitzer <snitzer@kernel.org> Subject: [PATCH 8/8] dm-verity: Convert from tasklet to BH workqueue Date: Mon, 29 Jan 2024 23:11:55 -1000 Message-ID: <20240130091300.2968534-9-tj@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130091300.2968534-1-tj@kernel.org> References: <20240130091300.2968534-1-tj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789506736591745889 X-GMAIL-MSGID: 1789506736591745889 |
Series |
[1/8] workqueue: Update lock debugging code
|
|
Commit Message
Tejun Heo
Jan. 30, 2024, 9:11 a.m. UTC
The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.
This patch converts dm-verity from tasklet to BH workqueue.
This is a minimal conversion which doesn't rename the related names
including the "try_verify_in_tasklet" option. If this patch is applied, a
follow-up patch would be necessary. I couldn't decide whether the option
name would need to be updated too.
Only compile tested. I don't know how to verity.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@kernel.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: dm-devel@lists.linux.dev
---
drivers/md/dm-verity-target.c | 8 ++++----
drivers/md/dm-verity.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
Comments
On Mon, 29 Jan 2024, Tejun Heo wrote: > The only generic interface to execute asynchronously in the BH context is > tasklet; however, it's marked deprecated and has some design flaws. To > replace tasklets, BH workqueue support was recently added. A BH workqueue > behaves similarly to regular workqueues except that the queued work items > are executed in the BH context. > > This patch converts dm-verity from tasklet to BH workqueue. > > This is a minimal conversion which doesn't rename the related names > including the "try_verify_in_tasklet" option. If this patch is applied, a > follow-up patch would be necessary. I couldn't decide whether the option > name would need to be updated too. > > Only compile tested. I don't know how to verity. Download the cryptsetup package with "git clone https://gitlab.com/cryptsetup/cryptsetup" and run the testsuite: /autogen.sh && ./configure && make && make check > Signed-off-by: Tejun Heo <tj@kernel.org> > Cc: Alasdair Kergon <agk@redhat.com> > Cc: Mike Snitzer <snitzer@kernel.org> > Cc: Mikulas Patocka <mpatocka@redhat.com> > Cc: dm-devel@lists.linux.dev > --- > drivers/md/dm-verity-target.c | 8 ++++---- > drivers/md/dm-verity.h | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index 14e58ae70521..911261de2d08 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -645,9 +645,9 @@ static void verity_work(struct work_struct *w) > verity_finish_io(io, errno_to_blk_status(verity_verify_io(io))); > } > > -static void verity_tasklet(unsigned long data) > +static void verity_bh_work(struct work_struct *w) > { > - struct dm_verity_io *io = (struct dm_verity_io *)data; > + struct dm_verity_io *io = container_of(w, struct dm_verity_io, bh_work); > int err; > > io->in_tasklet = true; > @@ -675,8 +675,8 @@ static void verity_end_io(struct bio *bio) > } > > if (static_branch_unlikely(&use_tasklet_enabled) && io->v->use_tasklet) { > - tasklet_init(&io->tasklet, verity_tasklet, (unsigned long)io); > - tasklet_schedule(&io->tasklet); > + INIT_WORK(&io->bh_work, verity_bh_work); > + queue_work(system_bh_wq, &io->bh_work); > } else { > INIT_WORK(&io->work, verity_work); > queue_work(io->v->verify_wq, &io->work); > diff --git a/drivers/md/dm-verity.h b/drivers/md/dm-verity.h > index f9d522c870e6..7c16f834f31a 100644 > --- a/drivers/md/dm-verity.h > +++ b/drivers/md/dm-verity.h > @@ -83,7 +83,7 @@ struct dm_verity_io { > struct bvec_iter iter; > > struct work_struct work; > - struct tasklet_struct tasklet; > + struct work_struct bh_work; > > /* > * Three variably-size fields follow this struct: Do we really need two separate work_structs here? They are never submitted concurrently, so I think that one would be enough. Or, am I missing something? Mikulas
Hello, On Wed, Jan 31, 2024 at 10:19:07PM +0100, Mikulas Patocka wrote: > > @@ -83,7 +83,7 @@ struct dm_verity_io { > > struct bvec_iter iter; > > > > struct work_struct work; > > - struct tasklet_struct tasklet; > > + struct work_struct bh_work; > > > > /* > > * Three variably-size fields follow this struct: > > Do we really need two separate work_structs here? They are never submitted > concurrently, so I think that one would be enough. Or, am I missing > something? I don't know, so just did the dumb thing. If the caller always guarantees that the work items are never queued at the same time, reusing is fine. However, the followings might be useful to keep on mind: - work_struct is pretty small - 4 pointers. - INIT_WORK() on a queued work item isn't gonna be pretty. - Flushing and no-concurrent-execution guarantee are broken on INIT_WORK(). e.g. If you queue_work(), INIT_WORK(), flush_work(), the flush isn't actually going to wait for the work item to finish. Also, if you do queue_work(), INIT_WORK(), queue_work(), the two queued work item instances may end up running concurrently. Muxing a single work item carries more risks of subtle bugs, but in some cases, the way it's used is clear (e.g. sequential chaining) and that's fine. Thanks.
On Wed, 31 Jan 2024, Tejun Heo wrote: > Hello, > > On Wed, Jan 31, 2024 at 10:19:07PM +0100, Mikulas Patocka wrote: > > > @@ -83,7 +83,7 @@ struct dm_verity_io { > > > struct bvec_iter iter; > > > > > > struct work_struct work; > > > - struct tasklet_struct tasklet; > > > + struct work_struct bh_work; > > > > > > /* > > > * Three variably-size fields follow this struct: > > > > Do we really need two separate work_structs here? They are never submitted > > concurrently, so I think that one would be enough. Or, am I missing > > something? > > I don't know, so just did the dumb thing. If the caller always guarantees > that the work items are never queued at the same time, reusing is fine. > However, the followings might be useful to keep on mind: > > - work_struct is pretty small - 4 pointers. > > - INIT_WORK() on a queued work item isn't gonna be pretty. > > - Flushing and no-concurrent-execution guarantee are broken on INIT_WORK(). > e.g. If you queue_work(), INIT_WORK(), flush_work(), the flush isn't > actually going to wait for the work item to finish. Also, if you do > queue_work(), INIT_WORK(), queue_work(), the two queued work item > instances may end up running concurrently. > > Muxing a single work item carries more risks of subtle bugs, but in some > cases, the way it's used is clear (e.g. sequential chaining) and that's > fine. The code doesn't call INIT_WORK() on a queued work item and it doesn't flush the workqueue (it destroys it only in a situation when there are no work items running) so I think it's safe to use just one work_struct. Mikulas
On Wed, 31 Jan 2024 at 13:32, Tejun Heo <tj@kernel.org> wrote: > > I don't know, so just did the dumb thing. If the caller always guarantees > that the work items are never queued at the same time, reusing is fine. So the reason I thought it would be a good cleanup to introduce that "atomic" workqueue thing (now "bh") was that this case literally has a switch between "use tasklets' or "use workqueues". So it's not even about "reusing" the workqueue, it's literally a matter of making it always just use workqueues, and the switch then becomes just *which* workqueue to use - system or bh. In fact, I suspect there is very little reason ever to *not* just use the bh one, and even the switch could be removed. Because I think the only reason the "workqueue of tasklet" choice existed in the first place was that workqueues were the "proper" data structure, and the tasklet case was added later as a latency hack, and everybody knew that tasklets were deprecated. Linus
Hello, Linus. On Wed, Jan 31, 2024 at 03:19:01PM -0800, Linus Torvalds wrote: > On Wed, 31 Jan 2024 at 13:32, Tejun Heo <tj@kernel.org> wrote: > > > > I don't know, so just did the dumb thing. If the caller always guarantees > > that the work items are never queued at the same time, reusing is fine. > > So the reason I thought it would be a good cleanup to introduce that > "atomic" workqueue thing (now "bh") was that this case literally has a > switch between "use tasklets' or "use workqueues". > > So it's not even about "reusing" the workqueue, it's literally a > matter of making it always just use workqueues, and the switch then > becomes just *which* workqueue to use - system or bh. Yeah, that's how the dm-crypt got converted. The patch just before this one. This one probably can be converted the same way. I don't see the work item being re-initialized. It probably is better to initialize the work item together with the enclosing struct and then just queue it when needed. Mikulas, I couldn't decide what to do with the "try_verify_in_tasklet" option and just decided to do the minimal thing hoping that someone more familiar with the code can take over the actual conversion. How much of user interface commitment is that? Should it be renamed or would it be better to leave it be? Thanks.
On Wed, Jan 31 2024 at 6:19P -0500, Linus Torvalds <torvalds@linux-foundation.org> wrote: > On Wed, 31 Jan 2024 at 13:32, Tejun Heo <tj@kernel.org> wrote: > > > > I don't know, so just did the dumb thing. If the caller always guarantees > > that the work items are never queued at the same time, reusing is fine. > > So the reason I thought it would be a good cleanup to introduce that > "atomic" workqueue thing (now "bh") was that this case literally has a > switch between "use tasklets' or "use workqueues". > > So it's not even about "reusing" the workqueue, it's literally a > matter of making it always just use workqueues, and the switch then > becomes just *which* workqueue to use - system or bh. DM generally always use dedicated workqueues instead of the system. The dm-crypt tasklet's completion path did punt to the workqueue otherwise there was use-after-free of the per-bio-data that included the tasklet. And for verity there was fallback to workqueue if tasklet-based verification failed. Didn't inspire confidence. > In fact, I suspect there is very little reason ever to *not* just use > the bh one, and even the switch could be removed. > > Because I think the only reason the "workqueue of tasklet" choice > existed in the first place was that workqueues were the "proper" data > structure, and the tasklet case was added later as a latency hack, and > everybody knew that tasklets were deprecated. Correct, abusing tasklets was a very contrived latency optimization. Happy to see it all go away! (hindsight: it never should have gone in). Mike
On Wed, Jan 31 2024 at 7:04P -0500, Tejun Heo <tj@kernel.org> wrote: > Hello, Linus. > > On Wed, Jan 31, 2024 at 03:19:01PM -0800, Linus Torvalds wrote: > > On Wed, 31 Jan 2024 at 13:32, Tejun Heo <tj@kernel.org> wrote: > > > > > > I don't know, so just did the dumb thing. If the caller always guarantees > > > that the work items are never queued at the same time, reusing is fine. > > > > So the reason I thought it would be a good cleanup to introduce that > > "atomic" workqueue thing (now "bh") was that this case literally has a > > switch between "use tasklets' or "use workqueues". > > > > So it's not even about "reusing" the workqueue, it's literally a > > matter of making it always just use workqueues, and the switch then > > becomes just *which* workqueue to use - system or bh. > > Yeah, that's how the dm-crypt got converted. The patch just before this one. > This one probably can be converted the same way. I don't see the work item > being re-initialized. It probably is better to initialize the work item > together with the enclosing struct and then just queue it when needed. Sounds good. > Mikulas, I couldn't decide what to do with the "try_verify_in_tasklet" > option and just decided to do the minimal thing hoping that someone more > familiar with the code can take over the actual conversion. How much of user > interface commitment is that? Should it be renamed or would it be better to > leave it be? cryptsetup did add support for it, so I think it worthwhile to preserve the option; but it'd be fine to have it just be a backward compatible alias for a more appropriately named option? Mike
On Wed, Jan 31 2024 at 7:19P -0500, Mike Snitzer <snitzer@kernel.org> wrote: > On Wed, Jan 31 2024 at 7:04P -0500, > Tejun Heo <tj@kernel.org> wrote: > > > Hello, Linus. > > > > On Wed, Jan 31, 2024 at 03:19:01PM -0800, Linus Torvalds wrote: > > > On Wed, 31 Jan 2024 at 13:32, Tejun Heo <tj@kernel.org> wrote: > > > > > > > > I don't know, so just did the dumb thing. If the caller always guarantees > > > > that the work items are never queued at the same time, reusing is fine. > > > > > > So the reason I thought it would be a good cleanup to introduce that > > > "atomic" workqueue thing (now "bh") was that this case literally has a > > > switch between "use tasklets' or "use workqueues". > > > > > > So it's not even about "reusing" the workqueue, it's literally a > > > matter of making it always just use workqueues, and the switch then > > > becomes just *which* workqueue to use - system or bh. > > > > Yeah, that's how the dm-crypt got converted. The patch just before this one. > > This one probably can be converted the same way. I don't see the work item > > being re-initialized. It probably is better to initialize the work item > > together with the enclosing struct and then just queue it when needed. > > Sounds good. > > > Mikulas, I couldn't decide what to do with the "try_verify_in_tasklet" > > option and just decided to do the minimal thing hoping that someone more > > familiar with the code can take over the actual conversion. How much of user > > interface commitment is that? Should it be renamed or would it be better to > > leave it be? > > cryptsetup did add support for it, so I think it worthwhile to > preserve the option; but it'd be fine to have it just be a backward > compatible alias for a more appropriately named option? Hey Tejun, I'm not sure where things stand with the 6.9 workqueue changes to add BH workqueue. I had a look at your various branches and I'm not seeing where you might have staged any conversion patches (like this dm-verity one). I just staged various unrelated dm-verity and dm-crypt 6.8 fixes from Mikulas that I'll be sending to Linus later this week (for v6.8-rc6). Those changes required rebasing 'dm-6.9' because of conflicts, here is the dm-6.9 branch: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=dm-6.9 So we'll definitely need to rebase your changes on dm-6.9 to convert dm-crypt and dm-verity over to your BH workqueue. Are you OK with doing that or would you prefer I merge some 6.9 workqueue branch that you have into dm-6.9? And then Mikulas and I work to make the required DM target conversion changes? However you'd like to do it: please let me know where you have the latest 6.9 code the adds BH workqueue (and if you have DM target conversion code that reflects your latest). Thanks, Mike
Hello, Mike. On Tue, Feb 20, 2024 at 02:44:29PM -0500, Mike Snitzer wrote: > I'm not sure where things stand with the 6.9 workqueue changes to add > BH workqueue. I had a look at your various branches and I'm not > seeing where you might have staged any conversion patches (like this > dm-verity one). Yeah, the branch is for-6.9-bh-conversions in the wq tree but I haven't queued the DM patches yet. Wanted to make sure the perf signal from TCP conversion is okay first. FWIW, while Eric still has concerns, the initial test didn't show any appreciable regression with production memcache workload on our side. > I just staged various unrelated dm-verity and dm-crypt 6.8 fixes from > Mikulas that I'll be sending to Linus later this week (for v6.8-rc6). > Those changes required rebasing 'dm-6.9' because of conflicts, here is > the dm-6.9 branch: > https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=dm-6.9 > > So we'll definitely need to rebase your changes on dm-6.9 to convert > dm-crypt and dm-verity over to your BH workqueue. Are you OK with > doing that or would you prefer I merge some 6.9 workqueue branch that > you have into dm-6.9? And then Mikulas and I work to make the required > DM target conversion changes? Oh, if you don't mind, it'd be best if you could pull wq/for-6.9 into dm-6.9 and do the conversions there. Thank you.
On Tue, Feb 20 2024 at 3:05P -0500, Tejun Heo <tj@kernel.org> wrote: > Hello, Mike. > > On Tue, Feb 20, 2024 at 02:44:29PM -0500, Mike Snitzer wrote: > > I'm not sure where things stand with the 6.9 workqueue changes to add > > BH workqueue. I had a look at your various branches and I'm not > > seeing where you might have staged any conversion patches (like this > > dm-verity one). > > Yeah, the branch is for-6.9-bh-conversions in the wq tree but I haven't > queued the DM patches yet. Wanted to make sure the perf signal from TCP > conversion is okay first. FWIW, while Eric still has concerns, the initial > test didn't show any appreciable regression with production memcache > workload on our side. > > > I just staged various unrelated dm-verity and dm-crypt 6.8 fixes from > > Mikulas that I'll be sending to Linus later this week (for v6.8-rc6). > > Those changes required rebasing 'dm-6.9' because of conflicts, here is > > the dm-6.9 branch: > > https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=dm-6.9 > > > > So we'll definitely need to rebase your changes on dm-6.9 to convert > > dm-crypt and dm-verity over to your BH workqueue. Are you OK with > > doing that or would you prefer I merge some 6.9 workqueue branch that > > you have into dm-6.9? And then Mikulas and I work to make the required > > DM target conversion changes? > > Oh, if you don't mind, it'd be best if you could pull wq/for-6.9 into dm-6.9 > and do the conversions there. > > Thank you. I've rebased and made the changes available in this dm-6.9-bh-wq branch: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=dm-6.9-bh-wq I left them both DM conversion commits attributed to use despite the rebase (and churn of renames I did in the dm-verity commit); hopefully you're fine with that but if not I can split the renames out. I successfully tested using the cryptsetup testsuite ('make check'). And I've also added these changes to linux-next, via linux-dm.git's 'for-next': https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=for-next Mikulas, feel free to review/test and possibly add another patch for dm-verity that only uses a single work_struct in struct dm_verity_io Thanks, Mike
On Thu, Feb 22, 2024 at 04:24:45PM -0500, Mike Snitzer wrote: > I've rebased and made the changes available in this dm-6.9-bh-wq branch: > https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=dm-6.9-bh-wq > > I left them both DM conversion commits attributed to use despite the > rebase (and churn of renames I did in the dm-verity commit); hopefully > you're fine with that but if not I can split the renames out. Looks good to me. Thanks.
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 14e58ae70521..911261de2d08 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -645,9 +645,9 @@ static void verity_work(struct work_struct *w) verity_finish_io(io, errno_to_blk_status(verity_verify_io(io))); } -static void verity_tasklet(unsigned long data) +static void verity_bh_work(struct work_struct *w) { - struct dm_verity_io *io = (struct dm_verity_io *)data; + struct dm_verity_io *io = container_of(w, struct dm_verity_io, bh_work); int err; io->in_tasklet = true; @@ -675,8 +675,8 @@ static void verity_end_io(struct bio *bio) } if (static_branch_unlikely(&use_tasklet_enabled) && io->v->use_tasklet) { - tasklet_init(&io->tasklet, verity_tasklet, (unsigned long)io); - tasklet_schedule(&io->tasklet); + INIT_WORK(&io->bh_work, verity_bh_work); + queue_work(system_bh_wq, &io->bh_work); } else { INIT_WORK(&io->work, verity_work); queue_work(io->v->verify_wq, &io->work); diff --git a/drivers/md/dm-verity.h b/drivers/md/dm-verity.h index f9d522c870e6..7c16f834f31a 100644 --- a/drivers/md/dm-verity.h +++ b/drivers/md/dm-verity.h @@ -83,7 +83,7 @@ struct dm_verity_io { struct bvec_iter iter; struct work_struct work; - struct tasklet_struct tasklet; + struct work_struct bh_work; /* * Three variably-size fields follow this struct: