Skip to contentSkip to conversation

netlink: call cond_resched after broadcasting updates

PATCH In review Stephen Hemminger 2 participants 2 messages Dec 27, 2014 – Dec 31, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netlink: call cond_resched after broadcasting updates

When a netlink event is posted to a socket, the receiving process maybe waiting to wakeup. Reduce the latency by calling cond_resched() in this loop. This reduces the problems with missed events during a netlink storm such as when a routing daemon does mass update in response to a link transition.

net/netlink/af_netlink.c +3 -1
@@ -1983,8 +1983,10 @@ int netlink_broadcast_filtered(struct so
 
 	netlink_lock_table();
 
-	sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list)
+	sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list) {
 		do_one_broadcast(sk, &info);
+		cond_resched();
+	}
 
 	consume_skb(skb);
 
maintainer
#1 lore raw

From: Stephen Hemminger <[email protected]>
Date: Sat, 27 Dec 2014 09:54:33 -0800

Quoted 7 lines

When a netlink event is posted to a socket, the receiving process maybe waiting to wakeup. Reduce the latency by calling cond_resched() in this loop. This reduces the problems with missed events during a netlink storm such as when a routing daemon does mass update in response to a link transition.

As mentioned by others, this is potentially invoked from software interrupts generating netlink events (one example is ipv6) so we can't try to conditionally sleep here.