Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1150818ybj; Tue, 5 May 2020 14:10:34 -0700 (PDT) X-Google-Smtp-Source: APiQypJjyn047bAGG8QHvfiBSzAdwe37ktg4LsN6Zt6PYwdmHbyXIG69uHIlkQ0/eTU6IDT/iiJf X-Received: by 2002:a17:906:3c8:: with SMTP id c8mr4649197eja.66.1588713034605; Tue, 05 May 2020 14:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588713034; cv=none; d=google.com; s=arc-20160816; b=ncL5XD2UnNW+EHbhotdQ6H5iAS/PRRyuplUe1vY/DEBM29/GU7VEH45qB0bAfhx6Js VjawUZUcEHQEYl/ErqNrZZWysd3B8JY50h6BVLh29ZFeW4bGEMdRqAGqQgCJcZM9HGbU iyDDSKx0Pa3wp6M+t9vqlvuaUD1cAIQHF7WDECsfbPNca7M8R5MjXW7boPzt6xulRI0g df0FnC+3QtXo5pmhYLDMsuWlFGJC/NPcTikUqvAshVjJvENeP0nH+jIsYjlFgZrOUYMI tLElbQmrSgixkVcfKYkbUrpJXY0IGRI0opwGemhQHmXOukmIA1y5FfZpabgMz+KHBhrU gADg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gxAlApzzt5Fr2H0K0z2Ers4SPsXxQpIbe0gDV+IiJdk=; b=rAD/T7Gi3gq0BrUoh8zbFPbnK3LCcNM9j5Htf+Y3QX4sqxNDGErVhBfud7jLjSj6TA nIPK8cahi0rMFtjQ3AVq4aDtVXzGYkwSe1huAGFRTH/bDeBBhieB+6pRZLbsyX3b1iSO SMQbIyjjuI7GY1Wiy8fZC+rlUvfIvW9e1JCEeLbx2GycLecE5aa9UgjbMrTj9qSgDlhz nUDD3kmtNLqD7/LtV+kUj+9KN9AerCUs6OQHkN/lEujxsPl73AqQFnRQpQvXwDZfT7gE PG9FGonkT7YlDvSQpHZXxwYBoiljsrIcz7PDtb15+L54Ko0b9Ef1BmCKY6w1wUNK9ljR yQBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZlG07WlU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw22si1889996edb.418.2020.05.05.14.10.08; Tue, 05 May 2020 14:10:34 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZlG07WlU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729096AbgEEVKB (ORCPT + 99 others); Tue, 5 May 2020 17:10:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728135AbgEEVKB (ORCPT ); Tue, 5 May 2020 17:10:01 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888BDC061A0F; Tue, 5 May 2020 14:09:59 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id ck5so1788275qvb.11; Tue, 05 May 2020 14:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gxAlApzzt5Fr2H0K0z2Ers4SPsXxQpIbe0gDV+IiJdk=; b=ZlG07WlUkAyur6dQ7aip9K3opgyw/I5mnWql1zI3HeSEU7nbUhBt2lsaZGx3VMayp2 xzo83Oj5Jh1zKx0mQyCEN8VYFFajXjc+hf+8KPdeCMnfe9Z7xpsBzd4JJwcakBInOPVZ 9Z1gMFw+OtfuB/7gbwJRxua5SlKm2nKvUuwM4Dm+H2WfxUBZZd9Rr/8NCgRxUgTiSNyM dkopESb2AeeDUZ2C3UzJ7x9j2LCbDIxd1yzgtCWLL35jLo7sgkyMKtyIhn7j16evOKbo kY7GM9DNyd586Cg2Ge9xHqaKxkVfVb7YNP+L3fM5IpykrP7IXbMGMJHrl9r13TnWzi07 RTAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=gxAlApzzt5Fr2H0K0z2Ers4SPsXxQpIbe0gDV+IiJdk=; b=D4xU3Ts0yHU2lgdPM+Tv9+5WXc/DSFp4Gr3DqjAUJWQSgLDc9/Si1fM4mEuCfRpUOv uXfchdBl5RnfdscI6OlwZRUVXpktfJ0pLtK1It00AbdKQx6gAktw16aumAkg8DxzcB+7 ZM9S5Mzp01QlZD30VzM+NM0AFyOLsBJq7sytGhcwbK/gl3t/P1iBTC/T06XdHWHCvct5 e2HXM3GQHbQMghioAh84yqFmw5PZK6eC4VtkmlIspPhJSmAywa9YV0EJQ7HSJogx2mPO ILuq3B2ZvMc2M3xx0DaLtPW1Ps4JklHnbBiune0C0t8o3NQ1iX4XEYiY8HIK6k5W4yGU CLvA== X-Gm-Message-State: AGi0Pual3tSta5p3RRpBSwWTzrg679gnV3qtl3kVZjeqlavb+GLGhN+4 NXDjA4jB3cGxAZC4C6dL6NUcT0MEkqI= X-Received: by 2002:ad4:4f86:: with SMTP id em6mr4980156qvb.218.1588712998509; Tue, 05 May 2020 14:09:58 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:8365]) by smtp.gmail.com with ESMTPSA id i42sm3059938qtc.83.2020.05.05.14.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 14:09:57 -0700 (PDT) Date: Tue, 5 May 2020 17:09:56 -0400 From: Tejun Heo To: "J. Bruce Fields" 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: <20200505210956.GA3350@mtj.thefacebook.com> References: <1588348912-24781-1-git-send-email-bfields@redhat.com> <20200501182154.GG5462@mtj.thefacebook.com> <20200505021514.GA43625@pick.fieldses.org> <20200505210118.GC27966@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505210118.GC27966@fieldses.org> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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; 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