Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/pmap.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | |||||
* Data for the pv entry allocation mechanism. | * Data for the pv entry allocation mechanism. | ||||
* Updates to pv_invl_gen are protected by the pv list lock but reads are not. | * Updates to pv_invl_gen are protected by the pv list lock but reads are not. | ||||
*/ | */ | ||||
#ifdef NUMA | #ifdef NUMA | ||||
static __inline int | static __inline int | ||||
pc_to_domain(struct pv_chunk *pc) | pc_to_domain(struct pv_chunk *pc) | ||||
{ | { | ||||
return (_vm_phys_domain(DMAP_TO_PHYS((vm_offset_t)pc))); | return (vm_phys_domain(DMAP_TO_PHYS((vm_offset_t)pc))); | ||||
} | } | ||||
#else | #else | ||||
static __inline int | static __inline int | ||||
pc_to_domain(struct pv_chunk *pc __unused) | pc_to_domain(struct pv_chunk *pc __unused) | ||||
{ | { | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,142 Lines • ▼ Show 20 Lines | pmap_page_array_startup(long pages) | ||||
int domain, i; | int domain, i; | ||||
vm_page_array_size = pages; | vm_page_array_size = pages; | ||||
start = VM_MIN_KERNEL_ADDRESS; | start = VM_MIN_KERNEL_ADDRESS; | ||||
end = start + pages * sizeof(struct vm_page); | end = start + pages * sizeof(struct vm_page); | ||||
for (va = start; va < end; va += NBPDR) { | for (va = start; va < end; va += NBPDR) { | ||||
pfn = first_page + (va - start) / sizeof(struct vm_page); | pfn = first_page + (va - start) / sizeof(struct vm_page); | ||||
domain = _vm_phys_domain(ptoa(pfn)); | domain = vm_phys_domain(ptoa(pfn)); | ||||
pdpe = pmap_pdpe(kernel_pmap, va); | pdpe = pmap_pdpe(kernel_pmap, va); | ||||
if ((*pdpe & X86_PG_V) == 0) { | if ((*pdpe & X86_PG_V) == 0) { | ||||
pa = vm_phys_early_alloc(domain, PAGE_SIZE); | pa = vm_phys_early_alloc(domain, PAGE_SIZE); | ||||
dump_add_page(pa); | dump_add_page(pa); | ||||
pagezero((void *)PHYS_TO_DMAP(pa)); | pagezero((void *)PHYS_TO_DMAP(pa)); | ||||
*pdpe = (pdp_entry_t)(pa | X86_PG_V | X86_PG_RW | | *pdpe = (pdp_entry_t)(pa | X86_PG_V | X86_PG_RW | | ||||
X86_PG_A | X86_PG_M); | X86_PG_A | X86_PG_M); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 519 Lines • ▼ Show 20 Lines | retry: | ||||
PV_STAT(atomic_add_int(&pc_chunk_count, 1)); | PV_STAT(atomic_add_int(&pc_chunk_count, 1)); | ||||
PV_STAT(atomic_add_int(&pc_chunk_allocs, 1)); | PV_STAT(atomic_add_int(&pc_chunk_allocs, 1)); | ||||
dump_add_page(m->phys_addr); | dump_add_page(m->phys_addr); | ||||
pc = (void *)PHYS_TO_DMAP(m->phys_addr); | pc = (void *)PHYS_TO_DMAP(m->phys_addr); | ||||
pc->pc_pmap = pmap; | pc->pc_pmap = pmap; | ||||
pc->pc_map[0] = PC_FREE0 & ~1ul; /* preallocated bit 0 */ | pc->pc_map[0] = PC_FREE0 & ~1ul; /* preallocated bit 0 */ | ||||
pc->pc_map[1] = PC_FREE1; | pc->pc_map[1] = PC_FREE1; | ||||
pc->pc_map[2] = PC_FREE2; | pc->pc_map[2] = PC_FREE2; | ||||
pvc = &pv_chunks[_vm_phys_domain(m->phys_addr)]; | pvc = &pv_chunks[vm_phys_domain(m->phys_addr)]; | ||||
mtx_lock(&pvc->pvc_lock); | mtx_lock(&pvc->pvc_lock); | ||||
TAILQ_INSERT_TAIL(&pvc->pvc_list, pc, pc_lru); | TAILQ_INSERT_TAIL(&pvc->pvc_list, pc, pc_lru); | ||||
mtx_unlock(&pvc->pvc_lock); | mtx_unlock(&pvc->pvc_lock); | ||||
pv = &pc->pc_pventry[0]; | pv = &pc->pc_pventry[0]; | ||||
TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); | TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); | ||||
PV_STAT(atomic_add_long(&pv_entry_count, 1)); | PV_STAT(atomic_add_long(&pv_entry_count, 1)); | ||||
PV_STAT(atomic_add_int(&pv_entry_spare, _NPCPV - 1)); | PV_STAT(atomic_add_int(&pv_entry_spare, _NPCPV - 1)); | ||||
return (pv); | return (pv); | ||||
▲ Show 20 Lines • Show All 6,294 Lines • Show Last 20 Lines |