Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1162409ybj; Tue, 5 May 2020 14:26:06 -0700 (PDT) X-Google-Smtp-Source: APiQypLOE9QX/zV9jd7MC4hqOxNWWCqG1TxxpHzbp0gmch03cf9oGrpelI190iDg6sjetLJI6d+n X-Received: by 2002:a17:906:2458:: with SMTP id a24mr4501318ejb.239.1588713966411; Tue, 05 May 2020 14:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588713966; cv=none; d=google.com; s=arc-20160816; b=iutd0oKHKYoHv09dVGNHRAbrDDY3PsgbEl99ue1smGN/ubSY98eNW04HTzks67Bvpz 7WUbb8OLWEuZLdL6IGz65gonfSOQ+hQufY+aFPay0XLd3/tCBo6AMyLf2V/d3MWYF7F8 UDlMCqtTD8sjvQzJTm0StUEd0dHixMi/Qv7Y4qBVl3w43hDADjGtp9ZWQ2JbPQaV7ZAZ Aub8srdEIhdgPcz3yarDA4/Mgyk4D4+3lMAfEe7MqjwHvb7GRMD+h6PHqFd+5JaI6H3E Qq3g1yWhbZYpIGFU5JdzglapICToedmtMWR4icvX6/ZKilEqdjg33PgYgZnQg4SYBneH pcfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Oo1Nu0x7My4bHZIL3EJw250MXGd1yQpQzp0qaFL34WU=; b=0P8tchtGoQd+dQ9oS7UsZxpoLZu9Fcjni1lDbgVk93DXQHZ3O1Bh/gaxx+VqtlAHws dbd6tsngsrYGgcbEHN+SVjy5lWFPPHQpQDPPGcUcskbprzqNLO1obT0mAKOAzZeTYFF4 qYed8Z9ABqrEJWjpPew8Ug4XRgClwDufDnn7LzhH7vX+Iy7mCmaMpoHt+XmNtS8AHw7K B+8LxrqJnh/CbrSVGqoMpy323KAJ2htsh2CKH2Phhs5mqn2HeGkzZn6df4tDCp56qXCQ HFi66Ti0us4bKEzWp0u9/OaTo6EIOkCgj/Sq9UG6w3eT0zHJbztn1ltAse6L47h3AkGW 19bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si1833464edv.557.2020.05.05.14.25.37; Tue, 05 May 2020 14:26:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728965AbgEEVZ2 (ORCPT + 99 others); Tue, 5 May 2020 17:25:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727785AbgEEVZ2 (ORCPT ); Tue, 5 May 2020 17:25:28 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00::f03c:91ff:fe50:41d6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4064C061A0F for ; Tue, 5 May 2020 14:25:27 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 0A4B7BDB; Tue, 5 May 2020 17:25:27 -0400 (EDT) Date: Tue, 5 May 2020 17:25:27 -0400 From: "J. Bruce Fields" To: Tejun Heo Cc: "J. Bruce Fields" , Linus Torvalds , "open list:NFS, SUNRPC, AND..." , Jeff Layton , David Howells , Shaohua Li , Oleg Nesterov , Linux Kernel Mailing List Subject: Re: [PATCH 0/4] allow multiple kthreadd's Message-ID: <20200505212527.GA1265@fieldses.org> References: <1588348912-24781-1-git-send-email-bfields@redhat.com> <20200501182154.GG5462@mtj.thefacebook.com> <20200505021514.GA43625@pick.fieldses.org> <20200505210118.GC27966@fieldses.org> <20200505210956.GA3350@mtj.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505210956.GA3350@mtj.thefacebook.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, May 05, 2020 at 05:09:56PM -0400, Tejun Heo wrote: > Hello, > > On Tue, May 05, 2020 at 05:01:18PM -0400, J. Bruce Fields wrote: > > On Mon, May 04, 2020 at 10:15:14PM -0400, J. Bruce Fields wrote: > > > Though now I'm feeling greedy: it would be nice to have both some kind > > > of global flag, *and* keep kthread->data pointing to svc_rqst (as that > > > would give me a simpler and quicker way to figure out which client is > > > conflicting). Could I take a flag bit in kthread->flags, maybe? > > > > Would something like this be too hacky?: > > It's not the end of the world but a bit hacky. I wonder whether something > like the following would work better for identifying worker type so that you > can do sth like > > if (kthread_fn(current) == nfsd) > return kthread_data(current); > else > return NULL; Yes, definitely more generic, looks good to me. --b. > > Thanks. > > diff --git a/kernel/kthread.c b/kernel/kthread.c > index bfbfa481be3a..4f3ab9f2c994 100644 > --- a/kernel/kthread.c > +++ b/kernel/kthread.c > @@ -46,6 +46,7 @@ struct kthread_create_info > struct kthread { > unsigned long flags; > unsigned int cpu; > + int (*threadfn)(void *); > void *data; > struct completion parked; > struct completion exited; > @@ -152,6 +153,13 @@ bool kthread_freezable_should_stop(bool *was_frozen) > } > EXPORT_SYMBOL_GPL(kthread_freezable_should_stop); > > +void *kthread_fn(struct task_struct *task) > +{ > + if (task->flags & PF_KTHREAD) > + return to_kthread(task)->threadfn; > + return NULL; > +} > + > /** > * kthread_data - return data value specified on kthread creation > * @task: kthread task in question > @@ -244,6 +252,7 @@ static int kthread(void *_create) > do_exit(-ENOMEM); > } > > + self->threadfn = threadfn; > self->data = data; > init_completion(&self->exited); > init_completion(&self->parked); > > -- > tejun