[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200505212527.GA1265@fieldses.org>
Date: Tue, 5 May 2020 17:25:27 -0400
From: "J. Bruce Fields" <bfields@...ldses.org>
To: Tejun Heo <tj@...nel.org>
Cc: "J. Bruce Fields" <bfields@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"open list:NFS, SUNRPC, AND..." <linux-nfs@...r.kernel.org>,
Jeff Layton <jlayton@...hat.com>,
David Howells <dhowells@...hat.com>, Shaohua Li <shli@...com>,
Oleg Nesterov <oleg@...hat.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 0/4] allow multiple kthreadd's
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
Powered by blists - more mailing lists