diff options
author | setje <none@none> | 2008-01-21 10:48:14 -0800 |
---|---|---|
committer | setje <none@none> | 2008-01-21 10:48:14 -0800 |
commit | 5832075c3d504be66f389f3bc46573d7c21ee3fa (patch) | |
tree | 1dcb39b743fd75f45b60f5b57c6148f2c255e834 /usr | |
parent | 6b804b7dd19910467b5d3bdaca7ed2f66cc5ad58 (diff) | |
download | illumos-gate-5832075c3d504be66f389f3bc46573d7c21ee3fa.tar.gz |
6639955 nbs: need to resolve correct way to "hide" ramdisk consumed memory from physmem
6645052 startup_memlist() undercalculates npages
6649655 kernel cage list is missing some of phys_avail segments
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/uts/common/sys/mem_cage.h | 4 | ||||
-rw-r--r-- | usr/src/uts/sun4/os/startup.c | 55 | ||||
-rw-r--r-- | usr/src/uts/sun4u/lw8/os/lw8_platmod.c | 4 | ||||
-rw-r--r-- | usr/src/uts/sun4u/serengeti/os/serengeti.c | 2 |
4 files changed, 56 insertions, 9 deletions
diff --git a/usr/src/uts/common/sys/mem_cage.h b/usr/src/uts/common/sys/mem_cage.h index b83316a097..8ad15d7acc 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 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -83,6 +83,8 @@ extern void kcage_tick(void); extern int kcage_next_range(int incage, pfn_t lo, pfn_t hi, pfn_t *nlo, pfn_t *nhi); +extern kcage_dir_t kcage_startup_dir; + #endif /* _KERNEL */ #ifdef __cplusplus diff --git a/usr/src/uts/sun4/os/startup.c b/usr/src/uts/sun4/os/startup.c index 2974299c1b..d142820fc1 100644 --- a/usr/src/uts/sun4/os/startup.c +++ b/usr/src/uts/sun4/os/startup.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -894,6 +894,7 @@ install_kmem64_tte() */ #define MINMOVE_RAM_MB ((size_t)1900) #define MB_TO_BYTES(mb) ((mb) * 1048576ul) +#define BYTES_TO_MB(b) ((b) / 1048576ul) pgcnt_t tune_npages = (pgcnt_t) (MB_TO_BYTES(MINMOVE_RAM_MB)/ (size_t)MMU_PAGESIZE); @@ -902,6 +903,10 @@ pgcnt_t tune_npages = (pgcnt_t) extern void page_set_colorequiv_arr_cpu(void); extern void page_set_colorequiv_arr(void); +static pgcnt_t ramdisk_npages; +static struct memlist *old_phys_avail; + +kcage_dir_t kcage_startup_dir = KCAGE_DOWN; static void startup_memlist(void) @@ -1138,7 +1143,14 @@ startup_memlist(void) * ... and divy it up */ alloc_base = kmem64_base; - npages -= kmem64_sz / (PAGESIZE + sizeof (struct page)); + + if (kpm_smallpages == 0) { + npages -= kmem64_sz / (PAGESIZE + sizeof (struct page)); + } else { + npages -= kmem64_sz / (PAGESIZE + sizeof (struct page) + + sizeof (kpm_spage_t)); + } + pp_base = (page_t *)alloc_base; pp_sz = npages * sizeof (struct page); alloc_base += pp_sz; @@ -1216,8 +1228,10 @@ startup_memlist(void) * to the size of the ramdisk (in Kb) in /etc/system at the * time the miniroot archive is constructed. */ - if (root_is_ramdisk == B_TRUE) - physmem -= (ramdisk_size * 1024) / PAGESIZE; + if (root_is_ramdisk == B_TRUE) { + ramdisk_npages = (ramdisk_size * 1024) / PAGESIZE; + physmem -= ramdisk_npages; + } if (kpm_enable && (ndata_alloc_kpm(&ndata, kpm_npages) != 0)) cmn_err(CE_PANIC, "no more nucleus memory after kpm alloc"); @@ -1665,9 +1679,30 @@ startup_fixup_physavail(void) sync_memlists(phys_avail, cur); ASSERT(phys_avail != NULL); - memlist_free_list(phys_avail); + + old_phys_avail = phys_avail; phys_avail = cur; +} +void +update_kcage_ranges(uint64_t addr, uint64_t len) +{ + pfn_t base = btop(addr); + pgcnt_t num = btop(len); + int rv; + + rv = kcage_range_add(base, num, kcage_startup_dir); + + if (rv == ENOMEM) { + cmn_err(CE_WARN, "%ld megabytes not available to kernel cage", + (len == 0 ? 0 : BYTES_TO_MB(len))); + } else if (rv != 0) { + /* catch this in debug kernels */ + ASSERT(0); + + cmn_err(CE_WARN, "unexpected kcage_range_add" + " return value %d", rv); + } } static void @@ -1726,6 +1761,12 @@ startup_vm(void) */ kvm_init(); + ASSERT(old_phys_avail != NULL && phys_avail != NULL); + if (kernel_cage_enable) { + diff_memlists(phys_avail, old_phys_avail, update_kcage_ranges); + } + memlist_free_list(old_phys_avail); + /* * If the following is true, someone has patched * phsymem to be less than the number of pages that @@ -1736,7 +1777,7 @@ startup_vm(void) * by the size of the memory used to hold page structures * for the non-used pages. */ - if (physmem < npages) { + if (physmem + ramdisk_npages < npages) { pgcnt_t diff, off; struct page *pp; struct seg kseg; @@ -1744,7 +1785,7 @@ startup_vm(void) cmn_err(CE_WARN, "limiting physmem to %ld pages", physmem); off = 0; - diff = npages - physmem; + diff = npages - (physmem + ramdisk_npages); diff -= mmu_btopr(diff * sizeof (struct page)); kseg.s_as = &kas; while (diff--) { diff --git a/usr/src/uts/sun4u/lw8/os/lw8_platmod.c b/usr/src/uts/sun4u/lw8/os/lw8_platmod.c index 70442879c1..d7159e9f37 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 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -285,6 +285,8 @@ set_platform_cage_params(void) kcage_range_init(phys_avail, KCAGE_UP, preferred_cage_size); } + kcage_startup_dir = KCAGE_UP; + /* Only note when the cage is off since it should always be on. */ if (!kcage_on) cmn_err(CE_NOTE, "!DR Kernel Cage is DISABLED"); diff --git a/usr/src/uts/sun4u/serengeti/os/serengeti.c b/usr/src/uts/sun4u/serengeti/os/serengeti.c index fae7be521a..bc2e6e2a6d 100644 --- a/usr/src/uts/sun4u/serengeti/os/serengeti.c +++ b/usr/src/uts/sun4u/serengeti/os/serengeti.c @@ -278,6 +278,8 @@ set_platform_cage_params(void) kcage_range_init(phys_avail, KCAGE_UP, preferred_cage_size); } + kcage_startup_dir = KCAGE_UP; + /* Only note when the cage is off since it should always be on. */ if (!kcage_on) cmn_err(CE_NOTE, "!DR Kernel Cage is DISABLED"); |