Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3444742rdh; Mon, 27 Nov 2023 14:43:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWkmUNEpNaetv+TsAeDm+kXCtYJW0r/qfT5n4NzPpdzzcdeDfyDEOBxStEH5FPK2OgherD X-Received: by 2002:a05:6358:3423:b0:16b:f6ba:a03a with SMTP id h35-20020a056358342300b0016bf6baa03amr15002450rwd.8.1701125034980; Mon, 27 Nov 2023 14:43:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701125034; cv=none; d=google.com; s=arc-20160816; b=uTxRYtT/we8U6FmcxJETg5gXS2k2Xs09VrIDHaAEf7UbLOypNky41XGjFNJNujkHAV nzTGVH9Q3gmkAbDe3UZy7DdcGvXSscsfhOgKGr/+dcD8+WcyRcXYd9rtm1ePvAr1T3p5 L+uVEtmk/U0laO1F8kkSSTSGAomK7noQdUHv5HEmqGQwrQKN437muErMQGRRx1LaPGAR lXfw58cMc+2IyAJNCTGa93nh4Zz1YQaTpHSfLXUDbhfFc9xWei5i/8UQvV6LvSvFWk0x 6cKTaFt8N2czq9xSpaBD59x6nuZdSG5y0GRLzYEi1oiJZEHjfrOVSg6w9FIQcBzakLuj uNwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:references:in-reply-to:subject:cc:to:from :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding; bh=9fMID4iFGZ/QvvRcv6L8PViRFU2fUpLdSwVJy5CrtKA=; fh=PEMm0VUakudpIGIXS8yNTb3Ygqmh7Zy4em9FkJGCG8E=; b=Irpo8kMNMXP1XMv2cdhXILpasxRksoALs+sQC8GKRa2rPzT2weqRV/fCzsmQ6oIdEW DL9UxhruBo/sMmRtI/ciwZ8Gt40UYihwLnWrUSgH9MfXPfB0S/JA8R/me3jBULMfGzOa EfD6biEwZ/JTrgv7YVGcretln2Y5J2VljW0/V7EzPAIAvcMgLVRE5vVnKblVG96kfiqZ DRvXkbbMsTcgmbAn/LvZt2GLMPi/i7/de2+twpqb+VSTe5UNSw/VjJm46oBnq+CovoZ1 rRFFqUpgS7EiDubaP4KZ7erRlUfWENvY/L2fgHrAsFgyV4X8ffWUu0xJ3mK48sc5C4aB rfrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-114-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id cc24-20020a05622a411800b004238dba4d6fsi10363225qtb.554.2023.11.27.14.43.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:43:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-114-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; spf=pass (google.com: domain of linux-nfs+bounces-114-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 B5FA31C209AA for ; Mon, 27 Nov 2023 22:43:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 713F7487A6; Mon, 27 Nov 2023 22:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5540137; Mon, 27 Nov 2023 14:43:43 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2996021923; Mon, 27 Nov 2023 22:43:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A69051379A; Mon, 27 Nov 2023 22:43:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id NT+lFZkbZWXsRAAAD6G6ig (envelope-from ); Mon, 27 Nov 2023 22:43:37 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "NeilBrown" To: "Al Viro" 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. In-reply-to: <20231127223054.GL38156@ZenIV> References: <170112272125.7109.6245462722883333440@noble.neil.brown.name>, <20231127223054.GL38156@ZenIV> Date: Tue, 28 Nov 2023 09:43:30 +1100 Message-id: <170112501017.7109.11367576354770728388@noble.neil.brown.name> X-Spamd-Bar: ++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.de (policy=none); spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of neilb@suse.de) smtp.mailfrom=neilb@suse.de X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [6.66 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(4.60)[~all:c]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[16.34%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.13)[-0.134]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWELVE(0.00)[13]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[suse.de : No valid SPF, No valid DKIM,none] X-Spam-Score: 6.66 X-Rspamd-Queue-Id: 2996021923 On Tue, 28 Nov 2023, Al Viro wrote: > On Tue, Nov 28, 2023 at 09:05:21AM +1100, NeilBrown wrote: >=20 > > 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. > >=20 > > 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. >=20 > > svc_recv(rqstp); > > validate_process_creds(); > > + if (task_work_pending(current)) > > + task_work_run(); >=20 > What locking environment and call chain do you have here? And what happens= if > you get something stuck in ->release()? No locking. This is in the top level function of the kthread. A ->release function that waits for an NFS filesystem to flush out data through a filesystem exported by this nfsd might hit problems. But that really requires us nfs-exporting and nfs filesystem which is loop-back mounted. While we do support nfs-reexport and nfs-loop-back mounts, I don't think we make any pretence of supporting a combination. Is that the sort of thing you were think of? >=20 > > =20 > > p->pdeath_signal =3D 0; > > - p->task_works =3D NULL; > > + p->task_works =3D args->kthread ? TASK_WORKS_DISABLED : NULL; >=20 > 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... >=20 I hadn't tried to understand what work_exited was for - but now I see that its purpose is precisely to block further work from being queued - exactly what I need. Thanks - I make that change for a v2. I've realised that I'll also need to change the flush_delayed_fput() in fsd_file_close_inode_sync() to task_work_run(). Thanks, NeilBrown