Skip to contentSkip to conversation

Make INET_LHTABLE_SIZE a compile-time tunable

PATCH In review Bill Sommerfeld 2 participants 4 messages Jan 14, 2011 – Feb 1, 2011

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

PATCH 1/1 Make INET_LHTABLE_SIZE a compile-time tunable

INET_LHTABLE_SIZE has been fixed at 32 for a long time. It should be tunable as larger systems may be running many more than 32 listeners. Since the exising code depends on the hash table size being a power of two, use a shift value as the tunable and compute the hash table size from the shift value.

---
Background: We've observed that many of our machines are now running with well in excess of 32 TCP listener sockets open. As the number of cpu cores per system increases we expect this to grow further.

In general hash tables should be sized to keep hash chains short, and 32 is not enough for this on some of our machines.

The help text was inspired by the help text for LOG_BUF_SHIFT in init/Kconfig

 include/net/inet_hashtables.h |    2 +-
 net/ipv4/Kconfig              |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
include/net/inet_hashtables.h +1 -1
index e9c2ed8..7253fce 100644
@@ -113,7 +113,7 @@ struct inet_listen_hashbucket {
 };
 
 /* This is for listening sockets, thus all sockets which possess wildcards. */
-#define INET_LHTABLE_SIZE	32	/* Yes, really, this is all you need. */
+#define INET_LHTABLE_SIZE	(1U << (CONFIG_INET_LHTABLE_SHIFT))
 
 struct inet_hashinfo {
 	/* This is for sockets with full identity only.  Sockets here will
net/ipv4/Kconfig +14 -0
index 9e95d7f..a92954e 100644
@@ -440,6 +440,20 @@ config INET_TCP_DIAG
 	depends on INET_DIAG
 	def_tristate INET_DIAG
 
+config INET_LHTABLE_SHIFT
+	int "Number of TCP port listener table buckets (5 => 32, 8 => 256)"
+	default 5
+	range 0 12
+	help
+	  Select number of buckets in TCP listener hash as a power of 2
+	  32 is probably enough unless you run a lot of different servers
+	  Examples:
+		     4 => 16
+		     5 => 32 (default)
+		     6 => 64
+		     7 => 128
+		     8 => 256
+
 menuconfig TCP_CONG_ADVANCED
 	bool "TCP: advanced congestion control"
 	---help---
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 2 lines · On Fri, Jan 14, 2011 at 13:48, I wrote:

INET_LHTABLE_SIZE has been fixed at 32 for a long time.  It should be tunable as larger systems may be running many more than 32 listeners.

I haven't seen any responses to this patch submission. Can someone take a look? Thanks.

- Bill

maintainer
#2 lore raw

From: Bill Sommerfeld <[email protected]>
Date: Mon, 31 Jan 2011 13:52:03 -0800

Quoted 6 lines · On Fri, Jan 14, 2011 at 13:48, I wrote:
Quoted 2 lines

INET_LHTABLE_SIZE has been fixed at 32 for a long time.  It should be tunable as larger systems may be running many more than 32 listeners.

I haven't seen any responses to this patch submission. Can someone take a look? Thanks.

It should be dynamically sized. Compile time configuration knobs generally stick.

#3 lore raw
Quoted 5 lines · David Miller

From: Bill Sommerfeld <[email protected]>

Quoted 2 lines

I haven't seen any responses to this patch submission.  Can someone take a look?  Thanks.

It should be dynamically sized.  Compile time configuration knobs generally stick.

I'll work on that. Consider this patch withdrawn until then.