Subject: Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock().

From: Jarek Poplawski <[email-masked]>
Date: Tue, 19 Aug 2008 07:56:23 +0000

On Tue, Aug 19, 2008 at 05:46:06PM +1000, Herbert Xu wrote:
> On Tue, Aug 19, 2008 at 07:35:58AM +0000, Jarek Poplawski wrote:
> >
> > > If we're removing a non-root qdisc, then we will first grab the
> > > root qdisc's lock, kill the child, and release the root lock.  By
> > > convention, any user of a child qdisc must have acquired the root
> > > qdisc's lock because the child is only reachable through the root.
> > > Therefore once we have released the root qdisc lock after killing
> > > the child, we're guaranteed that no further references to that
> > > child can be made.
> > 
> > By convention, there was always this comment that destroy is under
> > sch_tree_lock(), so it was legal to depend on this. I'm not afraid
> > of somebody using such an under destroy qdisc - it's about a code
> > inside this qdisc could refer to not destroyed part.
> 
> No no no, it's not about qdisc_destroy at all.  If you're relying
> on the lock around qdisc_destroy, then you're already too late.
> The qdisc should have been removed before we get to qdisc_destroy.
> 
> It's the act of removal that's protected by the root lock, and
> still is.  For example, in htb_graft we do sch_tree_lock before
> killing any children, this is the lock that I was referring to.

I'm not sure I can understand you: could you look at htb_destroy()
instead and think of this as a child qdisc of prio or another htb?
Having a top level "queue" lock guarantees there is no activity at
the whole tree at the moment.

Thanks,
Jarek P.