Re: [PATCH 0/4] allow multiple kthreadd's
From: J. Bruce Fields
Date: Tue May 05 2020 - 12:23:56 EST
On Tue, May 05, 2020 at 11:54:05AM -0400, Tejun Heo wrote:
> Hello, Bruce.
>
> On Mon, May 04, 2020 at 10:15:14PM -0400, J. Bruce Fields wrote:
> > We're currently using it to pass the struct svc_rqst that a new nfsd
> > thread needs. But once the new thread has gotten that, I guess it could
> > set kthread->data to some global value that it uses to say "I'm a knfsd
> > thread"?
> >
> > I suppose that would work.
> >
> > 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?
>
> Hmm... that'd be solvable if kthread->data can point to a struct which does
> both things, right?
Isn't this some sort of chicken-and-egg problem?
If you don't know whether a given kthread is an nfsd thread or not, then
it's not safe to assume that kthread->data points to some nfsd-specific
structure that might tell you whether it's an nfsd thread.
> Because it doesn't have free() callback, it's a bit
> awkward but the threadfn itself can unlink and RCU-free it before returning.
It's only ever going to be referenced from the thread itself. This is
just a way to ask "am I running as an nfsd thread?" when we're deep
inside generic filesystem code somewhere. So I don't think there's any
complicated lifetime issues here.
--b.