Page MenuHomeFreeBSD

Move a handful of stack variables into the faultstate.
ClosedPublic

Authored by jeff on Jan 21 2020, 7:41 PM.

Details

Summary

This allows me to split off more functionality into helper routines. I have an 9 patch series that eventually makes:
vm_fault_lookup(), vm_fault_relookup(), vm_fault_allocate(), vm_fault_getpages(), vm_fault_cow(), etc. This allows me to eliminate gotos and make the control flow more clear. It reduces vm_fault() from ~900loc to ~200loc. I have an idea for sendfile on zfs that will require a custom object fault function and moving these parameters into the fault state makes it easier to override later.

The one downside to this approach is that we have to be very careful about what changes to the state persist across restarts. In particular I notice that retry_prot was modifying fault_type permanently. If a restart happened after this it may be incorrect and we could immediately re-trigger the same fault. I have changed this so that fault_type is reloaded on retry but I would like some confirmation that this is the correct thing to do.

vm_fault_soft_fast also modifies vaddr so I make a local copy.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jeff created this revision.Jan 21 2020, 7:41 PM
jeff edited the summary of this revision. (Show Details)Jan 21 2020, 7:48 PM
jeff added reviewers: alc, dougm, kib, markj.
jeff set the repository for this revision to rS FreeBSD src repository.
kib accepted this revision.Jan 21 2020, 8:55 PM
This revision is now accepted and ready to land.Jan 21 2020, 8:55 PM
markj accepted this revision.Jan 22 2020, 8:14 PM

I think reloading fault_type is right. It looks to me like the same bug fixed by r355469.

sys/vm/vm_fault.c
132 ↗(On Diff #67113)

Missing a tab.

This revision was automatically updated to reflect the committed changes.