Patchwork icmp: No need to call sk_write_space()

login
register
mail settings
Submitter Eric Dumazet
Date Sept. 24, 2009, 10:16 p.m.
Message ID <4ABBEFD3.6060407@gmail.com>
Download mbox | patch
Permalink /patch/34239/
State Accepted
Delegated to: David Miller
Headers show

Comments

Eric Dumazet - Sept. 24, 2009, 10:16 p.m.
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.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Oct. 5, 2009, 7:12 a.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 25 Sep 2009 00:16:51 +0200

> 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.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied to net-next-2.6
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 5bc13fe..84adb57 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -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;
 	}