summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2019-02-10 22:45:57 +0000
committertedu <tedu@openbsd.org>2019-02-10 22:45:57 +0000
commit4bfbad54dc74c781cf5f6c5be05536cc5b05f314 (patch)
tree36e6282076e4ec2769422ead322bd985449a25f4 /sys
parentwhitespace tweak, no functional change (diff)
downloadwireguard-openbsd-4bfbad54dc74c781cf5f6c5be05536cc5b05f314.tar.xz
wireguard-openbsd-4bfbad54dc74c781cf5f6c5be05536cc5b05f314.zip
revert revert revert. there are many other archs that use custom allocs.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arm/arm/pmap7.c6
-rw-r--r--sys/arch/arm64/arm64/pmap.c6
-rw-r--r--sys/kern/subr_pool.c46
-rw-r--r--sys/kern/uipc_mbuf.c8
-rw-r--r--sys/sys/pool.h4
5 files changed, 36 insertions, 34 deletions
diff --git a/sys/arch/arm/arm/pmap7.c b/sys/arch/arm/arm/pmap7.c
index 36eab051865..9314ff12d90 100644
--- a/sys/arch/arm/arm/pmap7.c
+++ b/sys/arch/arm/arm/pmap7.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap7.c,v 1.57 2019/02/10 20:02:37 tedu Exp $ */
+/* $OpenBSD: pmap7.c,v 1.58 2019/02/10 22:45:58 tedu Exp $ */
/* $NetBSD: pmap.c,v 1.147 2004/01/18 13:03:50 scw Exp $ */
/*
@@ -243,7 +243,7 @@ struct pool pmap_pmap_pool;
*/
struct pool pmap_pv_pool;
void *pmap_bootstrap_pv_page_alloc(struct pool *, int, int *);
-void pmap_bootstrap_pv_page_free(struct pool *, int, void *);
+void pmap_bootstrap_pv_page_free(struct pool *, void *);
struct pool_allocator pmap_bootstrap_pv_allocator = {
pmap_bootstrap_pv_page_alloc, pmap_bootstrap_pv_page_free
};
@@ -2448,7 +2448,7 @@ pmap_bootstrap_pv_page_alloc(struct pool *pp, int flags, int *slowdown)
}
void
-pmap_bootstrap_pv_page_free(struct pool *pp, int flags, void *v)
+pmap_bootstrap_pv_page_free(struct pool *pp, void *v)
{
extern void pool_page_free(struct pool *, void *);
diff --git a/sys/arch/arm64/arm64/pmap.c b/sys/arch/arm64/arm64/pmap.c
index f4571814fde..f0366c8d8c7 100644
--- a/sys/arch/arm64/arm64/pmap.c
+++ b/sys/arch/arm64/arm64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.59 2019/02/10 20:07:33 tedu Exp $ */
+/* $OpenBSD: pmap.c,v 1.60 2019/02/10 22:45:58 tedu Exp $ */
/*
* Copyright (c) 2008-2009,2014-2016 Dale Rahn <drahn@dalerahn.com>
*
@@ -109,7 +109,7 @@ CTASSERT(sizeof(struct pmapvp0) == sizeof(struct pmapvp3));
/* Allocator for VP pool. */
void *pmap_vp_page_alloc(struct pool *, int, int *);
-void pmap_vp_page_free(struct pool *, int, void *);
+void pmap_vp_page_free(struct pool *, void *);
struct pool_allocator pmap_vp_allocator = {
pmap_vp_page_alloc, pmap_vp_page_free, sizeof(struct pmapvp0)
@@ -381,7 +381,7 @@ pmap_vp_page_alloc(struct pool *pp, int flags, int *slowdown)
}
void
-pmap_vp_page_free(struct pool *pp, int flags, void *v)
+pmap_vp_page_free(struct pool *pp, void *v)
{
km_free(v, pp->pr_pgsize, &kv_any, &kp_dirty);
}
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index f924edd6a39..94ea816183d 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.225 2019/02/10 20:05:04 tedu Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.226 2019/02/10 22:45:57 tedu Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -155,7 +155,6 @@ struct pool_page_header {
caddr_t ph_colored; /* page's colored address */
unsigned long ph_magic;
int ph_tick;
- int ph_flags;
};
#define POOL_MAGICBIT (1 << 3) /* keep away from perturbed low bits */
#define POOL_PHPOISON(ph) ISSET((ph)->ph_magic, POOL_MAGICBIT)
@@ -226,13 +225,13 @@ void pool_get_done(struct pool *, void *, void *);
void pool_runqueue(struct pool *, int);
void *pool_allocator_alloc(struct pool *, int, int *);
-void pool_allocator_free(struct pool *, int, void *);
+void pool_allocator_free(struct pool *, void *);
/*
* The default pool allocator.
*/
void *pool_page_alloc(struct pool *, int, int *);
-void pool_page_free(struct pool *, int, void *);
+void pool_page_free(struct pool *, void *);
/*
* safe for interrupts; this is the default allocator
@@ -244,7 +243,7 @@ struct pool_allocator pool_allocator_single = {
};
void *pool_multi_alloc(struct pool *, int, int *);
-void pool_multi_free(struct pool *, int, void *);
+void pool_multi_free(struct pool *, void *);
struct pool_allocator pool_allocator_multi = {
pool_multi_alloc,
@@ -253,7 +252,7 @@ struct pool_allocator pool_allocator_multi = {
};
void *pool_multi_alloc_ni(struct pool *, int, int *);
-void pool_multi_free_ni(struct pool *, int, void *);
+void pool_multi_free_ni(struct pool *, void *);
struct pool_allocator pool_allocator_multi_ni = {
pool_multi_alloc_ni,
@@ -788,6 +787,7 @@ pool_do_get(struct pool *pp, int flags, int *slowdown)
void
pool_put(struct pool *pp, void *v)
{
+ struct pool_page_header *ph, *freeph = NULL;
#ifdef DIAGNOSTIC
if (v == NULL)
@@ -808,8 +808,19 @@ pool_put(struct pool *pp, void *v)
pp->pr_nout--;
pp->pr_nput++;
+ /* is it time to free a page? */
+ if (pp->pr_nidle > pp->pr_maxpages &&
+ (ph = TAILQ_FIRST(&pp->pr_emptypages)) != NULL &&
+ (ticks - ph->ph_tick) > (hz * pool_wait_free)) {
+ freeph = ph;
+ pool_p_remove(pp, freeph);
+ }
+
pl_leave(pp, &pp->pr_lock);
+ if (freeph != NULL)
+ pool_p_free(pp, freeph);
+
if (!TAILQ_EMPTY(&pp->pr_requests)) {
pl_enter(pp, &pp->pr_requests_lock);
pool_runqueue(pp, PR_NOWAIT);
@@ -922,11 +933,10 @@ pool_p_alloc(struct pool *pp, int flags, int *slowdown)
else {
ph = pool_get(&phpool, flags);
if (ph == NULL) {
- pool_allocator_free(pp, flags, addr);
+ pool_allocator_free(pp, addr);
return (NULL);
}
}
- ph->ph_flags = flags;
XSIMPLEQ_INIT(&ph->ph_items);
ph->ph_page = addr;
@@ -1000,7 +1010,7 @@ pool_p_free(struct pool *pp, struct pool_page_header *ph)
#endif
}
- pool_allocator_free(pp, ph->ph_flags, ph->ph_page);
+ pool_allocator_free(pp, ph->ph_page);
if (!POOL_INPGHDR(pp))
pool_put(&phpool, ph);
@@ -1606,11 +1616,11 @@ pool_allocator_alloc(struct pool *pp, int flags, int *slowdown)
}
void
-pool_allocator_free(struct pool *pp, int flags, void *v)
+pool_allocator_free(struct pool *pp, void *v)
{
struct pool_allocator *pa = pp->pr_alloc;
- (*pa->pa_free)(pp, flags, v);
+ (*pa->pa_free)(pp, v);
}
void *
@@ -1625,7 +1635,7 @@ pool_page_alloc(struct pool *pp, int flags, int *slowdown)
}
void
-pool_page_free(struct pool *pp, int flags, void *v)
+pool_page_free(struct pool *pp, void *v)
{
km_free(v, pp->pr_pgsize, &kv_page, pp->pr_crange);
}
@@ -1638,9 +1648,6 @@ pool_multi_alloc(struct pool *pp, int flags, int *slowdown)
void *v;
int s;
- if (flags & PR_WAITOK)
- return pool_multi_alloc_ni(pp, flags, slowdown);
-
if (POOL_INPGHDR(pp))
kv.kv_align = pp->pr_pgsize;
@@ -1655,16 +1662,11 @@ pool_multi_alloc(struct pool *pp, int flags, int *slowdown)
}
void
-pool_multi_free(struct pool *pp, int flags, void *v)
+pool_multi_free(struct pool *pp, void *v)
{
struct kmem_va_mode kv = kv_intrsafe;
int s;
- if (flags & PR_WAITOK) {
- pool_multi_free_ni(pp, flags, v);
- return;
- }
-
if (POOL_INPGHDR(pp))
kv.kv_align = pp->pr_pgsize;
@@ -1694,7 +1696,7 @@ pool_multi_alloc_ni(struct pool *pp, int flags, int *slowdown)
}
void
-pool_multi_free_ni(struct pool *pp, int flags, void *v)
+pool_multi_free_ni(struct pool *pp, void *v)
{
struct kmem_va_mode kv = kv_any;
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a6aaa3ea24a..d100d3dd65b 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.267 2019/02/10 20:02:37 tedu Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.268 2019/02/10 22:45:58 tedu Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -139,7 +139,7 @@ unsigned int mbuf_mem_limit; /* how much memory can be allocated */
unsigned int mbuf_mem_alloc; /* how much memory has been allocated */
void *m_pool_alloc(struct pool *, int, int *);
-void m_pool_free(struct pool *, int, void *);
+void m_pool_free(struct pool *, void *);
struct pool_allocator m_pool_allocator = {
m_pool_alloc,
@@ -1475,9 +1475,9 @@ m_pool_alloc(struct pool *pp, int flags, int *slowdown)
}
void
-m_pool_free(struct pool *pp, int flags, void *v)
+m_pool_free(struct pool *pp, void *v)
{
- (*pool_allocator_multi.pa_free)(pp, flags, v);
+ (*pool_allocator_multi.pa_free)(pp, v);
mtx_enter(&m_pool_mtx);
mbuf_mem_alloc -= pp->pr_pgsize;
diff --git a/sys/sys/pool.h b/sys/sys/pool.h
index 71e944c5be7..079d328a4a0 100644
--- a/sys/sys/pool.h
+++ b/sys/sys/pool.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pool.h,v 1.75 2019/02/10 20:02:37 tedu Exp $ */
+/* $OpenBSD: pool.h,v 1.76 2019/02/10 22:45:58 tedu Exp $ */
/* $NetBSD: pool.h,v 1.27 2001/06/06 22:00:17 rafal Exp $ */
/*-
@@ -107,7 +107,7 @@ TAILQ_HEAD(pool_requests, pool_request);
struct pool_allocator {
void *(*pa_alloc)(struct pool *, int, int *);
- void (*pa_free)(struct pool *, int, void *);
+ void (*pa_free)(struct pool *, void *);
size_t pa_pagesz;
};