Re: [PATCH 8/8] fs/aio: Use rcu_work instead of explicit rcu and work item

From: Oleg Nesterov
Date: Wed Mar 21 2018 - 13:17:53 EST


On 03/21, Tejun Heo wrote:
>
> Hey, Oleg.
>
> On Wed, Mar 21, 2018 at 04:58:13PM +0100, Oleg Nesterov wrote:
> > > - struct rcu_head free_rcu;
> > > - struct work_struct free_work; /* see free_ioctx() */
> > > + struct rcu_work free_rwork; /* see free_ioctx() */
> >
> > IIUC, you can't easily share rcu_work's, thus every kioctx needs its own
> > ->free_rwork and this looks sub-optimal.
> >
> > What do you think about the (untested) patch below?
> >
> > Oleg.
> >
> >
> > --- a/fs/aio.c
> > +++ b/fs/aio.c
> > @@ -115,8 +115,10 @@ struct kioctx {
> > struct page **ring_pages;
> > long nr_pages;
> >
> > - struct rcu_head free_rcu;
> > - struct work_struct free_work; /* see free_ioctx() */
> > + union {
> > + struct rcu_head free_rcu;
> > + struct llist_node free_llist;
> > + };
>
> It really depends on how much we want to optimize. Do you think it
> matters enough?

I have no idea, probably not.

Mostly I am asking because I do not really understand
"[PATCH 6/8] RCU, workqueue: Implement rcu_work".

I mean, the code looks simple and correct but why does it play with
WORK_STRUCT_PENDING_BIT? IOW, I do not see a "good" use-case when 2 or more
queue_rcu_work()'s can use the same rwork and hit work_pending() == T. And
what the caller should do if queue_rcu_work() returns false?

Oleg.