Download raw body.
fault ahead & page wiring
On 25/11/24(Mon) 15:15, Martin Pieuchot wrote:
> 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.
I have been asked off-list why this KASSERT() couldn't be reached. This
is because when the fault is "narrow", which is always the case for wired
faults, only a single page is mapped in the memory space. Line 775 we
see:
f (flt->narrow == FALSE) {
[...]
} else {
/* narrow fault! */
nback = nforw = 0;
flt->startva = ufi->orig_rvaddr;
flt->npages = 1;
flt->centeridx = 0;
}
`npages' being 1 and `centeridx' being 0 ensure that the first and only page
found in the iterations below will be skipped.
d
While here use FALSE instead of 0 to be consistent with the rest of the
file.
ok?
Index: uvm/uvm_fault.c
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_fault.c,v
diff -u -p -r1.145 uvm_fault.c
--- uvm/uvm_fault.c 26 Nov 2024 10:10:28 -0000 1.145
+++ uvm/uvm_fault.c 27 Nov 2024 09:50:53 -0000
@@ -893,6 +893,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 == FALSE);
+
/*
* Since this isn't the page that's actually faulting,
* ignore pmap_enter() failures; it's not critical
@@ -902,8 +905,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)
@@ -1167,6 +1169,9 @@ uvm_fault_lower_lookup(
uvm_unlock_pageq();
counters_inc(uvmexp_counters, flt_nomap);
+ /* No fault-ahead when wired. */
+ KASSERT(flt->wired == FALSE);
+
/*
* Since this page isn't the page that's
* actually faulting, ignore pmap_enter()
@@ -1175,9 +1180,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
fault ahead & page wiring