[NET]: Size listen hash tables using backlog hint
We currently allocate a fixed size (TCP_SYNQ_HSIZE=512) slots hash table for each LISTEN socket, regardless of various parameters (listen backlog for example) On x86_64, this means order-1 allocations (might fail), even for 'small' sockets, expecting few connections. On the contrary, a huge server wanting a backlog of 50000 is slowed down a bit because of this fixed limit. This patch makes the sizing of listen hash table a dynamic parameter, depending of : - net.core.somaxconn tunable (default is 128) - net.ipv4.tcp_max_syn_backlog tunable (default : 256, 1024 or 128) - backlog value given by user application (2nd parameter of listen()) For large allocations (bigger than PAGE_SIZE), we use vmalloc() instead of kmalloc(). We still limit memory allocation with the two existing tunables (somaxconn & tcp_max_syn_backlog). So for standard setups, this patch actually reduce RAM usage. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
3c62f75aac
commit
72a3effaf6
+3
-3
@@ -262,12 +262,12 @@ int dccp_destroy_sock(struct sock *sk)
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_destroy_sock);
|
||||
|
||||
static inline int dccp_listen_start(struct sock *sk)
|
||||
static inline int dccp_listen_start(struct sock *sk, int backlog)
|
||||
{
|
||||
struct dccp_sock *dp = dccp_sk(sk);
|
||||
|
||||
dp->dccps_role = DCCP_ROLE_LISTEN;
|
||||
return inet_csk_listen_start(sk, TCP_SYNQ_HSIZE);
|
||||
return inet_csk_listen_start(sk, backlog);
|
||||
}
|
||||
|
||||
int dccp_disconnect(struct sock *sk, int flags)
|
||||
@@ -788,7 +788,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)
|
||||
* FIXME: here it probably should be sk->sk_prot->listen_start
|
||||
* see tcp_listen_start
|
||||
*/
|
||||
err = dccp_listen_start(sk);
|
||||
err = dccp_listen_start(sk, backlog);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user