netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dev_getfirstbyhwtype() optimization
@ 2010-03-18 21:27 Eric Dumazet
  2010-03-18 21:54 ` Laurent Chavey
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Eric Dumazet @ 2010-03-18 21:27 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Use RCU to avoid RTNL use in dev_getfirstbyhwtype()

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
diff --git a/net/core/dev.c b/net/core/dev.c
index 17b1686..0f2e9fc 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -772,14 +772,17 @@ EXPORT_SYMBOL(__dev_getfirstbyhwtype);
 
 struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
 {
-	struct net_device *dev;
+	struct net_device *dev, *ret = NULL;
 
-	rtnl_lock();
-	dev = __dev_getfirstbyhwtype(net, type);
-	if (dev)
-		dev_hold(dev);
-	rtnl_unlock();
-	return dev;
+	rcu_read_lock();
+	for_each_netdev_rcu(net, dev)
+		if (dev->type == type) {
+			dev_hold(dev);
+			ret = dev;
+			break;
+		}
+	rcu_read_unlock();
+	return ret;
 }
 EXPORT_SYMBOL(dev_getfirstbyhwtype);
 



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

end of thread, other threads:[~2010-03-22  3:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 21:27 [PATCH] net: dev_getfirstbyhwtype() optimization Eric Dumazet
2010-03-18 21:54 ` Laurent Chavey
2010-03-19  2:32 ` Paul E. McKenney
2010-03-19  5:14   ` Eric Dumazet
2010-03-19 11:54     ` Paul E. McKenney
2010-03-22  3:39 ` David Miller

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).