net: Don't take rtnl_lock() in wireless_nlevent_flush()
authorKirill Tkhai <ktkhai@virtuozzo.com>
Thu, 29 Mar 2018 16:20:44 +0000 (19:20 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Mar 2018 17:47:53 +0000 (13:47 -0400)
This function iterates over net_namespace_list and flushes
the queue for every of them. What does this rtnl_lock()
protects?! Since we may add skbs to net::wext_nlevents
without rtnl_lock(), it does not protects us about queuers.

It guarantees, two threads can't flush the queue in parallel,
that can change the order, but since skb can be queued
in any order, it doesn't matter, how many threads do this
in parallel. In case of several threads, this will be even
faster.

So, we can remove rtnl_lock() here, as it was used for
iteration over net_namespace_list only.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/wireless/wext-core.c

index 544d7b62d7ca9500df62a6a7a55eabfa674e6520..5e677dac2a0ceaa94b6f2d1548133b0fc33da8dc 100644 (file)
@@ -347,8 +347,6 @@ void wireless_nlevent_flush(void)
        struct sk_buff *skb;
        struct net *net;
 
-       ASSERT_RTNL();
-
        down_read(&net_rwsem);
        for_each_net(net) {
                while ((skb = skb_dequeue(&net->wext_nlevents)))
@@ -412,9 +410,7 @@ subsys_initcall(wireless_nlevent_init);
 /* Process events generated by the wireless layer or the driver. */
 static void wireless_nlevent_process(struct work_struct *work)
 {
-       rtnl_lock();
        wireless_nlevent_flush();
-       rtnl_unlock();
 }
 
 static DECLARE_WORK(wireless_nlevent_work, wireless_nlevent_process);