Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2457385rdb; Sun, 3 Dec 2023 18:40:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpn7vLq59D4NpJVS2RjuRAcWfz+6sR1JOBL4gob+4+lPn7oUmWF+BpRep/0NYDolvDO/7u X-Received: by 2002:a05:6512:401e:b0:50b:d763:fe40 with SMTP id br30-20020a056512401e00b0050bd763fe40mr2817404lfb.91.1701657651828; Sun, 03 Dec 2023 18:40:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701657651; cv=none; d=google.com; s=arc-20160816; b=nbei5iM17aytsTZr5PWD4O9lQl8CmfPYH0fPxv17mJ56DqweqQmegizamrjHxZBg0U r9MyY3CFQ6l90+A6v+zMu4nNyPBC+HJpgP8eVt6QDuuLF43opitTXU1tpCTIg7eOUh63 JvtYvFPsCD8NsKVCeVMVojvBe4om54sc8pDrx1qL3u1UWhSsEbYWG5gyjAcW2YqH821c GVi6vLwSwwwhLnhxwHoTMjC5ViyyyhaW1xwL3trG6kkqcIV0JSbiM7yklnUaq+DTw7xB 8OwXxUoNpO/VGYponi0WxQ/kiz5LjJWtQLGNtVMh5+IG6PjI1V7sUvNNHEmLLrALKjzz 5NaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=LVTxDRpbm4m8/L9l+PdmnoSZZXeKUDl437Ufb7hbh2I=; fh=jjaZDJ/Hn1/vk73fwBZ/tCAZ2tk5BFbAmmN/VKCBpKo=; b=0Ba80tL5pMWc7hHQQVo7+doeWEZi5vPUajK9X4mKBn4GpFLfvHCiqjwhnoOBfF/dgl llDRQXc0VjwtkpFAPBzWxB/TySJXGmccQJMddpAKKbJqN6AedMDLwRuI/eDlT1FGyBGv bf0gbMHcg+N8eGdA0bEadIw2R3QlOZ6xZv1XHWROO6jQhwMMYXTaVa4C+T1EYML9s7BG hAk0REe11cCz2cHYZzQvmr46sl37tbtpIFbfm0m6cGjxWBQf7cg8CGptxfZl7NePPEfv 7CSHJmWZ8Ja3tQvKytdxDUOVOG5vW8MPwM4yJ7MAvcytZK4bD5sB5evk+nqXatTkt2rr ishg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=XueloJ4X; spf=pass (google.com: domain of linux-nfs+bounces-270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f20-20020a0564021e9400b0054bdda70799si3884366edf.605.2023.12.03.18.40.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 18:40:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=XueloJ4X; spf=pass (google.com: domain of linux-nfs+bounces-270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 86A271F20F03 for ; Mon, 4 Dec 2023 02:40:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5D49814; Mon, 4 Dec 2023 02:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="XueloJ4X" X-Original-To: linux-nfs@vger.kernel.org Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC06C5; Sun, 3 Dec 2023 18:40:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LVTxDRpbm4m8/L9l+PdmnoSZZXeKUDl437Ufb7hbh2I=; b=XueloJ4XOx6AvGagXXqf5zKEn6 Kd5AGBMar6KgXfVvTp/7bdTGl3DdqsgzJxNve8zpIAvjgBZF3V0eQGEADal6zwOjS3aNKL4ftzMLN rjoiFwGFS3yizzESIkiPgOhziQogNXixp2rvMHVbe9hH6vo5z528uimva4HJN9LTEaMy3hA4xJJ6p 2J6Go6+2sdlMnM6i2xxXWn5D9YFtLk7fb+WBiY5TRAwsMUSUTJSyv4r4slX7mtCWJzKfssciHJsOZ 28eiZSUBaWqnd0eNWVAQ3j0FXQmUQpq9iWRRp65vJ4AaWDeVACyNu+yHrrr2reHauRZY7zS8495/5 wOj7nPaA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r9ysp-006nG8-1T; Mon, 04 Dec 2023 02:40:31 +0000 Date: Mon, 4 Dec 2023 02:40:31 +0000 From: Al Viro To: NeilBrown Cc: Christian Brauner , Jens Axboe , Oleg Nesterov , Chuck Lever , Jeff Layton , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: Re: [PATCH 1/2] Allow a kthread to declare that it calls task_work_run() Message-ID: <20231204024031.GV38156@ZenIV> References: <20231204014042.6754-1-neilb@suse.de> <20231204014042.6754-2-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231204014042.6754-2-neilb@suse.de> Sender: Al Viro On Mon, Dec 04, 2023 at 12:36:41PM +1100, NeilBrown wrote: > This means that any cost for doing the work is not imposed on the kernel > thread, and importantly excessive amounts of work cannot apply > back-pressure to reduce the amount of new work queued. It also means that a stuck ->release() won't end up with stuck kernel thread... > earlier than would be ideal. When __dput (from the workqueue) calls WTF is that __dput thing? __fput, perhaps? > This patch adds a new process flag PF_RUNS_TASK_WORK which is now used > instead of PF_KTHREAD to determine whether it is sensible to queue > something to task_works. This flag is always set for non-kernel threads. *ugh* What's that flag for? task_work_add() always can fail; any caller must have a fallback to cope with that possibility; fput() certainly does. Just have the kernel threads born with ->task_works set to &work_exited and provide a primitive that would flip it from that to NULL. > @@ -1328,7 +1328,7 @@ static void mntput_no_expire(struct mount *mnt) > > if (likely(!(mnt->mnt.mnt_flags & MNT_INTERNAL))) { > struct task_struct *task = current; > - if (likely(!(task->flags & PF_KTHREAD))) { > + if (likely((task->flags & PF_RUNS_TASK_WORK))) { > init_task_work(&mnt->mnt_rcu, __cleanup_mnt); > if (!task_work_add(task, &mnt->mnt_rcu, TWA_RESUME)) > return; Now, *that* is something I have much stronger objections to. Stuck filesystem shutdown is far more likely than stuck ->release(). You are seriously asking for trouble here. Why would you want to have nfsd block on that?