Use pool_cache for sockets.
This commit is contained in:
parent
bc7be9dd42
commit
c9ac92b592
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uipc_socket.c,v 1.165 2008/05/24 18:43:02 christos Exp $ */
|
||||
/* $NetBSD: uipc_socket.c,v 1.166 2008/05/26 17:21:18 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -63,7 +63,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.165 2008/05/24 18:43:02 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.166 2008/05/26 17:21:18 ad Exp $");
|
||||
|
||||
#include "opt_sock_counters.h"
|
||||
#include "opt_sosend_loan.h"
|
||||
|
@ -435,6 +435,7 @@ soinit(void)
|
|||
mutex_init(&so_pendfree_lock, MUTEX_DEFAULT, IPL_VM);
|
||||
softnet_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&socurkva_cv, "sokva");
|
||||
soinit2();
|
||||
|
||||
/* Set the initial adjusted socket buffer size. */
|
||||
if (sb_max_set(sb_max))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uipc_socket2.c,v 1.93 2008/05/24 16:35:28 christos Exp $ */
|
||||
/* $NetBSD: uipc_socket2.c,v 1.94 2008/05/26 17:21:18 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -58,7 +58,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.93 2008/05/24 16:35:28 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.94 2008/05/26 17:21:18 ad Exp $");
|
||||
|
||||
#include "opt_mbuftrace.h"
|
||||
#include "opt_sb_max.h"
|
||||
|
@ -120,8 +120,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.93 2008/05/24 16:35:28 christos E
|
|||
* domains.
|
||||
*/
|
||||
|
||||
static POOL_INIT(socket_pool, sizeof(struct socket), 0, 0, 0, "sockpl", NULL,
|
||||
IPL_SOFTNET);
|
||||
static pool_cache_t socket_cache;
|
||||
|
||||
u_long sb_max = SB_MAX; /* maximum socket buffer size */
|
||||
static u_long sb_max_adj; /* adjusted sb_max */
|
||||
|
@ -215,6 +214,14 @@ soisdisconnected(struct socket *so)
|
|||
sorwakeup(so);
|
||||
}
|
||||
|
||||
void
|
||||
soinit2(void)
|
||||
{
|
||||
|
||||
socket_cache = pool_cache_init(sizeof(struct socket), 0, 0, 0,
|
||||
"socket", NULL, IPL_SOFTNET, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* When an attempt at a new connection is noted on a socket
|
||||
* which accepts connections, sonewconn is called. If the
|
||||
|
@ -284,7 +291,7 @@ soget(bool waitok)
|
|||
{
|
||||
struct socket *so;
|
||||
|
||||
so = pool_get(&socket_pool, (waitok ? PR_WAITOK : PR_NOWAIT));
|
||||
so = pool_cache_get(socket_cache, (waitok ? PR_WAITOK : PR_NOWAIT));
|
||||
if (__predict_false(so == NULL))
|
||||
return (NULL);
|
||||
memset(so, 0, sizeof(*so));
|
||||
|
@ -313,7 +320,7 @@ soput(struct socket *so)
|
|||
cv_destroy(&so->so_cv);
|
||||
cv_destroy(&so->so_rcv.sb_cv);
|
||||
cv_destroy(&so->so_snd.sb_cv);
|
||||
pool_put(&socket_pool, so);
|
||||
pool_cache_put(socket_cache, so);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: socketvar.h,v 1.108 2008/04/28 20:24:11 martin Exp $ */
|
||||
/* $NetBSD: socketvar.h,v 1.109 2008/05/26 17:21:18 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -245,6 +245,7 @@ int sbreserve(struct sockbuf *, u_long, struct socket *);
|
|||
int sbwait(struct sockbuf *);
|
||||
int sb_max_set(u_long);
|
||||
void soinit(void);
|
||||
void soinit2(void);
|
||||
int soabort(struct socket *);
|
||||
int soaccept(struct socket *, struct mbuf *);
|
||||
int sobind(struct socket *, struct mbuf *, struct lwp *);
|
||||
|
|
Loading…
Reference in New Issue