mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
net: dont hold rtnl mutex during netlink dump callbacks
Four years ago, Patrick made a change to hold rtnl mutex during netlink dump callbacks. I believe it was a wrong move. This slows down concurrent dumps, making good old /proc/net/ files faster than rtnetlink in some situations. This occurred to me because one "ip link show dev ..." was _very_ slow on a workload adding/removing network devices in background. All dump callbacks are able to use RCU locking now, so this patch does roughly a revert of commits :1c2d670f36
: [RTNETLINK]: Hold rtnl_mutex during netlink dump callbacks6313c1e099
: [RTNETLINK]: Remove unnecessary locking in dump callbacks This let writers fight for rtnl mutex and readers going full speed. It also takes care of phonet : phonet_route_get() is now called from rcu read section. I renamed it to phonet_route_get_rcu() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Patrick McHardy <kaber@trash.net> Cc: Remi Denis-Courmont <remi.denis-courmont@nokia.com> Acked-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
dcfd9cdc12
commit
e67f88dd12
8 changed files with 25 additions and 23 deletions
|
@ -1007,10 +1007,11 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
|||
s_h = cb->args[0];
|
||||
s_idx = cb->args[1];
|
||||
|
||||
rcu_read_lock();
|
||||
for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
|
||||
idx = 0;
|
||||
head = &net->dev_index_head[h];
|
||||
hlist_for_each_entry(dev, node, head, index_hlist) {
|
||||
hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
|
||||
if (idx < s_idx)
|
||||
goto cont;
|
||||
if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
|
||||
|
@ -1023,6 +1024,7 @@ cont:
|
|||
}
|
||||
}
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
cb->args[1] = idx;
|
||||
cb->args[0] = h;
|
||||
|
||||
|
@ -1879,7 +1881,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
int min_len;
|
||||
int family;
|
||||
int type;
|
||||
int err;
|
||||
|
||||
type = nlh->nlmsg_type;
|
||||
if (type > RTM_MAX)
|
||||
|
@ -1906,11 +1907,8 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
if (dumpit == NULL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
__rtnl_unlock();
|
||||
rtnl = net->rtnl;
|
||||
err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
|
||||
rtnl_lock();
|
||||
return err;
|
||||
return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
|
||||
}
|
||||
|
||||
memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
|
||||
|
@ -1980,7 +1978,7 @@ static int __net_init rtnetlink_net_init(struct net *net)
|
|||
{
|
||||
struct sock *sk;
|
||||
sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX,
|
||||
rtnetlink_rcv, &rtnl_mutex, THIS_MODULE);
|
||||
rtnetlink_rcv, NULL, THIS_MODULE);
|
||||
if (!sk)
|
||||
return -ENOMEM;
|
||||
net->rtnl = sk;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue