From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3798ECE7AFF for ; Fri, 6 Sep 2024 10:59:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 913F76B007B; Fri, 6 Sep 2024 06:59:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89C936B0082; Fri, 6 Sep 2024 06:59:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73CD86B0089; Fri, 6 Sep 2024 06:59:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 540616B007B for ; Fri, 6 Sep 2024 06:59:45 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6D2EB1A106B for ; Fri, 6 Sep 2024 10:59:44 +0000 (UTC) X-FDA: 82534017888.20.5CE3BED Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id BF36FA0010 for ; Fri, 6 Sep 2024 10:59:41 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zuuf6cR0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725620381; a=rsa-sha256; cv=none; b=CYfcmsdtKqugEpJ7zjoZFhSv8RKL+VPGQT2GkviCkpM809aQCGF+BAzI8YoAkSQXPDPKUn vKM0Cz6k2RyQqtnIuEdDokJgoqKL1OIXSqCA/+KBXlGJ80GaJz7j9czeiW5J+WOexR5vB/ mnpP7FMkWsvDx1oEbfzRkHwyZ42MYZ0= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zuuf6cR0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725620381; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Lii+zCyvH1nupBnz/bs5CIqcmUeaf64t1+wdh+5exj0=; b=AVp2/IspVryyyRXl1lytg1OjOy8XO1h08zmdOmBh7fryonWOZh8zyGcxu6U8nnr1JssmZi nv+nN+PyzuvhYqykh+s3qd3S5NI8zO0mjoe00T/FTIeyPNdYH3qPMatVnNN0+gjkrIWwJt MhmI691nFfcQttQ8mHvbA3WviNTxots= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725620381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lii+zCyvH1nupBnz/bs5CIqcmUeaf64t1+wdh+5exj0=; b=Zuuf6cR0WzWK9LyrH9w1La7YmSV6j9VClyd5LzOQbr/P6VRnQuUmNsJ41s9tkFvxMXwN49 EBX/6OrTLKZewmON6kZ4E7Y5w2AVcIsXxdUcuvtBu8YK6e9mcdKafaH+4LJ74+vXguj6vU 8kaLVGNfZVjfhECqhVxSVRi5kbARXQs= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-263-HweLr_pDN5ybzRciXidryw-1; Fri, 06 Sep 2024 06:59:35 -0400 X-MC-Unique: HweLr_pDN5ybzRciXidryw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 028191955BC1; Fri, 6 Sep 2024 10:59:34 +0000 (UTC) Received: from [10.45.224.222] (unknown [10.45.224.222]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E0B911956086; Fri, 6 Sep 2024 10:59:30 +0000 (UTC) Date: Fri, 6 Sep 2024 12:59:25 +0200 (CEST) From: Mikulas Patocka To: Eric Biggers cc: dm-devel@lists.linux.dev, Alasdair Kergon , Mike Snitzer , Tejun Heo , Lai Jiangshan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sami Tolvanen Subject: Re: [PATCH] dm verity: don't use WQ_MEM_RECLAIM In-Reply-To: <20240905223555.GA1512@sol.localdomain> Message-ID: References: <20240904040444.56070-1-ebiggers@kernel.org> <086a76c4-98da-d9d1-9f2f-6249c3d55fe9@redhat.com> <20240905223555.GA1512@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Stat-Signature: hyxazb6p49d4j86f5bu6wmyoya1bs9re X-Rspamd-Queue-Id: BF36FA0010 X-Rspamd-Server: rspam02 X-HE-Tag: 1725620381-269269 X-HE-Meta: U2FsdG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P/frcuz4oaXlwBvp/HhhjuZNh3pUBplGoPsbpNY/yvkseyK1i6IZEVIaWMlq1imM6s+nh2NOFtKrmKoVG09Ww6iE4ZK83eHSB7fRNY0vEj6ZF0/u2DjGgQWQPcCzp6HXRU3/3PhuwxWoxA3JN26dQ5x5Oi7yFmWIro5OswsOrw+uLLTlG1rmZOqrMjwQDcD/V/zhRnsymNzDePI7iF0/OQzhkDJHFmeQFwlycSH2GuakG8rQCcXQehaGC/tZ7CztFUnehwTvvrXOYqtpbYKeps8umIPg4Z+nmSXlnxx6tS X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, 5 Sep 2024, Eric Biggers wrote: > On Thu, Sep 05, 2024 at 08:21:46PM +0200, Mikulas Patocka wrote: > > > > > > On Tue, 3 Sep 2024, Eric Biggers wrote: > > > > > From: Eric Biggers > > > > > > Since dm-verity doesn't support writes, the kernel's memory reclaim code > > > will never wait on dm-verity work. That makes the use of WQ_MEM_RECLAIM > > > in dm-verity unnecessary. WQ_MEM_RECLAIM has been present from the > > > beginning of dm-verity, but I could not find a justification for it; > > > I suspect it was just copied from dm-crypt which does support writes. > > > > > > Therefore, remove WQ_MEM_RECLAIM from dm-verity. This eliminates the > > > creation of an unnecessary rescuer thread per dm-verity device. > > > > > > Signed-off-by: Eric Biggers > > > > Hmm. I can think about a case where you have read-only dm-verity device, > > on the top of that you have dm-snapshot device and on the top of that you > > have a writable filesystem. > > > > When the filesystem needs to write data, it submits some write bios. When > > dm-snapshot receives these write bios, it will read from the dm-verity > > device and write to the snapshot's exception store device. So, dm-verity > > needs WQ_MEM_RECLAIM in this case. > > > > Mikulas > > > > Yes, unfortunately that sounds correct. > > This means that any workqueue involved in fulfilling block device I/O, > regardless of whether that I/O is read or write, has to use WQ_MEM_RECLAIM. > > I wonder if there's any way to safely share the rescuer threads. > > - Eric When I thought about it, I think that removing WQ_MEM_RECLAIM would be incorrect even without snapshot and it could deadlock even with a read-only filesystem directly on the top of dm-verity. There is a limited number of workqueue kernel threads in the system. If all the workqueue kernel threads are busy trying to read some data from a filesystem that is on the top of dm-verity, then the system deadlocks. Dm-verity would wait until one of the work items exits - and the work items would wait for dm-verity to return the data. The probability that this happens is low, but theoretically it is wrong. Mikulas