netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch: Make linkwatch more robust against rtnl holders
@ 2004-02-15 14:11 Stefan Rompf
  2004-02-19  1:11 ` David S. Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Rompf @ 2004-02-15 14:11 UTC (permalink / raw)
  To: netdev; +Cc: davem

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

Hi David,

the attached patch updates the linkwatch code so that it backs off and retries 
whenever it cannot get the rtnl semaphore.

This makes it more robust against unrelated processes calling 
flush_scheduled_work() while holding the rtnl lock. This problem was reported 
on netdev for the sungem driver.

I preferred rescheduling every 1/10 second against creating a kernel thread as 
the code is shorter, and the situation should not happen anyway.

Stefan

[-- Attachment #2: patch-linkwatch-2.6.1 --]
[-- Type: text/x-diff, Size: 737 bytes --]

--- net/core/link_watch.c.old	2003-12-26 20:38:25.000000000 +0100
+++ net/core/link_watch.c	2004-01-30 20:07:57.000000000 +0100
@@ -84,6 +84,8 @@
 
 static void linkwatch_event(void *dummy)
 {
+	if (rtnl_shlock_nowait()) goto out_err1;
+	if (rtnl_exlock_nowait()) goto out_err2;
 	/* Limit the number of linkwatch events to one
 	 * per second so that a runaway driver does not
 	 * cause a storm of messages on the netlink
@@ -92,11 +94,16 @@
 	linkwatch_nextevent = jiffies + HZ;
 	clear_bit(LW_RUNNING, &linkwatch_flags);
 
-	rtnl_shlock();
-	rtnl_exlock();
 	linkwatch_run_queue();
 	rtnl_exunlock();
 	rtnl_shunlock();
+
+	return;
+
+out_err2:
+	rtnl_shunlock();
+out_err1:
+	schedule_delayed_work(&linkwatch_work, HZ / 10);
 }
 
 

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

end of thread, other threads:[~2004-02-20 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-15 14:11 Patch: Make linkwatch more robust against rtnl holders Stefan Rompf
2004-02-19  1:11 ` David S. Miller
2004-02-19  1:18   ` Jeff Garzik
2004-02-20 16:44   ` Stefan Rompf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).