diff options
| author | 2015-09-06 20:58:14 +0000 | |
|---|---|---|
| committer | 2015-09-06 20:58:14 +0000 | |
| commit | b0c99887288c9456ac68c3a0109ff2955af5b9f5 (patch) | |
| tree | c9db66fb8e09cb582c14f39ea9b94aad9466b4b1 /sys/kern/subr_pool.c | |
| parent | Fix aliasing of sys_errlist, sys_nerr, sys_siglist, and sys_signame (diff) | |
| download | wireguard-openbsd-b0c99887288c9456ac68c3a0109ff2955af5b9f5.tar.xz wireguard-openbsd-b0c99887288c9456ac68c3a0109ff2955af5b9f5.zip | |
We no longer need to grab the kernel lock for allocating and freeing pages
in the (default) single page pool backend allocator. This means it is now
safe to call pool_get(9) and pool_put(9) for "small" items while holding
a mutex without holding the kernel lock as well as these functions will
no longer acquire the kernel lock under any circumstances. For "large" items
(where large is larger than 1/8th of a page) this still isn't safe though.
ok dlg@
Diffstat (limited to 'sys/kern/subr_pool.c')
| -rw-r--r-- | sys/kern/subr_pool.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 39a87575d1b..c3820846c41 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.189 2015/09/01 08:22:45 kettenis Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.190 2015/09/06 20:58:14 kettenis Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -1436,9 +1436,17 @@ pool_page_alloc(struct pool *pp, int flags, int *slowdown) kd.kd_waitok = ISSET(flags, PR_WAITOK); kd.kd_slowdown = slowdown; - KERNEL_LOCK(); + /* + * XXX Until we can call msleep(9) without holding the kernel + * lock. + */ + if (ISSET(flags, PR_WAITOK)) + KERNEL_LOCK(); + v = km_alloc(pp->pr_pgsize, &kv_page, pp->pr_crange, &kd); - KERNEL_UNLOCK(); + + if (ISSET(flags, PR_WAITOK)) + KERNEL_UNLOCK(); return (v); } @@ -1446,9 +1454,7 @@ pool_page_alloc(struct pool *pp, int flags, int *slowdown) void pool_page_free(struct pool *pp, void *v) { - KERNEL_LOCK(); km_free(v, pp->pr_pgsize, &kv_page, pp->pr_crange); - KERNEL_UNLOCK(); } void * |
