mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
net: Introduce for_each_netdev_rcu() iterator
Adds RCU management to the list of netdevices. Convert some for_each_netdev() users to RCU version, if it can avoid read_lock-ing dev_base_lock Ie: read_lock(&dev_base_loack); for_each_netdev(net, dev) some_action(); read_unlock(&dev_base_lock); becomes : rcu_read_lock(); for_each_netdev_rcu(net, dev) some_action(); rcu_read_unlock(); Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
d0075634cf
commit
c6d14c8456
11 changed files with 68 additions and 77 deletions
|
|
@ -600,13 +600,13 @@ struct net_device *rose_dev_first(void)
|
|||
{
|
||||
struct net_device *dev, *first = NULL;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(&init_net, dev) {
|
||||
rcu_read_lock();
|
||||
for_each_netdev_rcu(&init_net, dev) {
|
||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE)
|
||||
if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
|
||||
first = dev;
|
||||
}
|
||||
read_unlock(&dev_base_lock);
|
||||
rcu_read_unlock();
|
||||
|
||||
return first;
|
||||
}
|
||||
|
|
@ -618,8 +618,8 @@ struct net_device *rose_dev_get(rose_address *addr)
|
|||
{
|
||||
struct net_device *dev;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(&init_net, dev) {
|
||||
rcu_read_lock();
|
||||
for_each_netdev_rcu(&init_net, dev) {
|
||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
|
||||
dev_hold(dev);
|
||||
goto out;
|
||||
|
|
@ -627,7 +627,7 @@ struct net_device *rose_dev_get(rose_address *addr)
|
|||
}
|
||||
dev = NULL;
|
||||
out:
|
||||
read_unlock(&dev_base_lock);
|
||||
rcu_read_unlock();
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
|
@ -635,14 +635,14 @@ static int rose_dev_exists(rose_address *addr)
|
|||
{
|
||||
struct net_device *dev;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(&init_net, dev) {
|
||||
rcu_read_lock();
|
||||
for_each_netdev_rcu(&init_net, dev) {
|
||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)
|
||||
goto out;
|
||||
}
|
||||
dev = NULL;
|
||||
out:
|
||||
read_unlock(&dev_base_lock);
|
||||
rcu_read_unlock();
|
||||
return dev != NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue