Commit cc429c8f authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: avoid cache line dirtying in ipv6_dev_get_saddr()

By extending the rcu section a bit, we can avoid these
very expensive in6_ifa_put()/in6_ifa_hold() calls
done in __ipv6_dev_get_saddr() and ipv6_dev_get_saddr()
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f59c031e
...@@ -1608,11 +1608,6 @@ static int __ipv6_dev_get_saddr(struct net *net, ...@@ -1608,11 +1608,6 @@ static int __ipv6_dev_get_saddr(struct net *net,
} }
break; break;
} else if (minihiscore < miniscore) { } else if (minihiscore < miniscore) {
if (hiscore->ifa)
in6_ifa_put(hiscore->ifa);
in6_ifa_hold(score->ifa);
swap(hiscore, score); swap(hiscore, score);
hiscore_idx = 1 - hiscore_idx; hiscore_idx = 1 - hiscore_idx;
...@@ -1660,6 +1655,7 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, ...@@ -1660,6 +1655,7 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
int dst_type; int dst_type;
bool use_oif_addr = false; bool use_oif_addr = false;
int hiscore_idx = 0; int hiscore_idx = 0;
int ret = 0;
dst_type = __ipv6_addr_type(daddr); dst_type = __ipv6_addr_type(daddr);
dst.addr = daddr; dst.addr = daddr;
...@@ -1735,15 +1731,14 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, ...@@ -1735,15 +1731,14 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
} }
out: out:
rcu_read_unlock();
hiscore = &scores[hiscore_idx]; hiscore = &scores[hiscore_idx];
if (!hiscore->ifa) if (!hiscore->ifa)
return -EADDRNOTAVAIL; ret = -EADDRNOTAVAIL;
else
*saddr = hiscore->ifa->addr;
*saddr = hiscore->ifa->addr; rcu_read_unlock();
in6_ifa_put(hiscore->ifa); return ret;
return 0;
} }
EXPORT_SYMBOL(ipv6_dev_get_saddr); EXPORT_SYMBOL(ipv6_dev_get_saddr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment