From: Eric Dumazet Date: Thu, 18 Mar 2010 11:27:25 +0000 (+0000) Subject: net: dev_getfirstbyhwtype() optimization X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=99fe3c391d50d381687fd84ed0ab22d57079e41f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git net: dev_getfirstbyhwtype() optimization Use RCU to avoid RTNL use in dev_getfirstbyhwtype() Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/core/dev.c b/net/core/dev.c index 2d01f18f303a..a03aab45e84f 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);