From dcb04c4830b3bb71205a10a4aa84d631aac94222 Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Sat, 8 Nov 2014 13:37:10 -0800 Subject: [PATCH] remap pools to uma zones (cherry picked from commit 2165c018fc9389723d58881d9f231b544de17915) Signed-off-by: Scott K --- sys/compat/mach/mach_message.c | 18 ++++++++++-------- sys/compat/mach/mach_misc.c | 1 - sys/compat/mach/mach_port.c | 28 ++++++++++++++++------------ sys/compat/mach/mach_semaphore.c | 33 +++++++++++++++++---------------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/sys/compat/mach/mach_message.c b/sys/compat/mach/mach_message.c index 0b005e4..92b60d8 100644 --- a/sys/compat/mach/mach_message.c +++ b/sys/compat/mach/mach_message.c @@ -40,9 +40,10 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include + #include #include #include @@ -54,8 +55,8 @@ __FBSDID("$FreeBSD$"); #include #endif -/* Mach message pool */ -static struct pool mach_message_pool; +/* Mach message zone */ +static uma_zone_t mach_message_zone; static inline int mach_msg_send(struct thread *, mach_msg_header_t *, int *, size_t); @@ -1098,9 +1099,10 @@ inline void mach_add_ool_desc(msg, addr, size) void mach_message_init(void) { - pool_init(&mach_message_pool, sizeof (struct mach_message), - 0, 0, 0, "mach_message_pool", NULL, IPL_NONE); - return; + + mach_message_zone = + uma_zcreate("mach_message_zone", sizeof (struct mach_message), + NULL, NULL, NULL, 0/* align*/, 0/*flags*/); } struct mach_message * @@ -1108,7 +1110,7 @@ mach_message_get(mach_msg_header_t *msgh, size_t size, struct mach_port *mp, str { struct mach_message *mm; - mm = (struct mach_message *)pool_get(&mach_message_pool, PR_WAITOK); + mm = uma_zallac(mach_message_zone, M_WAITOK); memset(mm, 0, sizeof(*mm)); mm->mm_msg = msgh; mm->mm_size = size; @@ -1165,7 +1167,7 @@ mach_message_put_exclocked(struct mach_message *mm) TAILQ_REMOVE(&mp->mp_msglist, mm, mm_list); mp->mp_count--; - pool_put(&mach_message_pool, mm); + uma_zfree(mach_message_zone, mm); return; } diff --git a/sys/compat/mach/mach_misc.c b/sys/compat/mach/mach_misc.c index 5df2eb1..1798532 100644 --- a/sys/compat/mach/mach_misc.c +++ b/sys/compat/mach/mach_misc.c @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include diff --git a/sys/compat/mach/mach_port.c b/sys/compat/mach/mach_port.c index 0b0efc9..2836791 100644 --- a/sys/compat/mach/mach_port.c +++ b/sys/compat/mach/mach_port.c @@ -34,11 +34,12 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include +#include + #include #include #include @@ -54,9 +55,9 @@ __FBSDID("$FreeBSD$"); #include #endif -/* Right and port pools, list of all rights and its lock */ -static struct pool mach_port_pool; -static struct pool mach_right_pool; +/* Right and port zones, list of all rights and its lock */ +static uma_zone_t mach_port_zone; +static uma_zone_t mach_right_zone; struct mach_port *mach_bootstrap_port; struct mach_port *mach_clock_port; @@ -621,10 +622,13 @@ mach_port_mod_refs(struct mach_trap_args *args) void mach_port_init(void) { - pool_init(&mach_port_pool, sizeof (struct mach_port), - 0, 0, 0, "mach_port_pool", NULL, IPL_NONE); - pool_init(&mach_right_pool, sizeof (struct mach_right), - 0, 0, 0, "mach_right_pool", NULL, IPL_NONE); + + mach_port_zone = + uma_zcreate("mach_port_zone", sizeof (struct mach_port), + NULL, NULL, NULL, 0/* align*/, 0/*flags*/); + mach_right_zone = + uma_zcreate("mach_right_zone", sizeof (struct mach_right), + NULL, NULL, NULL, 0/* align*/, 0/*flags*/); mach_bootstrap_port = mach_port_get(); mach_clock_port = mach_port_get(); @@ -644,7 +648,7 @@ mach_port_get(void) { struct mach_port *mp; - mp = (struct mach_port *)pool_get(&mach_port_pool, PR_WAITOK); + mp = uma_zalloc(mach_port_zone, M_WAITOK); memset(mp, 0, sizeof(*mp)); mp->mp_recv = NULL; mp->mp_count = 0; @@ -678,7 +682,7 @@ mach_port_put(struct mach_port *mp) if (mp->mp_flags & MACH_MP_DATA_ALLOCATED) free(mp->mp_data, M_MACH); - pool_put(&mach_port_pool, mp); + uma_zfree(mach_port_zone, mp); return; } @@ -717,7 +721,7 @@ mach_right_get(struct mach_port *mp, struct thread *td, int type, mach_port_t hi } } - mr = pool_get(&mach_right_pool, PR_WAITOK); + mr = uma_zalloc(mach_right_zone, M_WAITOK); mr->mr_port = mp; mr->mr_lwp = l; @@ -875,7 +879,7 @@ mach_right_put_exclocked(struct mach_right *mr, int right) mach_notify_port_destroyed(mr->mr_lwp, mr); LIST_REMOVE(mr, mr_list); - pool_put(&mach_right_pool, mr); + uma_zfree(mach_right_zone, mr); } return; } diff --git a/sys/compat/mach/mach_semaphore.c b/sys/compat/mach/mach_semaphore.c index 6953b1a..befbd5f 100644 --- a/sys/compat/mach/mach_semaphore.c +++ b/sys/compat/mach/mach_semaphore.c @@ -33,12 +33,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include -#include #include #include +#include + +#include #include #include @@ -49,11 +50,11 @@ __FBSDID("$FreeBSD$"); #include #include -/* Semaphore list, lock, pools */ +/* Semaphore list, lock, zones */ static LIST_HEAD(mach_semaphore_list, mach_semaphore) mach_semaphore_list; -static krwlock_t mach_semaphore_list_lock; -static struct pool mach_semaphore_list_pool; -static struct pool mach_waiting_lwp_pool; +static struct rwlock mach_semaphore_list_lock; +static uma_zone_t mach_semaphore_list_zone; +static uma_zone_t mach_waiting_lwp_zone; /* Function to manipulate them */ static struct mach_semaphore *mach_semaphore_get(int, int); @@ -199,10 +200,12 @@ mach_semaphore_init(void) { LIST_INIT(&mach_semaphore_list); rw_init(&mach_semaphore_list_lock); - pool_init(&mach_semaphore_list_pool, sizeof (struct mach_semaphore), - 0, 0, 0, "mach_sem_pool", NULL, IPL_NONE); - pool_init(&mach_waiting_lwp_pool, sizeof (struct mach_waiting_lwp), - 0, 0, 0, "mach_waitp_pool", NULL, IPL_NONE); + mach_semaphore_list_zone = + uma_zcreate("mach_sem_zone", sizeof (struct mach_semaphore), + NULL, NULL, NULL, 0/* align*/, 0/*flags*/); + mach_waiting_lwp_zone = + uma_zcreate("mach_waitp_zone", sizeof (struct mach_waiting_lwp), + NULL, NULL, NULL, 0/* align*/, 0/*flags*/); return; } @@ -212,8 +215,7 @@ mach_semaphore_get(int value, int policy) { struct mach_semaphore *ms; - ms = (struct mach_semaphore *)pool_get(&mach_semaphore_list_pool, - M_WAITOK); + ms = uma_zalloc(mach_semaphore_list_zone, M_WAITOK); ms->ms_value = value; ms->ms_policy = policy; TAILQ_INIT(&ms->ms_waiting); @@ -241,7 +243,7 @@ mach_semaphore_put(struct mach_semaphore *ms) LIST_REMOVE(ms, ms_list); rw_exit(&mach_semaphore_list_lock); - pool_put(&mach_semaphore_list_pool, ms); + uma_zfree(mach_semaphore_list_zone, ms); return; } @@ -251,8 +253,7 @@ mach_waiting_lwp_get(struct thread *td, struct mach_semaphore *ms) { struct mach_waiting_lwp *mwl; - mwl = (struct mach_waiting_lwp *)pool_get(&mach_waiting_lwp_pool, - M_WAITOK); + mwl = uma_zalloc(mach_waiting_lwp_zone, M_WAITOK); mwl->mwl_l = l; rw_enter(&ms->ms_lock, RW_WRITER); @@ -270,7 +271,7 @@ mach_waiting_lwp_put(struct mach_waiting_lwp *mwl, struct mach_semaphore *ms, in TAILQ_REMOVE(&ms->ms_waiting, mwl, mwl_list); if (!locked) rw_exit(&ms->ms_lock); - pool_put(&mach_waiting_lwp_pool, mwl); + uma_zfree(mach_waiting_lwp_zone, mwl); return; } -- 1.8.4.2