Re: [PATCH 07/11] blkcg: make request_queue bypassing on allocation

From: Tejun Heo
Date: Fri Apr 13 2012 - 17:38:55 EST


On Fri, Apr 13, 2012 at 05:33:44PM -0400, Vivek Goyal wrote:
> On Fri, Apr 13, 2012 at 02:05:48PM -0700, Tejun Heo wrote:
> > On Fri, Apr 13, 2012 at 04:55:01PM -0400, Vivek Goyal wrote:
> > > But neither seems to be the case here. So to make sure that blkg_lookup()
> > > under rcu will see the updated value of queue flag (bypass), are we
> > > relying on the fact that caller should see the DEAD flag and not go
> > > ahead with blkg_lookup()? If yes, atleast it is not obivious.
> >
> > We're relying on the fact that it doesn't matter anymore because all
> > blkgs will be shoot down in queue cleanup path which goes through rcu
> > free, which is different from deactivating individual policies. It
> > indeed is subtle. Umm... this is starting to get ridiculous. Why the
> > hell was megaraid messing with so many queues anyways?
>
> Well, blkcg_deactivate_policy() frees the policy data in a non-rcu
> manner. So group is around but policy data is gone. So technically if some
> IO submitter does not see the queue bypass flag, he might still try to
> access blkg->pd[pol->plid] after being freed.

No, we always go through blkg_destroy_all() and each blkg along with
any attached policy_data will go through RCU grace period before
getting destroyed. It is stupid subtle but nevertheless correct.

> Having said that, in this case we are probably fine as blk_release_queue()
> is executed after last reference to queue is dropped and no more IO can
> come. May be a 2 line comment will help.

Yeah, we're guaranteed that by the time blk_release_queue() executes
nobody is traversing the queue. Hmmm... right, this is much easier to
wrap one's head around. I'll use this explanation in the comment.

> BTW, looks like blkio_exit_group_fn() probably is not a good name anymore
> as it is not even called when policy is being deactivated. It should
> probably be now .blkio_exit_policy_data_fn() or something like that.

Heh, I'm brewing mass blkcg API rename patch as we speak.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/