All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] panic during unregister_netdevice()
@ 2003-11-06 19:58 Krishna Kumar
  2003-11-06 19:59 ` David S. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Krishna Kumar @ 2003-11-06 19:58 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: davem, krkumar, netdev





Actually, even the original code looks good, and if that panic'd, the
following won't change
that (verified it also).

When unregister_netdev() is called by the driver, it first calls
unregister_netdevice() which
drops it's last ref to the dev, making it zero. unregister_netdev() then
calls rtnl_unlock() which
calls netdev_run_todo(), which calls netdev_wait_allrefs() and only after
that succeeds,
does the driver do a free_netdev(). So the dev should not be freed while
the wait_ref() is
executing, and the original code looks correct.

I don't know if it is some corruption on my system, some hardware problem ?
I will look
some more, also try to get a different machine.

- KK




|---------+---------------------------->
|         |           Stephen Hemminger|
|         |           <shemminger@osdl.|
|         |           org>             |
|         |           Sent by:         |
|         |           netdev-bounce@oss|
|         |           .sgi.com         |
|         |                            |
|         |                            |
|         |           11/05/2003 05:09 |
|         |           PM               |
|         |                            |
|---------+---------------------------->
  >-----------------------------------------------------------------------------------------------------------------|
  |                                                                                                                 |
  |       To:       Krishna Kumar/Beaverton/IBM@IBMUS                                                               |
  |       cc:       davem@redhat.com, krkumar@us.ltcfwd.linux.ibm.com, netdev@oss.sgi.com                           |
  |       Subject:  Re: [PATCH] panic during unregister_netdevice()                                                 |
  |                                                                                                                 |
  >-----------------------------------------------------------------------------------------------------------------|




Try this. Instead of dropping the last reference in unregister, it does it
after all other references are gone (sort of like the old 2.4 code).

diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c           Wed Nov  5 17:04:57 2003
+++ b/net/core/dev.c           Wed Nov  5 17:04:57 2003
@@ -2743,7 +2743,7 @@
             unsigned long rebroadcast_time, warning_time;

             rebroadcast_time = warning_time = jiffies;
-            while (atomic_read(&dev->refcnt) != 0) {
+            while (atomic_read(&dev->refcnt) > 1) {
                         if (time_after(jiffies, rebroadcast_time + 1 *
HZ)) {
                                     rtnl_shlock();
                                     rtnl_exlock();
@@ -2838,6 +2838,7 @@
                                     dev->reg_state = NETREG_UNREGISTERED;

                                     netdev_wait_allrefs(dev);
+                                    dev_put(dev);

                                     /* paranoia */
                                     BUG_ON(atomic_read(&dev->refcnt));
@@ -2974,7 +2975,6 @@
             /* Finish processing unregister after unlock */
             net_set_todo(dev);

-            dev_put(dev);
             return 0;
 }

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH] Bugs in xfrm
@ 2004-01-10 18:33 Krishna Kumar
  2004-01-10 20:11 ` David S. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Krishna Kumar @ 2004-01-10 18:33 UTC (permalink / raw)
  To: David S. Miller; +Cc: krkumar, netdev

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]





> Explain to me how that won't loop forever if given a non-NULL dst?

Oops, forgot the dst = next in the loop :-)

> Next, this dst_bundle_free() thing is totally not needed as far as I can
> tell.  When dst_free() is made, the top-level of the bundle's dst gets
added
> to the garbage collection list, the garbage collection properly walks the
> children to process the whole bundle.

The garbage collector (called via __dst_free) takes dst_garbage_list and
goes through the dst->next pointer. But dst_destroy() seems to destroy
stuff
on the dst->child list (I missed the part that the first dst has a refcnt
of
zero and all others on child have refcnt of 1). So this is not needed.

> Please redo this patch and please test it this time :)

Are the other "bugs" correct :-) Or should I send separate patches this
time ?

thanks,

- KK

[-- Attachment #2: Type: text/html, Size: 1338 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-01-10 20:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-06 19:58 [PATCH] panic during unregister_netdevice() Krishna Kumar
2003-11-06 19:59 ` David S. Miller
2003-11-06 21:07   ` Krishna Kumar
2003-11-06 21:14     ` David S. Miller
2003-11-07 19:01   ` [PATCH] Hang in downing interface with IPv6 PRIVACY Krishna Kumar
2003-11-09  6:30     ` David S. Miller
2004-01-10  1:40       ` [PATCH] Bugs in xfrm Krishna Kumar
2004-01-10  4:48         ` David S. Miller
2004-01-10 18:33 Krishna Kumar
2004-01-10 20:11 ` David S. Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.