Re: circular locking, mirred, 2.6.24.2

jamal
2008-03-06T20:48:47Z

On Thu, 2008-06-03 at 18:56 +0100, Jarek Poplawski wrote:

> Every netdevice after register_netdevice() has its queue_lock and
> ingress_lock initialized with the same static lock_class_keys, so unless
> changed later, these locks are treated by lockdep as 2 global locks.
> So, taking such locks with different order should be reported.

ok.

> This really
> happens in act_mirred, and I don't know yet, why this wasn't reported
> earlier.

Look closely at those traces again ;-> there are *three* different
netdevices involved, one (loopback) seems to be _totaly_ unrelated.
Tracing of those locks just seems confused - perhaps the pernet stuff is
confusing loopback?

> Of course, if there are two different devices this could be safe, but
> not always (e.g. thread1 has dev_eth0->ingress_lock and wants
> dev_eth1->queue_lock, thread2 has dev_eth1->ingress_lock, wants
> dev_eth0->qdisc_lock, and thread3 has dev_eth0->qdisc_lock and wants
> dev_eth0->ingress_lock). With ifb this shouldn't be the case, but
> anyway we have to tell lockdep that ifb uses a different pair of locks.

thread3 can not happen because we dont allow it (the other 2 are not
contentious).
There are cases where redirecting will cause you problems (example if
you redirected to yourself and cause an infinite redirect) which are
listed in iproute2/doc. Denys script is fine afaics.