mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
net: Use a percpu_counter for sockets_allocated
Instead of using one atomic_t per protocol, use a percpu_counter
for "sockets_allocated", to reduce cache line contention on
heavy duty network servers.
Note : We revert commit (248969ae31
net: af_unix can make unix_nr_socks visbile in /proc),
since it is not anymore used after sock_prot_inuse_add() addition
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c1b56878fb
commit
1748376b66
11 changed files with 29 additions and 16 deletions
|
@ -114,7 +114,7 @@ extern int sysctl_sctp_wmem[3];
|
|||
|
||||
static int sctp_memory_pressure;
|
||||
static atomic_t sctp_memory_allocated;
|
||||
static atomic_t sctp_sockets_allocated;
|
||||
struct percpu_counter sctp_sockets_allocated;
|
||||
|
||||
static void sctp_enter_memory_pressure(struct sock *sk)
|
||||
{
|
||||
|
@ -3613,7 +3613,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
|
|||
sp->hmac = NULL;
|
||||
|
||||
SCTP_DBG_OBJCNT_INC(sock);
|
||||
atomic_inc(&sctp_sockets_allocated);
|
||||
percpu_counter_inc(&sctp_sockets_allocated);
|
||||
|
||||
local_bh_disable();
|
||||
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
||||
|
@ -3632,7 +3632,7 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
|
|||
/* Release our hold on the endpoint. */
|
||||
ep = sctp_sk(sk)->ep;
|
||||
sctp_endpoint_free(ep);
|
||||
atomic_dec(&sctp_sockets_allocated);
|
||||
percpu_counter_dec(&sctp_sockets_allocated);
|
||||
local_bh_disable();
|
||||
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
|
||||
local_bh_enable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue