Re: "new style" netdevice allocation patch for TUN driver (2.4.18 kernel)

From: Maksim (Max) Krasnyanskiy (maxk@qualcomm.com)
Date: Tue Aug 06 2002 - 15:03:48 EST


> From: "Maksim (Max) Krasnyanskiy" <maxk@qualcomm.com>
> Date: Tue, 06 Aug 2002 10:07:49 -0700
>
> Dave, how about this
>
> --- net/core/dev.c.orig Mon Aug 5 21:48:54 2002
> +++ net/core/dev.c Mon Aug 5 21:54:01 2002
> @@ -2577,6 +2577,11 @@
>
>First, the call-chain notifiers are probably not safe
>to run without rtnl_lock held.
Good point.

>Second, why not just fix the bug instead of applying band-aids
>to device unregistry? I know it's nice in that it allows you
>to configure devices some more, but it doesn't make the real
>problem go away.
I completely agree. However sleeping and holding a lock that you
don't have to hold is a bug on it's own :).
Things like sockets drop the lock before calling schedule() and acquire
it on wakeup. I think we should do the same in unregister_netdevice().

How about this:

--- dev.c.orig Tue Aug 6 00:58:46 2002
+++ dev.c Tue Aug 6 01:00:00 2002
@@ -2584,9 +2584,12 @@
                         notifier_call_chain(&netdev_chain,
NETDEV_UNREGISTER, dev);
                 }

+ rtnl_unlock();
                 current->state = TASK_INTERRUPTIBLE;
                 schedule_timeout(HZ/4);
                 current->state = TASK_RUNNING;
+ rtnl_lock();
+
                 if ((jiffies - warning_time) > 10*HZ) {
                         printk(KERN_EMERG "unregister_netdevice: waiting
for %s to "
                                         "become free. Usage count = %d\n",
-----

Max

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



This archive was generated by hypermail 2b29 : Wed Aug 07 2002 - 22:00:33 EST