Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3857497rdh; Tue, 28 Nov 2023 05:54:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC/h4uSc1gpCyxmJhfaFTI54DRlwlTicoP7SLSJtB7/IJIvbIl96ChciFrN+OKZoFojtVp X-Received: by 2002:a05:6a20:e308:b0:18b:4e39:835 with SMTP id nb8-20020a056a20e30800b0018b4e390835mr15395637pzb.31.1701179666058; Tue, 28 Nov 2023 05:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701179666; cv=none; d=google.com; s=arc-20160816; b=YK3iilocqAPkg4/bPNRRHciVhemdwM7Dt2HMa+k3QnktODzhoqPTU9QTkDkC5PMWE8 Nt6wK/cbSlGQX9ydpx5mq4z1p3AH6V2rMhje+3Msau7TB8Ujoy0nqd2dr9fKLkZjbtTJ RJdb18NBRH0D5q3oYLannYaH5nuLfIPb+LC9beRKFM/IPy+xE8HiSrPNXFNEXJO5O36A u5DDLEuC5JQPez0F5WB6gjyrs5eMe4UcQORzSZsYVe1UUqNdsomlBWdE3lxZUGb1HeDV 3hiJPy7euiQ7+r6QRXSw3HqQrxxcacPEUihkolwpU6Mi+Q13trN4JXiQgHSOOZvJEE+r RXNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent: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=ww4tb37z+QtlEnTPZlBwHCJJj+TrIqx4ZMKlc8ERHeA=; fh=NgmM/LgFuVVs402r0XWmNkhLaO+SQ9eWQfwdU+YoZ/s=; b=YdqpcCwJU0gnJ1HDAGvBbboj1gPk3MrrL8OmR+xjF5vwjshHmkY7X9Tt3VqDBfZtQd c9XBGfZcsKvPagpLlOpiCmOKmOGD+xnEGB/Qr1wJTMi7+yjB6TJtg30/++OhGgTcAm7M EsmZ7S9H3ZX7/IOyiWbjgZteuQhDEUUcUBDMkkvS0wFOkA6iMDCsMGcKYmabouHDE4mQ JP2NptH4WYTZjH1W6+JGnwWwIZjr5K6fVYgxDIl/BqURy8eQAStebzrfVppN4wNK2teO XFhTJf0svSGlNNY8FtYT6bo6mHbtwfRf6ajxwDE7f98rLyhp5KFHPcLLJIqQZYJNhuXh Ftng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HJr9QfGm; spf=pass (google.com: domain of linux-nfs+bounces-126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p18-20020a634f52000000b005b5c68e2c92si12100178pgl.371.2023.11.28.05.54.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 05:54:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HJr9QfGm; spf=pass (google.com: domain of linux-nfs+bounces-126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9539FB20F7D for ; Tue, 28 Nov 2023 13:54:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A0A4199B2; Tue, 28 Nov 2023 13:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HJr9QfGm" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C75A85 for ; Tue, 28 Nov 2023 05:54:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701179654; 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=ww4tb37z+QtlEnTPZlBwHCJJj+TrIqx4ZMKlc8ERHeA=; b=HJr9QfGms9OBh8Lpf6symAyPPkLcKCfWtAbSSctZcr2BmCFSHM0tCUmmj4c7toSJR1EqUr LxnxlD0sVPe7HDJOvqXEfPh++WbnmKdsYIW0iTxXFUZqrBA97RVNcMtmEnj8ZSxgs772PU 0kvT7FEgQ69IuQiLakamvbaYDu5PkWg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-lwrmL7D6NWaWrcZVqNIhYw-1; Tue, 28 Nov 2023 08:54:08 -0500 X-MC-Unique: lwrmL7D6NWaWrcZVqNIhYw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD511811E8F; Tue, 28 Nov 2023 13:54:07 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.14]) by smtp.corp.redhat.com (Postfix) with SMTP id A0B4E1C060AE; Tue, 28 Nov 2023 13:54:04 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 28 Nov 2023 14:53:02 +0100 (CET) Date: Tue, 28 Nov 2023 14:52:59 +0100 From: Oleg Nesterov To: Christian Brauner Cc: NeilBrown , Al Viro , Jens Axboe , 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: <20231128135258.GB22743@redhat.com> References: <170112272125.7109.6245462722883333440@noble.neil.brown.name> <20231128-arsch-halbieren-b2a95645de53@brauner> 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: <20231128-arsch-halbieren-b2a95645de53@brauner> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 On 11/28, Christian Brauner wrote: > > Should be simpler if you invert the logic? > > COMPLETELY UNTESTED Agreed, this looks much better to me. But perhaps we can just add the new PF_KTHREAD_XXX flag and change fput --- a/fs/file_table.c +++ b/fs/file_table.c @@ -445,7 +445,8 @@ void fput(struct file *file) if (atomic_long_dec_and_test(&file->f_count)) { struct task_struct *task = current; - if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) { + if (likely(!in_interrupt() && + task->flags & (PF_KTHREAD|PF_KTHREAD_XXX) != PF_KTHREAD) { init_task_work(&file->f_rcuhead, ____fput); if (!task_work_add(task, &file->f_rcuhead, TWA_RESUME)) return; ? Then nfsd() can simply set PF_KTHREAD_XXX. This looks even simpler to me. Oleg.