From: Martin Pieuchot Subject: fault ahead & page wiring To: tech@openbsd.org Date: Mon, 25 Nov 2024 15:15:48 +0100 When a wired fault occurs, uvm_fault_check() disables looking & faulting neighbor pages. This is done line 702 by setting `narrow' to TRUE. When a fault is "narrow" the kernel only looks at a single page and there is no "fault-ahead". So instead of syncing with NetBSD and using `flt->wired' coherently for the pmap_enter(9) below, assert that such condition is impossible. ok? Index: uvm/uvm_fault.c =================================================================== RCS file: /cvs/src/sys/uvm/uvm_fault.c,v diff -u -p -r1.144 uvm_fault.c --- uvm/uvm_fault.c 25 Nov 2024 13:46:55 -0000 1.144 +++ uvm/uvm_fault.c 25 Nov 2024 14:01:07 -0000 @@ -888,6 +888,9 @@ uvm_fault_upper_lookup(struct uvm_faulti uvm_unlock_pageq(); counters_inc(uvmexp_counters, flt_namap); + /* No fault-ahead when wired. */ + KASSERT(flt->wired == 0); + /* * Since this isn't the page that's actually faulting, * ignore pmap_enter() failures; it's not critical @@ -897,8 +900,7 @@ uvm_fault_upper_lookup(struct uvm_faulti VM_PAGE_TO_PHYS(anon->an_page) | flt->pa_flags, (anon->an_ref > 1) ? (flt->enter_prot & ~PROT_WRITE) : flt->enter_prot, - PMAP_CANFAIL | - (VM_MAPENT_ISWIRED(ufi->entry) ? PMAP_WIRED : 0)); + PMAP_CANFAIL); } } if (flt->npages > 1) @@ -1173,6 +1175,9 @@ uvm_fault_lower_lookup( uvm_unlock_pageq(); counters_inc(uvmexp_counters, flt_nomap); + /* No fault-ahead when wired. */ + KASSERT(flt->wired == 0); + /* * Since this page isn't the page that's * actually faulting, ignore pmap_enter() @@ -1181,9 +1186,7 @@ uvm_fault_lower_lookup( */ (void) pmap_enter(ufi->orig_map->pmap, currva, VM_PAGE_TO_PHYS(pages[lcv]) | flt->pa_flags, - flt->enter_prot & MASK(ufi->entry), - PMAP_CANFAIL | - (flt->wired ? PMAP_WIRED : 0)); + flt->enter_prot & MASK(ufi->entry), PMAP_CANFAIL); /* * NOTE: page can't be PG_WANTED because