Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_page.c
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
#include <vm/vm_radix.h> | #include <vm/vm_radix.h> | ||||
#include <vm/vm_reserv.h> | #include <vm/vm_reserv.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <vm/uma_int.h> | #include <vm/uma_int.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
extern int uma_startup_count(int); | |||||
extern void uma_startup(void *, int); | |||||
extern void uma_startup1(void); | |||||
/* | /* | ||||
* Associated with page of user-allocatable memory is a | * Associated with page of user-allocatable memory is a | ||||
* page structure. | * page structure. | ||||
*/ | */ | ||||
struct vm_domain vm_dom[MAXMEMDOM]; | struct vm_domain vm_dom[MAXMEMDOM]; | ||||
struct mtx_padalign __exclusive_cache_line vm_page_queue_free_mtx; | struct mtx_padalign __exclusive_cache_line vm_page_queue_free_mtx; | ||||
struct mtx_padalign __exclusive_cache_line pa_lock[PA_LOCK_COUNT]; | struct mtx_padalign __exclusive_cache_line pa_lock[PA_LOCK_COUNT]; | ||||
/* | /* | ||||
* bogus page -- for I/O to/from partially complete buffers, | * bogus page -- for I/O to/from partially complete buffers, | ||||
* or for paging into sparsely invalid regions. | * or for paging into sparsely invalid regions. | ||||
*/ | */ | ||||
vm_page_t bogus_page; | vm_page_t bogus_page; | ||||
vm_page_t vm_page_array; | vm_page_t vm_page_array; | ||||
long vm_page_array_size; | long vm_page_array_size; | ||||
long first_page; | long first_page; | ||||
static int boot_pages = UMA_BOOT_PAGES; | static int boot_pages; | ||||
SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, | SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, | ||||
&boot_pages, 0, | &boot_pages, 0, | ||||
"number of pages allocated for bootstrapping the VM system"); | "number of pages allocated for bootstrapping the VM system"); | ||||
static int pa_tryrelock_restart; | static int pa_tryrelock_restart; | ||||
SYSCTL_INT(_vm, OID_AUTO, tryrelock_restart, CTLFLAG_RD, | SYSCTL_INT(_vm, OID_AUTO, tryrelock_restart, CTLFLAG_RD, | ||||
&pa_tryrelock_restart, 0, "Number of tryrelock restarts"); | &pa_tryrelock_restart, 0, "Number of tryrelock restarts"); | ||||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | vm_page_startup(vm_offset_t vaddr) | ||||
struct vm_domain *vmd; | struct vm_domain *vmd; | ||||
struct vm_phys_seg *seg; | struct vm_phys_seg *seg; | ||||
vm_page_t m; | vm_page_t m; | ||||
char *list, *listend; | char *list, *listend; | ||||
vm_offset_t mapped; | vm_offset_t mapped; | ||||
vm_paddr_t end, high_avail, low_avail, new_end, page_range, size; | vm_paddr_t end, high_avail, low_avail, new_end, page_range, size; | ||||
vm_paddr_t biggestsize, last_pa, pa; | vm_paddr_t biggestsize, last_pa, pa; | ||||
u_long pagecount; | u_long pagecount; | ||||
int biggestone, i, pages_per_zone, segind; | int biggestone, i, segind; | ||||
biggestsize = 0; | biggestsize = 0; | ||||
biggestone = 0; | biggestone = 0; | ||||
vaddr = round_page(vaddr); | vaddr = round_page(vaddr); | ||||
for (i = 0; phys_avail[i + 1]; i += 2) { | for (i = 0; phys_avail[i + 1]; i += 2) { | ||||
phys_avail[i] = round_page(phys_avail[i]); | phys_avail[i] = round_page(phys_avail[i]); | ||||
phys_avail[i + 1] = trunc_page(phys_avail[i + 1]); | phys_avail[i + 1] = trunc_page(phys_avail[i + 1]); | ||||
Show All 13 Lines | vm_page_startup(vm_offset_t vaddr) | ||||
*/ | */ | ||||
mtx_init(&vm_page_queue_free_mtx, "vm page free queue", NULL, MTX_DEF); | mtx_init(&vm_page_queue_free_mtx, "vm page free queue", NULL, MTX_DEF); | ||||
for (i = 0; i < PA_LOCK_COUNT; i++) | for (i = 0; i < PA_LOCK_COUNT; i++) | ||||
mtx_init(&pa_lock[i], "vm page", NULL, MTX_DEF); | mtx_init(&pa_lock[i], "vm page", NULL, MTX_DEF); | ||||
for (i = 0; i < vm_ndomains; i++) | for (i = 0; i < vm_ndomains; i++) | ||||
vm_page_domain_init(&vm_dom[i]); | vm_page_domain_init(&vm_dom[i]); | ||||
/* | /* | ||||
* Almost all of the pages needed for bootstrapping UMA are used | |||||
* for zone structures, so if the number of CPUs results in those | |||||
* structures taking more than one page each, we set aside more pages | |||||
* in proportion to the zone structure size. | |||||
*/ | |||||
pages_per_zone = howmany(sizeof(struct uma_zone) + | |||||
sizeof(struct uma_cache) * (mp_maxid + 1) + | |||||
roundup2(sizeof(struct uma_slab), sizeof(void *)), UMA_SLAB_SIZE); | |||||
if (pages_per_zone > 1) { | |||||
/* Reserve more pages so that we don't run out. */ | |||||
boot_pages = UMA_BOOT_PAGES_ZONES * pages_per_zone; | |||||
} | |||||
/* | |||||
* Allocate memory for use when boot strapping the kernel memory | * Allocate memory for use when boot strapping the kernel memory | ||||
* allocator. | * allocator. | ||||
* | * | ||||
* CTFLAG_RDTUN doesn't work during the early boot process, so we must | * CTFLAG_RDTUN doesn't work during the early boot process, so we must | ||||
* manually fetch the value. | * manually fetch the value. | ||||
*/ | */ | ||||
boot_pages = uma_startup_count(0); | |||||
TUNABLE_INT_FETCH("vm.boot_pages", &boot_pages); | TUNABLE_INT_FETCH("vm.boot_pages", &boot_pages); | ||||
new_end = end - (boot_pages * UMA_SLAB_SIZE); | new_end = end - (boot_pages * UMA_SLAB_SIZE); | ||||
new_end = trunc_page(new_end); | new_end = trunc_page(new_end); | ||||
mapped = pmap_map(&vaddr, new_end, end, | mapped = pmap_map(&vaddr, new_end, end, | ||||
VM_PROT_READ | VM_PROT_WRITE); | VM_PROT_READ | VM_PROT_WRITE); | ||||
bzero((void *)mapped, end - new_end); | bzero((void *)mapped, end - new_end); | ||||
uma_startup((void *)mapped, boot_pages); | uma_startup((void *)mapped, boot_pages); | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | #if VM_NRESERVLEVEL > 0 | ||||
*/ | */ | ||||
vm_reserv_init(); | vm_reserv_init(); | ||||
#endif | #endif | ||||
/* | /* | ||||
* Set an initial domain policy for thread0 so that allocations | * Set an initial domain policy for thread0 so that allocations | ||||
* can work. | * can work. | ||||
*/ | */ | ||||
domainset_zero(); | domainset_zero(); | ||||
/* Announce page availability to UMA. */ | |||||
uma_startup1(); | |||||
return (vaddr); | return (vaddr); | ||||
} | } | ||||
void | void | ||||
vm_page_reference(vm_page_t m) | vm_page_reference(vm_page_t m) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 3,246 Lines • Show Last 20 Lines |