diff options
author | Sven Wegener <sven.wegener@stealer.net> | 2008-09-03 00:23:14 +0000 |
---|---|---|
committer | Sven Wegener <sven.wegener@stealer.net> | 2010-02-06 13:49:15 +0000 |
commit | c1d9422a64e70d4e8d9b158d00d7458fb299801d (patch) | |
tree | 2782550ec8c91a01ad321215434c1c6d8235c7ee | |
parent | 7aeef972cce30b0ab04047e07918b04d867e7a29 (diff) |
ipvs: Make number of locks protecting connection table configurableipvs/experimental
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 <sven.wegener@stealer.net>
-rw-r--r-- | include/net/ip_vs.h | 8 | ||||
-rw-r--r-- | net/netfilter/ipvs/Kconfig | 14 | ||||
-rw-r--r-- | 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<<CT_LOCKARRAY_BITS) -#define CT_LOCKARRAY_MASK (CT_LOCKARRAY_SIZE-1) - struct ip_vs_aligned_lock { rwlock_t l; @@ -71,46 +67,46 @@ struct ip_vs_aligned_lock /* lock array for conn table */ static struct ip_vs_aligned_lock -__ip_vs_conntbl_lock_array[CT_LOCKARRAY_SIZE] __cacheline_aligned; +__ip_vs_conntbl_lock_array[IP_VS_CONN_LOCK_SIZE] __cacheline_aligned; static inline void ct_read_lock(unsigned key) { - read_lock(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + read_lock(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_read_unlock(unsigned key) { - read_unlock(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + read_unlock(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_write_lock(unsigned key) { - write_lock(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + write_lock(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_write_unlock(unsigned key) { - write_unlock(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + write_unlock(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_read_lock_bh(unsigned key) { - read_lock_bh(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + read_lock_bh(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_read_unlock_bh(unsigned key) { - read_unlock_bh(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + read_unlock_bh(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_write_lock_bh(unsigned key) { - write_lock_bh(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + write_lock_bh(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } static inline void ct_write_unlock_bh(unsigned key) { - write_unlock_bh(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l); + write_unlock_bh(&__ip_vs_conntbl_lock_array[key&IP_VS_CONN_LOCK_MASK].l); } @@ -1087,7 +1083,7 @@ int __init ip_vs_conn_init(void) INIT_LIST_HEAD(&ip_vs_conn_tab[idx]); } - for (idx = 0; idx < CT_LOCKARRAY_SIZE; idx++) { + for (idx = 0; idx < IP_VS_CONN_LOCK_SIZE; idx++) { rwlock_init(&__ip_vs_conntbl_lock_array[idx].l); } |