summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/uts/common/disp/thread.c2
-rw-r--r--usr/src/uts/common/sys/proc.h1
-rw-r--r--usr/src/uts/sparc/v9/os/v9dep.c10
-rw-r--r--usr/src/uts/sparc/v9/sys/machpcb.h13
-rw-r--r--usr/src/uts/sun4/os/machdep.c45
5 files changed, 43 insertions, 28 deletions
diff --git a/usr/src/uts/common/disp/thread.c b/usr/src/uts/common/disp/thread.c
index 4405e40209..fc2bbb0337 100644
--- a/usr/src/uts/common/disp/thread.c
+++ b/usr/src/uts/common/disp/thread.c
@@ -171,6 +171,8 @@ thread_init(void)
thread_cache = kmem_cache_create("thread_cache", sizeof (kthread_t),
PTR24_ALIGN, NULL, NULL, NULL, NULL, static_arena, 0);
+ lwp_stk_cache_init();
+
lwp_cache = kmem_cache_create("lwp_cache", sizeof (klwp_t),
0, NULL, NULL, NULL, NULL, NULL, 0);
#endif
diff --git a/usr/src/uts/common/sys/proc.h b/usr/src/uts/common/sys/proc.h
index 1f79353453..f908f9b6e7 100644
--- a/usr/src/uts/common/sys/proc.h
+++ b/usr/src/uts/common/sys/proc.h
@@ -716,6 +716,7 @@ extern void lwp_setrval(klwp_t *, int, int);
extern void lwp_forkregs(klwp_t *, klwp_t *);
extern void lwp_freeregs(klwp_t *, int);
extern caddr_t lwp_stk_init(klwp_t *, caddr_t);
+extern void lwp_stk_cache_init(void);
extern void lwp_stk_fini(klwp_t *);
extern void lwp_installctx(klwp_t *);
extern void lwp_rtt(void);
diff --git a/usr/src/uts/sparc/v9/os/v9dep.c b/usr/src/uts/sparc/v9/os/v9dep.c
index b63433f1e4..009621abdc 100644
--- a/usr/src/uts/sparc/v9/os/v9dep.c
+++ b/usr/src/uts/sparc/v9/os/v9dep.c
@@ -826,17 +826,15 @@ setregs(uarg_t *args)
if (p->p_model == DATAMODEL_LP64 &&
mpcb->mpcb_wstate != WSTATE_USER64) {
ASSERT(mpcb->mpcb_wbcnt == 0);
- kmem_free(mpcb->mpcb_wbuf, MAXWIN * sizeof (struct rwindow32));
- mpcb->mpcb_wbuf = kmem_alloc(MAXWIN *
- sizeof (struct rwindow64), KM_SLEEP);
+ kmem_cache_free(wbuf32_cache, mpcb->mpcb_wbuf);
+ mpcb->mpcb_wbuf = kmem_cache_alloc(wbuf64_cache, KM_SLEEP);
ASSERT(((uintptr_t)mpcb->mpcb_wbuf & 7) == 0);
mpcb->mpcb_wstate = WSTATE_USER64;
} else if (p->p_model == DATAMODEL_ILP32 &&
mpcb->mpcb_wstate != WSTATE_USER32) {
ASSERT(mpcb->mpcb_wbcnt == 0);
- kmem_free(mpcb->mpcb_wbuf, MAXWIN * sizeof (struct rwindow64));
- mpcb->mpcb_wbuf = kmem_alloc(MAXWIN *
- sizeof (struct rwindow32), KM_SLEEP);
+ kmem_cache_free(wbuf64_cache, mpcb->mpcb_wbuf);
+ mpcb->mpcb_wbuf = kmem_cache_alloc(wbuf32_cache, KM_SLEEP);
mpcb->mpcb_wstate = WSTATE_USER32;
}
mpcb->mpcb_pa = va_to_pa(mpcb);
diff --git a/usr/src/uts/sparc/v9/sys/machpcb.h b/usr/src/uts/sparc/v9/sys/machpcb.h
index de517c40fe..63da78e8c6 100644
--- a/usr/src/uts/sparc/v9/sys/machpcb.h
+++ b/usr/src/uts/sparc/v9/sys/machpcb.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -98,6 +97,12 @@ typedef struct machpcb {
((caddr_t)(lwp)->lwp_regs - REGOFF))
#endif
+#ifndef _ASM
+struct kmem_cache;
+extern struct kmem_cache *wbuf32_cache;
+extern struct kmem_cache *wbuf64_cache;
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/sun4/os/machdep.c b/usr/src/uts/sun4/os/machdep.c
index 902923ccff..76588c0976 100644
--- a/usr/src/uts/sun4/os/machdep.c
+++ b/usr/src/uts/sun4/os/machdep.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -58,6 +57,7 @@
#include <sys/sysmacros.h>
#include <sys/promif.h>
#include <sys/pool_pset.h>
+#include <vm/seg_kmem.h>
int maxphys = MMU_PAGESIZE * 16; /* 128k */
int klustsize = MMU_PAGESIZE * 16; /* 128k */
@@ -82,6 +82,21 @@ thread_stk_init(caddr_t stk)
return (stk);
}
+#define WIN32_SIZE (MAXWIN * sizeof (struct rwindow32))
+#define WIN64_SIZE (MAXWIN * sizeof (struct rwindow64))
+
+kmem_cache_t *wbuf32_cache;
+kmem_cache_t *wbuf64_cache;
+
+void
+lwp_stk_cache_init(void)
+{
+ wbuf32_cache = kmem_cache_create("wbuf32_cache", WIN32_SIZE,
+ 0, NULL, NULL, NULL, NULL, static_arena, 0);
+ wbuf64_cache = kmem_cache_create("wbuf64_cache", WIN64_SIZE,
+ 0, NULL, NULL, NULL, NULL, static_arena, 0);
+}
+
/*
* Initialize lwp's kernel stack.
* Note that now that the floating point register save area (kfpu_t)
@@ -120,12 +135,10 @@ lwp_stk_init(klwp_t *lwp, caddr_t stk)
mpcb->mpcb_wbcnt = 0;
if (lwp->lwp_procp->p_model == DATAMODEL_ILP32) {
mpcb->mpcb_wstate = WSTATE_USER32;
- mpcb->mpcb_wbuf = kmem_alloc(MAXWIN * sizeof (struct rwindow32),
- KM_SLEEP);
+ mpcb->mpcb_wbuf = kmem_cache_alloc(wbuf32_cache, KM_SLEEP);
} else {
mpcb->mpcb_wstate = WSTATE_USER64;
- mpcb->mpcb_wbuf = kmem_alloc(MAXWIN * sizeof (struct rwindow64),
- KM_SLEEP);
+ mpcb->mpcb_wbuf = kmem_cache_alloc(wbuf64_cache, KM_SLEEP);
}
ASSERT(((uintptr_t)mpcb->mpcb_wbuf & 7) == 0);
mpcb->mpcb_wbuf_pa = va_to_pa(mpcb->mpcb_wbuf);
@@ -144,9 +157,9 @@ lwp_stk_fini(klwp_t *lwp)
*/
mpcb->mpcb_wbcnt = 0;
if (mpcb->mpcb_wstate == WSTATE_USER32)
- kmem_free(mpcb->mpcb_wbuf, MAXWIN * sizeof (struct rwindow32));
+ kmem_cache_free(wbuf32_cache, mpcb->mpcb_wbuf);
else
- kmem_free(mpcb->mpcb_wbuf, MAXWIN * sizeof (struct rwindow64));
+ kmem_cache_free(wbuf64_cache, mpcb->mpcb_wbuf);
mpcb->mpcb_wbuf = NULL;
mpcb->mpcb_wbuf_pa = -1;
}
@@ -189,19 +202,15 @@ lwp_forkregs(klwp_t *lwp, klwp_t *clwp)
* Here, we took on the data model of the cloned lwp.
*/
if (mpcb->mpcb_wstate != wstate) {
- size_t osize, size;
-
if (wstate == WSTATE_USER32) {
- osize = MAXWIN * sizeof (struct rwindow32);
- size = MAXWIN * sizeof (struct rwindow64);
+ kmem_cache_free(wbuf32_cache, wbuf);
+ wbuf = kmem_cache_alloc(wbuf64_cache, KM_SLEEP);
wstate = WSTATE_USER64;
} else {
- osize = MAXWIN * sizeof (struct rwindow64);
- size = MAXWIN * sizeof (struct rwindow32);
+ kmem_cache_free(wbuf64_cache, wbuf);
+ wbuf = kmem_cache_alloc(wbuf32_cache, KM_SLEEP);
wstate = WSTATE_USER32;
}
- kmem_free(wbuf, osize);
- wbuf = kmem_alloc(size, KM_SLEEP);
}
mpcb->mpcb_pa = va_to_pa(mpcb);