Skip to contentSkip to conversation

icmp: No need to call sk_write_space()

PATCH Applied Eric Dumazet 2 participants 2 messages Sep 24, 2009 – Oct 5, 2009

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

PATCH 1/1 icmp: No need to call sk_write_space()

We can make icmp messages tx completion callback a litle bit faster.

Setting SOCK_USE_WRITE_QUEUE sk flag tells sock_wfree() to not call sk_write_space() on a socket we know no thread is posssibly waiting for write space. (on per cpu kernel internal icmp sockets only)

This avoids the sock_def_write_space() call and read_lock(&sk->sk_callback_lock)/read_unlock(&sk->sk_callback_lock) calls as well.

We avoid three atomic ops.

---

net/ipv4/icmp.c +4 -0
index 5bc13fe..84adb57 100644
@@ -1165,6 +1165,10 @@ static int __net_init icmp_sk_init(struct net *net)
 		sk->sk_sndbuf =
 			(2 * ((64 * 1024) + sizeof(struct sk_buff)));
 
+		/*
+		 * Speedup sock_wfree()
+		 */
+		sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
 		inet_sk(sk)->pmtudisc = IP_PMTUDISC_DONT;
 	}
 
maintainer Applied
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Fri, 25 Sep 2009 00:16:51 +0200

Quoted 6 lines

We can make icmp messages tx completion callback a litle bit faster.

Setting SOCK_USE_WRITE_QUEUE sk flag tells sock_wfree() to not call sk_write_space() on a socket we know no thread is posssibly waiting for write space. (on per cpu kernel internal icmp sockets only)

Quoted 7 lines

This avoids the sock_def_write_space() call and read_lock(&sk->sk_callback_lock)/read_unlock(&sk->sk_callback_lock) calls as well.

We avoid three atomic ops.

Applied to net-next-2.6