From c1d9422a64e70d4e8d9b158d00d7458fb299801d Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Wed, 3 Sep 2008 00:23:14 +0000 Subject: ipvs: Make number of locks protecting connection table configurable The size of the connection table can be increased up to 20 bits, resulting in a table size of 1048576 entries. The number of locks is fixed to 4 bits, resulting in only 16 locks. This doesn't scale well, make the number of locks configurable too. Lowest value is 4 and the upper bound is the size of the connection table. Signed-off-by: Sven Wegener --- include/net/ip_vs.h | 8 ++++++++ net/netfilter/ipvs/Kconfig | 14 ++++++++++++++ net/netfilter/ipvs/ip_vs_conn.c | 24 ++++++++++-------------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 8dc3296b7bea..eb425393f15a 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h @@ -603,6 +603,14 @@ extern void ip_vs_init_hash_table(struct list_head *table, int rows); #define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS) #define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1) +#ifndef CONFIG_IP_VS_LOCK_BITS +#define CONFIG_IP_VS_LOCK_BITS 4 +#endif + +#define IP_VS_CONN_LOCK_BITS CONFIG_IP_VS_LOCK_BITS +#define IP_VS_CONN_LOCK_SIZE (1 << IP_VS_CONN_LOCK_BITS) +#define IP_VS_CONN_LOCK_MASK (IP_VS_CONN_LOCK_SIZE - 1) + enum { IP_VS_DIR_INPUT = 0, IP_VS_DIR_OUTPUT, diff --git a/net/netfilter/ipvs/Kconfig b/net/netfilter/ipvs/Kconfig index f2d76238b9b5..fb9697e919d5 100644 --- a/net/netfilter/ipvs/Kconfig +++ b/net/netfilter/ipvs/Kconfig @@ -68,6 +68,20 @@ config IP_VS_TAB_BITS each hash entry uses 8 bytes, so you can estimate how much memory is needed for your box. +config IP_VS_LOCK_BITS + int "IPVS lock table size (the Nth power of 2)" + range 4 IP_VS_TAB_BITS + default 4 + ---help--- + The IPVS connection hash table is protected by a table of rwlocks, + each lock covering a subset of the whole connection hash table. This + number specifies the number of locks used to protect the table. + + Note the number of locks must be power of 2. The number of locks will + be the value of 2 to the your input number power. The number to + choose is from 4 up to the number of the connection table size, with + the default number being 4. + comment "IPVS transport protocol load balancing support" config IP_VS_PROTO_TCP diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index 27c30cf933da..c05059d6ad2e 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -60,10 +60,6 @@ static unsigned int ip_vs_conn_rnd; /* * Fine locking granularity for big connection hash table */ -#define CT_LOCKARRAY_BITS 4 -#define CT_LOCKARRAY_SIZE (1<