summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/os/mem_cage.c185
-rw-r--r--usr/src/uts/common/sys/mem_cage.h16
-rw-r--r--usr/src/uts/sfmmu/vm/hat_sfmmu.c6
-rw-r--r--usr/src/uts/sun4/os/startup.c6
-rw-r--r--usr/src/uts/sun4/vm/vm_dep.h1
-rw-r--r--usr/src/uts/sun4u/io/sbd_mem.c15
-rw-r--r--usr/src/uts/sun4u/lw8/os/lw8_platmod.c9
-rw-r--r--usr/src/uts/sun4u/opl/io/drmach.c6
-rw-r--r--usr/src/uts/sun4u/opl/os/opl.c8
-rw-r--r--usr/src/uts/sun4u/serengeti/io/sbdp_mem.c4
-rw-r--r--usr/src/uts/sun4u/serengeti/os/serengeti.c9
-rw-r--r--usr/src/uts/sun4u/starcat/io/drmach.c8
-rw-r--r--usr/src/uts/sun4u/starcat/os/starcat.c9
-rw-r--r--usr/src/uts/sun4u/starfire/io/drmach.c8
-rw-r--r--usr/src/uts/sun4u/starfire/os/starfire.c14
-rw-r--r--usr/src/uts/sun4u/sunfire/io/ac_add.c6
-rw-r--r--usr/src/uts/sun4u/sunfire/io/ac_del.c12
-rw-r--r--usr/src/uts/sun4u/vm/mach_vm_dep.c1
-rw-r--r--usr/src/uts/sun4v/vm/mach_vm_dep.c1
19 files changed, 142 insertions, 182 deletions
diff --git a/usr/src/uts/common/os/mem_cage.c b/usr/src/uts/common/os/mem_cage.c
index 27d7bc25bc..1d486bfcb1 100644
--- a/usr/src/uts/common/os/mem_cage.c
+++ b/usr/src/uts/common/os/mem_cage.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -227,6 +227,7 @@ static struct kcage_glist *kcage_current_glist;
* until that cage has somewhere to go. This is not currently a problem
* as early kmem_alloc's use BOP_ALLOC instead of page_create_va.
*/
+static vmem_t *kcage_arena;
static struct kcage_glist kcage_glist_firstfree;
static struct kcage_glist *kcage_glist_freelist = &kcage_glist_firstfree;
@@ -238,6 +239,9 @@ static int kcage_glist_delete(pfn_t, pfn_t, struct kcage_glist **);
static void kcage_cageout(void);
static int kcage_invalidate_page(page_t *, pgcnt_t *);
static int kcage_setnoreloc_pages(page_t *, se_t);
+static int kcage_range_add_internal(pfn_t base, pgcnt_t npgs, kcage_dir_t);
+static void kcage_init(pgcnt_t preferred_size);
+static int kcage_range_delete_internal(pfn_t base, pgcnt_t npgs);
/*
* Kernel Memory Cage counters and thresholds.
@@ -269,38 +273,14 @@ static int kcage_kstat_snapshot(kstat_t *ksp, void *buf, int rw);
/*
* Startup and Dynamic Reconfiguration interfaces.
- * kcage_range_lock()
- * kcage_range_unlock()
- * kcage_range_islocked()
* kcage_range_add()
* kcage_range_del()
- * kcage_init()
+ * kcage_range_delete_post_mem_del()
+ * kcage_range_init()
* kcage_set_thresholds()
*/
/*
- * Called outside of this file to add/remove from the list,
- * therefore, it takes a writer lock
- */
-void
-kcage_range_lock(void)
-{
- rw_enter(&kcage_range_rwlock, RW_WRITER);
-}
-
-void
-kcage_range_unlock(void)
-{
- rw_exit(&kcage_range_rwlock);
-}
-
-int
-kcage_range_islocked(void)
-{
- return (rw_lock_held(&kcage_range_rwlock));
-}
-
-/*
* Called from page_get_contig_pages to get the approximate kcage pfn range
* for exclusion from search for contiguous pages. This routine is called
* without kcage_range lock (kcage routines can call page_get_contig_pages
@@ -396,42 +376,50 @@ kcage_next_range(int incage, pfn_t lo, pfn_t hi,
return (0);
}
-int
-kcage_range_init(struct memlist *ml, int decr)
+void
+kcage_range_init(struct memlist *ml, kcage_dir_t d, pgcnt_t preferred_size)
{
int ret = 0;
- ASSERT(kcage_range_islocked());
+ ASSERT(kcage_arena == NULL);
+ kcage_arena = vmem_create("kcage_arena", NULL, 0, sizeof (uint64_t),
+ segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP);
+ ASSERT(kcage_arena != NULL);
- if (decr) {
+ if (d == KCAGE_DOWN) {
while (ml->next != NULL)
ml = ml->next;
}
+ rw_enter(&kcage_range_rwlock, RW_WRITER);
+
while (ml != NULL) {
- ret = kcage_range_add(btop(ml->address), btop(ml->size), decr);
+ ret = kcage_range_add_internal(btop(ml->address),
+ btop(ml->size), d);
if (ret)
- break;
+ panic("kcage_range_add_internal failed: "
+ "ml=0x%x, ret=0x%x\n", ml, ret);
- ml = (decr ? ml->prev : ml->next);
+ ml = (d == KCAGE_DOWN ? ml->prev : ml->next);
}
- return (ret);
+ rw_exit(&kcage_range_rwlock);
+
+ if (ret == 0)
+ kcage_init(preferred_size);
}
/*
* Third arg controls direction of growth: 0: increasing pfns,
* 1: decreasing.
- * Calls to add and delete must be protected by calls to
- * kcage_range_lock() and kcage_range_unlock().
*/
-int
-kcage_range_add(pfn_t base, pgcnt_t npgs, int decr)
+static int
+kcage_range_add_internal(pfn_t base, pgcnt_t npgs, kcage_dir_t d)
{
struct kcage_glist *new, **lpp;
pfn_t lim;
- ASSERT(kcage_range_islocked());
+ ASSERT(rw_write_held(&kcage_range_rwlock));
ASSERT(npgs != 0);
if (npgs == 0)
@@ -450,7 +438,7 @@ kcage_range_add(pfn_t base, pgcnt_t npgs, int decr)
new->base = base;
new->lim = lim;
- new->decr = decr;
+ new->decr = (d == KCAGE_DOWN);
if (new->decr != 0)
new->curr = new->lim;
else
@@ -477,17 +465,27 @@ kcage_range_add(pfn_t base, pgcnt_t npgs, int decr)
return (0);
}
+int
+kcage_range_add(pfn_t base, pgcnt_t npgs, kcage_dir_t d)
+{
+ int ret;
+
+ rw_enter(&kcage_range_rwlock, RW_WRITER);
+ ret = kcage_range_add_internal(base, npgs, d);
+ rw_exit(&kcage_range_rwlock);
+ return (ret);
+}
+
/*
- * Calls to add and delete must be protected by calls to
- * kcage_range_lock() and kcage_range_unlock().
+ * Calls to add and delete must be protected by kcage_range_rwlock
*/
-int
-kcage_range_delete(pfn_t base, pgcnt_t npgs)
+static int
+kcage_range_delete_internal(pfn_t base, pgcnt_t npgs)
{
struct kcage_glist *lp;
pfn_t lim;
- ASSERT(kcage_range_islocked());
+ ASSERT(rw_write_held(&kcage_range_rwlock));
ASSERT(npgs != 0);
if (npgs == 0)
@@ -531,18 +529,28 @@ kcage_range_delete(pfn_t base, pgcnt_t npgs)
return (kcage_glist_delete(base, lim, &kcage_glist));
}
+int
+kcage_range_delete(pfn_t base, pgcnt_t npgs)
+{
+ int ret;
+
+ rw_enter(&kcage_range_rwlock, RW_WRITER);
+ ret = kcage_range_delete_internal(base, npgs);
+ rw_exit(&kcage_range_rwlock);
+ return (ret);
+}
+
/*
- * Calls to add and delete must be protected by calls to
- * kcage_range_lock() and kcage_range_unlock().
+ * Calls to add and delete must be protected by kcage_range_rwlock.
* This routine gets called after successful Solaris memory
* delete operation from DR post memory delete routines.
*/
-int
-kcage_range_delete_post_mem_del(pfn_t base, pgcnt_t npgs)
+static int
+kcage_range_delete_post_mem_del_internal(pfn_t base, pgcnt_t npgs)
{
pfn_t lim;
- ASSERT(kcage_range_islocked());
+ ASSERT(rw_write_held(&kcage_range_rwlock));
ASSERT(npgs != 0);
if (npgs == 0)
@@ -557,9 +565,20 @@ kcage_range_delete_post_mem_del(pfn_t base, pgcnt_t npgs)
return (kcage_glist_delete(base, lim, &kcage_glist));
}
+int
+kcage_range_delete_post_mem_del(pfn_t base, pgcnt_t npgs)
+{
+ int ret;
+
+ rw_enter(&kcage_range_rwlock, RW_WRITER);
+ ret = kcage_range_delete_post_mem_del_internal(base, npgs);
+ rw_exit(&kcage_range_rwlock);
+ return (ret);
+}
+
/*
* No locking is required here as the whole operation is covered
- * by the kcage_range_lock().
+ * by kcage_range_rwlock writer lock.
*/
static struct kcage_glist *
kcage_glist_alloc(void)
@@ -568,10 +587,13 @@ kcage_glist_alloc(void)
if ((new = kcage_glist_freelist) != NULL) {
kcage_glist_freelist = new->next;
- bzero(new, sizeof (*new));
} else {
- new = kmem_zalloc(sizeof (struct kcage_glist), KM_NOSLEEP);
+ new = vmem_alloc(kcage_arena, sizeof (*new), VM_NOSLEEP);
}
+
+ if (new != NULL)
+ bzero(new, sizeof (*new));
+
return (new);
}
@@ -666,30 +688,31 @@ kcage_glist_delete(pfn_t base, pfn_t lim, struct kcage_glist **lpp)
}
/*
- * The caller of kcage_get_pfn must hold the kcage_range_lock to make
- * sure that there are no concurrent calls. The same lock
- * must be obtained for range add and delete by calling
- * kcage_range_lock() and kcage_range_unlock().
+ * If lockit is 1, kcage_get_pfn holds the
+ * reader lock for kcage_range_rwlock.
+ * Changes to lp->curr can cause race conditions, but
+ * they are handled by higher level code (see kcage_next_range.)
*/
static pfn_t
-kcage_get_pfn(void)
+kcage_get_pfn(int lockit)
{
struct kcage_glist *lp;
- pfn_t pfn;
+ pfn_t pfn = PFN_INVALID;
- ASSERT(kcage_range_islocked());
+ if (lockit && !rw_tryenter(&kcage_range_rwlock, RW_READER))
+ return (pfn);
lp = kcage_current_glist;
while (lp != NULL) {
if (lp->decr != 0) {
if (lp->curr != lp->base) {
pfn = --lp->curr;
- return (pfn);
+ break;
}
} else {
if (lp->curr != lp->lim) {
pfn = lp->curr++;
- return (pfn);
+ break;
}
}
@@ -698,7 +721,9 @@ kcage_get_pfn(void)
kcage_current_glist = lp;
}
- return (PFN_INVALID);
+ if (lockit)
+ rw_exit(&kcage_range_rwlock);
+ return (pfn);
}
/*
@@ -720,7 +745,7 @@ kcage_get_pfn(void)
* list is not installed or if none of the PFNs in the installed list have
* been allocated to the cage. In otherwords, there is no cage.
*
- * Caller need not hold kcage_range_lock while calling this function
+ * Caller need not hold kcage_range_rwlock while calling this function
* as the front part of the list is static - pages never come out of
* the cage.
*
@@ -872,7 +897,7 @@ kcage_recalc_preferred_size(pgcnt_t preferred_size)
* The size of the cage is determined by the argument preferred_size.
* or the actual amount of memory, whichever is smaller.
*/
-void
+static void
kcage_init(pgcnt_t preferred_size)
{
pgcnt_t wanted;
@@ -884,7 +909,6 @@ kcage_init(pgcnt_t preferred_size)
extern void page_list_noreloc_startup(page_t *);
ASSERT(!kcage_on);
- ASSERT(kcage_range_islocked());
/* increase preferred cage size for lp for kmem */
preferred_size = kcage_recalc_preferred_size(preferred_size);
@@ -925,7 +949,7 @@ kcage_init(pgcnt_t preferred_size)
kcage_freemem = 0;
pfn = PFN_INVALID; /* prime for alignment test */
while (wanted != 0) {
- if ((pfn = kcage_get_pfn()) == PFN_INVALID)
+ if ((pfn = kcage_get_pfn(0)) == PFN_INVALID)
break;
if ((pp = page_numtopp_nolock(pfn)) != NULL) {
@@ -997,7 +1021,6 @@ kcage_init(pgcnt_t preferred_size)
ksp->ks_lock = &kcage_kstat_lock; /* XXX - not really needed */
kstat_install(ksp);
}
-
}
static int
@@ -1010,7 +1033,7 @@ kcage_kstat_update(kstat_t *ksp, int rw)
return (EACCES);
count = 0;
- kcage_range_lock();
+ rw_enter(&kcage_range_rwlock, RW_WRITER);
for (lp = kcage_glist; lp != NULL; lp = lp->next) {
if (lp->decr) {
if (lp->curr != lp->lim) {
@@ -1022,7 +1045,7 @@ kcage_kstat_update(kstat_t *ksp, int rw)
}
}
}
- kcage_range_unlock();
+ rw_exit(&kcage_range_rwlock);
ksp->ks_ndata = count;
ksp->ks_data_size = count * 2 * sizeof (uint64_t);
@@ -1045,7 +1068,7 @@ kcage_kstat_snapshot(kstat_t *ksp, void *buf, int rw)
ksp->ks_snaptime = gethrtime();
kspmem = (struct memunit *)buf;
- kcage_range_lock();
+ rw_enter(&kcage_range_rwlock, RW_WRITER);
for (lp = kcage_glist; lp != NULL; lp = lp->next, kspmem++) {
if ((caddr_t)kspmem >= (caddr_t)buf + ksp->ks_data_size)
break;
@@ -1062,7 +1085,7 @@ kcage_kstat_snapshot(kstat_t *ksp, void *buf, int rw)
}
}
}
- kcage_range_unlock();
+ rw_exit(&kcage_range_rwlock);
return (0);
}
@@ -1452,13 +1475,6 @@ kcage_expand()
return (0);
}
- /*
- * Try to get the range list reader lock. If the lock is already
- * held, then don't get stuck here waiting for it.
- */
- if (!rw_tryenter(&kcage_range_rwlock, RW_READER))
- return (0);
-
KCAGE_STAT_INCR(ke_calls);
KCAGE_STAT_SET_SCAN(ke_wanted, (uint_t)wanted);
@@ -1468,7 +1484,7 @@ kcage_expand()
n = 0; /* number of pages PP_SETNORELOC'd */
nf = 0; /* number of those actually free */
while (kcage_on && nf < wanted) {
- pfn = kcage_get_pfn();
+ pfn = kcage_get_pfn(1);
if (pfn == PFN_INVALID) { /* eek! no where to grow */
KCAGE_STAT_INCR(ke_nopfn);
goto terminate;
@@ -1490,12 +1506,6 @@ kcage_expand()
continue;
}
- /*
- * NORELOC is only set at boot-time or by this routine
- * under the kcage_range_rwlock lock which is currently
- * held. This means we can do a fast check here before
- * locking the page in kcage_assimilate_page.
- */
if (PP_ISNORELOC(pp)) {
KCAGE_STAT_INCR(ke_isnoreloc);
continue;
@@ -1540,7 +1550,6 @@ kcage_expand()
*/
terminate:
- kcage_range_unlock();
return (did_something);
}
diff --git a/usr/src/uts/common/sys/mem_cage.h b/usr/src/uts/common/sys/mem_cage.h
index 2a56aff22e..b83316a097 100644
--- a/usr/src/uts/common/sys/mem_cage.h
+++ b/usr/src/uts/common/sys/mem_cage.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -59,17 +59,17 @@ extern void kcage_freemem_add(pgcnt_t);
extern void kcage_freemem_sub(pgcnt_t);
extern int kcage_create_throttle(pgcnt_t, int);
-/* Third arg controls direction of growth: 0: increasing pfns, 1: decreasing. */
-extern void kcage_range_lock(void);
-extern void kcage_range_unlock(void);
+/*
+ * Control direction of growth: 0: increasing pfns, 1: decreasing.
+ */
+typedef enum {KCAGE_UP, KCAGE_DOWN} kcage_dir_t;
+extern void kcage_range_init(struct memlist *, kcage_dir_t, pgcnt_t);
+extern int kcage_range_add(pfn_t, pgcnt_t, kcage_dir_t);
+
extern int kcage_current_pfn(pfn_t *);
-extern int kcage_range_islocked(void);
-extern int kcage_range_init(struct memlist *, int);
-extern int kcage_range_add(pfn_t, pgcnt_t, int);
extern int kcage_range_delete(pfn_t, pgcnt_t);
extern int kcage_range_delete_post_mem_del(pfn_t, pgcnt_t);
-extern void kcage_init(pgcnt_t);
extern void kcage_recalc_thresholds(void);
/* Called from vm_pageout.c */
diff --git a/usr/src/uts/sfmmu/vm/hat_sfmmu.c b/usr/src/uts/sfmmu/vm/hat_sfmmu.c
index a01e6d4122..78f4f9a9d1 100644
--- a/usr/src/uts/sfmmu/vm/hat_sfmmu.c
+++ b/usr/src/uts/sfmmu/vm/hat_sfmmu.c
@@ -1761,12 +1761,18 @@ int
hat_dup(struct hat *hat, struct hat *newhat, caddr_t addr, size_t len,
uint_t flag)
{
+ extern uint_t get_color_start(struct as *);
+
ASSERT(hat->sfmmu_xhat_provider == NULL);
ASSERT((flag == 0) || (flag == HAT_DUP_ALL) || (flag == HAT_DUP_COW));
if (flag == HAT_DUP_COW) {
panic("hat_dup: HAT_DUP_COW not supported");
}
+ if (flag == HAT_DUP_ALL && consistent_coloring == 0 &&
+ update_proc_pgcolorbase_after_fork != 0) {
+ hat->sfmmu_clrbin = get_color_start(hat->sfmmu_as);
+ }
return (0);
}
diff --git a/usr/src/uts/sun4/os/startup.c b/usr/src/uts/sun4/os/startup.c
index 26752b4b5d..7e4841f8c3 100644
--- a/usr/src/uts/sun4/os/startup.c
+++ b/usr/src/uts/sun4/os/startup.c
@@ -590,11 +590,7 @@ setup_cage_params(void)
if (kernel_cage_enable == 0) {
return;
}
- kcage_range_lock();
- if (kcage_range_init(phys_avail, 1) == 0) {
- kcage_init(total_pages / 256);
- }
- kcage_range_unlock();
+ kcage_range_init(phys_avail, KCAGE_DOWN, total_pages / 256);
if (kcage_on) {
cmn_err(CE_NOTE, "!Kernel Cage is ENABLED");
diff --git a/usr/src/uts/sun4/vm/vm_dep.h b/usr/src/uts/sun4/vm/vm_dep.h
index aa0c0c0163..da9f35b778 100644
--- a/usr/src/uts/sun4/vm/vm_dep.h
+++ b/usr/src/uts/sun4/vm/vm_dep.h
@@ -419,6 +419,7 @@ extern int ecache_alignsize;
#define L2CACHE_ALIGN ecache_alignsize
#define L2CACHE_ALIGN_MAX 512
+extern int update_proc_pgcolorbase_after_fork;
extern int consistent_coloring;
extern uint_t vac_colors_mask;
extern int vac_size;
diff --git a/usr/src/uts/sun4u/io/sbd_mem.c b/usr/src/uts/sun4u/io/sbd_mem.c
index add43318dc..85d76f3381 100644
--- a/usr/src/uts/sun4u/io/sbd_mem.c
+++ b/usr/src/uts/sun4u/io/sbd_mem.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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -518,9 +517,7 @@ sbd_add_memory_spans(sbd_board_t *sbp, struct memlist *ml)
continue;
}
- kcage_range_lock();
- rv = kcage_range_add(base, npgs, 1);
- kcage_range_unlock();
+ rv = kcage_range_add(base, npgs, KCAGE_DOWN);
if (rv != 0)
continue;
}
@@ -2354,9 +2351,7 @@ error:
break;
}
- kcage_range_lock();
- err = kcage_range_add(base, npgs, 1);
- kcage_range_unlock();
+ err = kcage_range_add(base, npgs, KCAGE_DOWN);
if (err != 0) {
cmn_err(CE_WARN,
"%s: kcage_range_add fail %d", f, err);
diff --git a/usr/src/uts/sun4u/lw8/os/lw8_platmod.c b/usr/src/uts/sun4u/lw8/os/lw8_platmod.c
index 5d298cccdb..aeb275346a 100644
--- a/usr/src/uts/sun4u/lw8/os/lw8_platmod.c
+++ b/usr/src/uts/sun4u/lw8/os/lw8_platmod.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -268,7 +268,6 @@ set_platform_cage_params(void)
{
extern pgcnt_t total_pages;
extern struct memlist *phys_avail;
- int ret;
if (kernel_cage_enable) {
pgcnt_t preferred_cage_size;
@@ -279,15 +278,11 @@ set_platform_cage_params(void)
if (serengeti_cage_size_limit)
preferred_cage_size = serengeti_cage_size_limit;
#endif
- kcage_range_lock();
/*
* Post copies obp into the lowest slice. This requires the
* cage to grow upwards
*/
- ret = kcage_range_init(phys_avail, 0);
- if (ret == 0)
- kcage_init(preferred_cage_size);
- kcage_range_unlock();
+ kcage_range_init(phys_avail, KCAGE_UP, preferred_cage_size);
}
/* Only note when the cage is off since it should always be on. */
diff --git a/usr/src/uts/sun4u/opl/io/drmach.c b/usr/src/uts/sun4u/opl/io/drmach.c
index 5b1d23e6d4..50632f4917 100644
--- a/usr/src/uts/sun4u/opl/io/drmach.c
+++ b/usr/src/uts/sun4u/opl/io/drmach.c
@@ -2283,9 +2283,7 @@ drmach_mem_add_span(drmachid_t id, uint64_t basepa, uint64_t size)
if (!DRMACH_IS_MEM_ID(id))
return (drerr_new(0, EOPL_INAPPROP, NULL));
- kcage_range_lock();
- rv = kcage_range_add(basepfn, npages, 1);
- kcage_range_unlock();
+ rv = kcage_range_add(basepfn, npages, KCAGE_DOWN);
if (rv == ENOMEM) {
cmn_err(CE_WARN, "%ld megabytes not available to kernel cage",
(size == 0 ? 0 : size / MBYTE));
@@ -2315,9 +2313,7 @@ drmach_mem_del_span(drmachid_t id, uint64_t basepa, uint64_t size)
return (drerr_new(0, EOPL_INAPPROP, NULL));
if (size > 0) {
- kcage_range_lock();
rv = kcage_range_delete_post_mem_del(basepfn, npages);
- kcage_range_unlock();
if (rv != 0) {
cmn_err(CE_WARN,
"unexpected kcage_range_delete_post_mem_del"
diff --git a/usr/src/uts/sun4u/opl/os/opl.c b/usr/src/uts/sun4u/opl/os/opl.c
index 0a544bf629..c13871d573 100644
--- a/usr/src/uts/sun4u/opl/os/opl.c
+++ b/usr/src/uts/sun4u/opl/os/opl.c
@@ -337,7 +337,6 @@ set_platform_cage_params(void)
extern pgcnt_t total_pages;
extern struct memlist *phys_avail;
struct memlist *ml, *tml;
- int ret;
if (kernel_cage_enable) {
pgcnt_t preferred_cage_size;
@@ -347,7 +346,6 @@ set_platform_cage_params(void)
ml = opl_memlist_per_board(phys_avail);
- kcage_range_lock();
/*
* Note: we are assuming that post has load the
* whole show in to the high end of memory. Having
@@ -355,7 +353,7 @@ set_platform_cage_params(void)
* the glist and arrange for the cage to grow
* downward (descending pfns).
*/
- ret = kcage_range_init(ml, 1);
+ kcage_range_init(ml, KCAGE_DOWN, preferred_cage_size);
/* free the memlist */
do {
@@ -363,10 +361,6 @@ set_platform_cage_params(void)
kmem_free(ml, sizeof (struct memlist));
ml = tml;
} while (ml != NULL);
-
- if (ret == 0)
- kcage_init(preferred_cage_size);
- kcage_range_unlock();
}
if (kcage_on)
diff --git a/usr/src/uts/sun4u/serengeti/io/sbdp_mem.c b/usr/src/uts/sun4u/serengeti/io/sbdp_mem.c
index a11ad815a5..f78bf49e74 100644
--- a/usr/src/uts/sun4u/serengeti/io/sbdp_mem.c
+++ b/usr/src/uts/sun4u/serengeti/io/sbdp_mem.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1634,9 +1634,7 @@ sbdp_mem_del_span(sbdp_handle_t *hp, uint64_t address, uint64_t size)
if (size > 0) {
int rv;
- kcage_range_lock();
rv = kcage_range_delete_post_mem_del(basepfn, npages);
- kcage_range_unlock();
if (rv != 0) {
cmn_err(CE_WARN,
"unexpected kcage_range_delete_post_mem_del"
diff --git a/usr/src/uts/sun4u/serengeti/os/serengeti.c b/usr/src/uts/sun4u/serengeti/os/serengeti.c
index cafcd22c45..ce9e95e669 100644
--- a/usr/src/uts/sun4u/serengeti/os/serengeti.c
+++ b/usr/src/uts/sun4u/serengeti/os/serengeti.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -261,7 +261,6 @@ set_platform_cage_params(void)
{
extern pgcnt_t total_pages;
extern struct memlist *phys_avail;
- int ret;
if (kernel_cage_enable) {
pgcnt_t preferred_cage_size;
@@ -272,15 +271,11 @@ set_platform_cage_params(void)
if (serengeti_cage_size_limit)
preferred_cage_size = serengeti_cage_size_limit;
#endif
- kcage_range_lock();
/*
* Post copies obp into the lowest slice. This requires the
* cage to grow upwards
*/
- ret = kcage_range_init(phys_avail, 0);
- if (ret == 0)
- kcage_init(preferred_cage_size);
- kcage_range_unlock();
+ kcage_range_init(phys_avail, KCAGE_UP, preferred_cage_size);
}
/* Only note when the cage is off since it should always be on. */
diff --git a/usr/src/uts/sun4u/starcat/io/drmach.c b/usr/src/uts/sun4u/starcat/io/drmach.c
index 63d3b9f855..9cabee2e94 100644
--- a/usr/src/uts/sun4u/starcat/io/drmach.c
+++ b/usr/src/uts/sun4u/starcat/io/drmach.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -6417,9 +6417,7 @@ drmach_mem_add_span(drmachid_t id, uint64_t basepa, uint64_t size)
if (!DRMACH_IS_MEM_ID(id))
return (drerr_new(0, ESTC_INAPPROP, NULL));
- kcage_range_lock();
- rv = kcage_range_add(basepfn, npages, 1);
- kcage_range_unlock();
+ rv = kcage_range_add(basepfn, npages, KCAGE_DOWN);
if (rv == ENOMEM) {
cmn_err(CE_WARN, "%lu megabytes not available"
" to kernel cage", size >> 20);
@@ -6445,9 +6443,7 @@ drmach_mem_del_span(drmachid_t id, uint64_t basepa, uint64_t size)
return (drerr_new(0, ESTC_INAPPROP, NULL));
if (size > 0) {
- kcage_range_lock();
rv = kcage_range_delete_post_mem_del(basepfn, npages);
- kcage_range_unlock();
if (rv != 0) {
cmn_err(CE_WARN,
"unexpected kcage_range_delete_post_mem_del"
diff --git a/usr/src/uts/sun4u/starcat/os/starcat.c b/usr/src/uts/sun4u/starcat/os/starcat.c
index 4d4edc08cb..34ad7a8068 100644
--- a/usr/src/uts/sun4u/starcat/os/starcat.c
+++ b/usr/src/uts/sun4u/starcat/os/starcat.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -196,7 +196,6 @@ set_platform_cage_params(void)
{
extern pgcnt_t total_pages;
extern struct memlist *phys_avail;
- int ret;
if (kernel_cage_enable) {
pgcnt_t preferred_cage_size;
@@ -208,7 +207,6 @@ set_platform_cage_params(void)
if (starcat_cage_size_limit)
preferred_cage_size = starcat_cage_size_limit;
#endif
- kcage_range_lock();
/*
* Note: we are assuming that post has load the
* whole show in to the high end of memory. Having
@@ -216,10 +214,7 @@ set_platform_cage_params(void)
* the glist and arrange for the cage to grow
* downward (descending pfns).
*/
- ret = kcage_range_init(phys_avail, 1);
- if (ret == 0)
- kcage_init(preferred_cage_size);
- kcage_range_unlock();
+ kcage_range_init(phys_avail, KCAGE_DOWN, preferred_cage_size);
}
if (kcage_on)
diff --git a/usr/src/uts/sun4u/starfire/io/drmach.c b/usr/src/uts/sun4u/starfire/io/drmach.c
index f8c468ed2d..a0f0bb8afa 100644
--- a/usr/src/uts/sun4u/starfire/io/drmach.c
+++ b/usr/src/uts/sun4u/starfire/io/drmach.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2952,9 +2952,7 @@ drmach_mem_add_span(drmachid_t id, uint64_t basepa, uint64_t size)
if (!DRMACH_IS_MEM_ID(id))
return (drerr_new(0, ESTF_INAPPROP, NULL));
- kcage_range_lock();
- rv = kcage_range_add(basepfn, npages, 1);
- kcage_range_unlock();
+ rv = kcage_range_add(basepfn, npages, KCAGE_DOWN);
if (rv == ENOMEM) {
cmn_err(CE_WARN, "%ld megabytes not available to kernel cage",
(size == 0 ? 0 : size / MBYTE));
@@ -2999,9 +2997,7 @@ drmach_mem_del_span(drmachid_t id, uint64_t basepa, uint64_t size)
}
if (size > 0) {
- kcage_range_lock();
rv = kcage_range_delete_post_mem_del(basepfn, npages);
- kcage_range_unlock();
if (rv != 0) {
cmn_err(CE_WARN,
"unexpected kcage_range_delete_post_mem_del"
diff --git a/usr/src/uts/sun4u/starfire/os/starfire.c b/usr/src/uts/sun4u/starfire/os/starfire.c
index 1c81ab87ff..4bd49fc9f0 100644
--- a/usr/src/uts/sun4u/starfire/os/starfire.c
+++ b/usr/src/uts/sun4u/starfire/os/starfire.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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -147,7 +146,6 @@ set_platform_cage_params(void)
{
extern pgcnt_t total_pages;
extern struct memlist *phys_avail;
- int ret;
if (kernel_cage_enable) {
pgcnt_t preferred_cage_size;
@@ -159,7 +157,6 @@ set_platform_cage_params(void)
if (starfire_cage_size_limit)
preferred_cage_size = starfire_cage_size_limit;
#endif
- kcage_range_lock();
/*
* Note: we are assuming that post has load the
* whole show in to the high end of memory. Having
@@ -167,10 +164,7 @@ set_platform_cage_params(void)
* the glist and arrange for the cage to grow
* downward (descending pfns).
*/
- ret = kcage_range_init(phys_avail, 1);
- if (ret == 0)
- kcage_init(preferred_cage_size);
- kcage_range_unlock();
+ kcage_range_init(phys_avail, KCAGE_DOWN, preferred_cage_size);
}
if (kcage_on)
diff --git a/usr/src/uts/sun4u/sunfire/io/ac_add.c b/usr/src/uts/sun4u/sunfire/io/ac_add.c
index b8379aaa6f..d97cd15c9b 100644
--- a/usr/src/uts/sun4u/sunfire/io/ac_add.c
+++ b/usr/src/uts/sun4u/sunfire/io/ac_add.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -182,14 +182,12 @@ ac_add_bank(struct bd_list *add, ac_cfga_pkt_t *pkt)
/*
* Add the board to the cage growth list.
*/
- kcage_range_lock();
- errs = kcage_range_add(base_pa >> PAGESHIFT, bank_size >> PAGESHIFT, 1);
+ errs = kcage_range_add(btop(base_pa), btop(bank_size), KCAGE_DOWN);
/* TODO: deal with error return. */
if (errs != 0)
cmn_err(CE_NOTE, "ac_add_bank(): board %d, bank %d, "
"kcage_range_add() returned %d",
add->sc.board, pkt->bank, errs);
- kcage_range_unlock();
return (0);
}
diff --git a/usr/src/uts/sun4u/sunfire/io/ac_del.c b/usr/src/uts/sun4u/sunfire/io/ac_del.c
index 1e26e379d6..c0eb6405d8 100644
--- a/usr/src/uts/sun4u/sunfire/io/ac_del.c
+++ b/usr/src/uts/sun4u/sunfire/io/ac_del.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -243,9 +243,7 @@ ac_del_bank_add_span(
/*
* Delete the pages from the cage growth list.
*/
- kcage_range_lock();
ret = kcage_range_delete(base, npgs);
- kcage_range_unlock();
if (ret != 0) {
/* TODO: Should this be a separate error? */
AC_ERR_SET(pkt, AC_ERR_KPM_NONRELOC);
@@ -263,8 +261,7 @@ ac_del_bank_add_span(
* TODO: We should not unconditionally add back
* if we conditionally add at memory add time.
*/
- kcage_range_lock();
- errs = kcage_range_add(base, npgs, 1);
+ errs = kcage_range_add(base, npgs, KCAGE_DOWN);
/* TODO: deal with error return. */
if (errs != 0) {
AC_ERR_SET(pkt, ac_kpm_err_cvt(errs));
@@ -273,7 +270,6 @@ ac_del_bank_add_span(
"kcage_range_add() returned %d",
pkt->softsp->board, pkt->bank, errs);
}
- kcage_range_unlock();
return (EINVAL);
}
return (0);
@@ -307,15 +303,13 @@ ac_del_bank_add_cage(
* TODO: We should not unconditionally add back
* if we conditionally add at memory add time.
*/
- kcage_range_lock();
- errs = kcage_range_add(base, npgs, 1);
+ errs = kcage_range_add(base, npgs, KCAGE_DOWN);
/* TODO: deal with error return. */
if (errs != 0)
cmn_err(CE_NOTE, "ac_del_bank_add_cage(): "
"board %d, bank %d, "
"kcage_range_add() returned %d",
del->sc.board, bank, errs);
- kcage_range_unlock();
}
static int
diff --git a/usr/src/uts/sun4u/vm/mach_vm_dep.c b/usr/src/uts/sun4u/vm/mach_vm_dep.c
index 9cdabd0658..81427b8007 100644
--- a/usr/src/uts/sun4u/vm/mach_vm_dep.c
+++ b/usr/src/uts/sun4u/vm/mach_vm_dep.c
@@ -57,6 +57,7 @@ uint_t page_colors = 0;
uint_t page_colors_mask = 0;
uint_t page_coloring_shift = 0;
int consistent_coloring;
+int update_proc_pgcolorbase_after_fork = 0;
uint_t mmu_page_sizes = DEFAULT_MMU_PAGE_SIZES;
uint_t max_mmu_page_sizes = MMU_PAGE_SIZES;
diff --git a/usr/src/uts/sun4v/vm/mach_vm_dep.c b/usr/src/uts/sun4v/vm/mach_vm_dep.c
index 55ebdb715b..4b9a6f477b 100644
--- a/usr/src/uts/sun4v/vm/mach_vm_dep.c
+++ b/usr/src/uts/sun4v/vm/mach_vm_dep.c
@@ -58,6 +58,7 @@ uint_t page_colors = 0;
uint_t page_colors_mask = 0;
uint_t page_coloring_shift = 0;
int consistent_coloring;
+int update_proc_pgcolorbase_after_fork = 1;
uint_t mmu_page_sizes = MMU_PAGE_SIZES;
uint_t max_mmu_page_sizes = MMU_PAGE_SIZES;