summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2013-11-05 03:28:44 +0000
committerdlg <dlg@openbsd.org>2013-11-05 03:28:44 +0000
commit562a4aeae0180db9db98df3bb019f0098eb14d37 (patch)
treee0f8e6931c05d77ca47a7670e263ad469a2f7df6
parentReplace direct references to p_size, p_offset and d_secperunit with (diff)
downloadwireguard-openbsd-562a4aeae0180db9db98df3bb019f0098eb14d37.tar.xz
wireguard-openbsd-562a4aeae0180db9db98df3bb019f0098eb14d37.zip
remove pool constructors and destructors. theyre called for every
get and put, so they dont save us anything by caching constructed objects. there were no real users of them, and this api was never documented. removing conditionals in a hot path cant be a bad idea either. ok deraadt@ krw@ kettenis@
-rw-r--r--sys/kern/subr_pool.c34
-rw-r--r--sys/sys/pool.h8
2 files changed, 5 insertions, 37 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index b469b9b8139..0be2df00543 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.123 2013/08/08 23:25:06 syl Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.124 2013/11/05 03:28:45 dlg Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -342,11 +342,6 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
if (pool_serial == 0)
panic("pool_init: too much uptime");
- /* constructor, destructor, and arg */
- pp->pr_ctor = NULL;
- pp->pr_dtor = NULL;
- pp->pr_arg = NULL;
-
/*
* Decide whether to put the page header off page to avoid
* wasting too large a part of the page. Off-page page headers
@@ -511,20 +506,9 @@ pool_get(struct pool *pp, int flags)
if (v == NULL)
return (v);
- if (pp->pr_ctor) {
- if (flags & PR_ZERO)
- panic("pool_get: PR_ZERO when ctor set");
- if (pp->pr_ctor(pp->pr_arg, v, flags)) {
- mtx_enter(&pp->pr_mtx);
- pp->pr_nget--;
- pool_do_put(pp, v);
- mtx_leave(&pp->pr_mtx);
- v = NULL;
- }
- } else {
- if (flags & PR_ZERO)
- memset(v, 0, pp->pr_size);
- }
+ if (flags & PR_ZERO)
+ memset(v, 0, pp->pr_size);
+
return (v);
}
@@ -722,8 +706,6 @@ startover:
void
pool_put(struct pool *pp, void *v)
{
- if (pp->pr_dtor)
- pp->pr_dtor(pp->pr_arg, v);
mtx_enter(&pp->pr_mtx);
#ifdef POOL_DEBUG
if (pp->pr_roflags & PR_DEBUGCHK) {
@@ -1051,14 +1033,6 @@ pool_set_constraints(struct pool *pp, const struct kmem_pa_mode *mode)
pp->pr_crange = mode;
}
-void
-pool_set_ctordtor(struct pool *pp, int (*ctor)(void *, void *, int),
- void (*dtor)(void *, void *), void *arg)
-{
- pp->pr_ctor = ctor;
- pp->pr_dtor = dtor;
- pp->pr_arg = arg;
-}
/*
* Release all complete pages that have not been used recently.
*
diff --git a/sys/sys/pool.h b/sys/sys/pool.h
index 761dd68fde6..d0fe9d1d6cd 100644
--- a/sys/sys/pool.h
+++ b/sys/sys/pool.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pool.h,v 1.43 2013/03/26 16:37:45 tedu Exp $ */
+/* $OpenBSD: pool.h,v 1.44 2013/11/05 03:28:44 dlg Exp $ */
/* $NetBSD: pool.h,v 1.27 2001/06/06 22:00:17 rafal Exp $ */
/*-
@@ -108,10 +108,6 @@ struct pool {
int pr_curcolor;
int pr_phoffset; /* Offset in page of page header */
- /* constructor, destructor, and arg */
- int (*pr_ctor)(void *, void *, int);
- void (*pr_dtor)(void *, void *);
- void *pr_arg;
/*
* Warning message to be issued, and a per-time-delta rate cap,
* if the hard limit is reached.
@@ -149,8 +145,6 @@ int pool_sethardlimit(struct pool *, u_int, const char *, int);
struct uvm_constraint_range; /* XXX */
void pool_set_constraints(struct pool *,
const struct kmem_pa_mode *mode);
-void pool_set_ctordtor(struct pool *, int (*)(void *, void *, int),
- void(*)(void *, void *), void *);
/* these functions are locked */
void *pool_get(struct pool *, int) __malloc;