Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3438390rdh; Mon, 27 Nov 2023 14:31:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUq418UXJkZX/ybWwrCbMALs6uFPMYEJ81ut3QF09oHQ61EwtcAkgms+mXK0qodA3r9EC2 X-Received: by 2002:ad4:4043:0:b0:67a:2384:f28b with SMTP id r3-20020ad44043000000b0067a2384f28bmr11808081qvp.60.1701124277511; Mon, 27 Nov 2023 14:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701124277; cv=none; d=google.com; s=arc-20160816; b=YEtdP6TPTGpNUf4WBPdWJjXoc84VN7yPEYE1e3GituBWLJi+06/PlqMcdblcPLmuEv bnXVHS3YaDpWVAiusAFSzvRewt9bwGoJy9Lb+InF8cKbSLWtpHFpxZ8B6IdfMcTmaynJ Cy/HVRMygOpMxK9wgJGsQ6uuBLfIQWgyfXEdju1QKZL/scFOdcMSZPGbNan1K7rrtaPB X4ribPl7MewnDvFavUq8L2+RIHCpNv+2cAvz+Dp7WvXcsQvbzeWHZ6y2G6oLCdQdKk/7 mtDScf7oWKtLG+OjxgVaM1f8A4TvxDOHQQjFfFBjz7AkVOH0qY4rcwyB8qnBm7yfK3VZ cPuw== 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=3PzatJTAFuI9AA1q1PyzjD6sj+4//yZnqVg5MvBFhPA=; fh=jjaZDJ/Hn1/vk73fwBZ/tCAZ2tk5BFbAmmN/VKCBpKo=; b=QZk8PxEyYfKrk3U335mA2sa9R7G3ob4iInAtPNCOeqZMPrQa9IqBR4hbPWFRSvpv9U YAKyY+CSVNTBUbJnVO9WiOlfkV4Qe/s/GII/kkR83lystB0MqOGsEPOyFma6coRscao6 Jq8kDKgYyg7VGXpcF0CI77852VeG13d1W+Nc/a4EdDfy8M8Pqhyk5ZY7i+efKFgMiQv7 Pixc1qYPACmjSnaKxjLcWNGtUNo68oQUuLFL787pyvQjA/wvvZgHuAWWYzEgdB4ttjw0 2qbWRVq3rFfNKpLBBUvSQkJx3i2NahiCM5kivs0Mw09ITJHLG2o19VbtVhGNY7dyb2ml +qhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=Ki96iRt+; spf=pass (google.com: domain of linux-nfs+bounces-113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-113-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 ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q1-20020ad45741000000b0067a4bb0693fsi2093340qvx.285.2023.11.27.14.31.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=Ki96iRt+; spf=pass (google.com: domain of linux-nfs+bounces-113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-113-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 485CA1C20B14 for ; Mon, 27 Nov 2023 22:31:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 042BF48CDB; Mon, 27 Nov 2023 22:31:15 +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="Ki96iRt+" 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 6B287EA; Mon, 27 Nov 2023 14:31:07 -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=3PzatJTAFuI9AA1q1PyzjD6sj+4//yZnqVg5MvBFhPA=; b=Ki96iRt+2k9IAxyOJxJ69225dH 3s3CGMlrXW/53HNxRWoBDzzXcnGWu5Ff4/gLdtkaJtQinjTzDpWqihWFUR25cxJRqFS+0UQluG7SR 0S52ZJhREva+EtvoYVhP/jbOuuWKnTXsj5HEhwqtCNpmLpxgQ1c4L9pqHYrBvzspDphzrZAmK8luR OFJVf0yBF0Bxj4qrXQ1GwEUWhW4fXKlxwc0MmJNGS/BBJTCff5TPyNdLFolh5sGo0U2MTz5EgwxO6 ZAI6uCvgmRosdhvpHCxf3munWLk4SEXl86W/ambCxIHb40BdfE1S7tzfNLE45+EJOsR9z7+M7wEKm u1k/McjA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r7k7y-004Ai6-2j; Mon, 27 Nov 2023 22:30:54 +0000 Date: Mon, 27 Nov 2023 22:30:54 +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/RFC] core/nfsd: allow kernel threads to use task_work. Message-ID: <20231127223054.GL38156@ZenIV> References: <170112272125.7109.6245462722883333440@noble.neil.brown.name> 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: <170112272125.7109.6245462722883333440@noble.neil.brown.name> Sender: Al Viro On Tue, Nov 28, 2023 at 09:05:21AM +1100, NeilBrown wrote: > A simple way to fix this is to treat nfsd threads like normal processes > for task_work. Thus the pending files are queued for the thread, and > the same thread finishes the work. > > Currently KTHREADs are assumed never to call task_work_run(). With this > patch that it still the default but it is implemented by storing the > magic value TASK_WORKS_DISABLED in ->task_works. If a kthread, such as > nfsd, will call task_work_run() periodically, it sets ->task_works > to NULL to indicate this. > svc_recv(rqstp); > validate_process_creds(); > + if (task_work_pending(current)) > + task_work_run(); What locking environment and call chain do you have here? And what happens if you get something stuck in ->release()? > > p->pdeath_signal = 0; > - p->task_works = NULL; > + p->task_works = args->kthread ? TASK_WORKS_DISABLED : NULL; Umm... why not have them set (by helper in kernel/task_work.c) to &work_exited? Then the task_work_run parts wouldn't be needed at all...