aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2008-11-26 00:16:35 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-26 00:16:35 -0500
commit1748376b6626acf59c24e9592ac67b3fe2a0e026 (patch)
tree65a28205daf1ca92e31389440764fc407365014e /net/sctp/socket.c
parentc1b56878fb68e9c14070939ea4537ad4db79ffae (diff)
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 (248969ae31e1b3276fc4399d67ce29a5d81e6fd9 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>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index ba81fe3ccab8..a2de585888d0 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -114,7 +114,7 @@ extern int sysctl_sctp_wmem[3];
114 114
115static int sctp_memory_pressure; 115static int sctp_memory_pressure;
116static atomic_t sctp_memory_allocated; 116static atomic_t sctp_memory_allocated;
117static atomic_t sctp_sockets_allocated; 117struct percpu_counter sctp_sockets_allocated;
118 118
119static void sctp_enter_memory_pressure(struct sock *sk) 119static void sctp_enter_memory_pressure(struct sock *sk)
120{ 120{
@@ -3613,7 +3613,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3613 sp->hmac = NULL; 3613 sp->hmac = NULL;
3614 3614
3615 SCTP_DBG_OBJCNT_INC(sock); 3615 SCTP_DBG_OBJCNT_INC(sock);
3616 atomic_inc(&sctp_sockets_allocated); 3616 percpu_counter_inc(&sctp_sockets_allocated);
3617 3617
3618 local_bh_disable(); 3618 local_bh_disable();
3619 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 3619 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
@@ -3632,7 +3632,7 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
3632 /* Release our hold on the endpoint. */ 3632 /* Release our hold on the endpoint. */
3633 ep = sctp_sk(sk)->ep; 3633 ep = sctp_sk(sk)->ep;
3634 sctp_endpoint_free(ep); 3634 sctp_endpoint_free(ep);
3635 atomic_dec(&sctp_sockets_allocated); 3635 percpu_counter_dec(&sctp_sockets_allocated);
3636 local_bh_disable(); 3636 local_bh_disable();
3637 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 3637 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
3638 local_bh_enable(); 3638 local_bh_enable();