Page MenuHomeFreeBSD

vm_fault: improve interface for vm_fault_quick_hold_pages()
ClosedPublic

Authored by kib on Aug 26 2025, 3:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 27, 11:05 AM
Unknown Object (File)
Wed, Nov 26, 3:09 PM
Unknown Object (File)
Tue, Nov 25, 8:18 PM
Unknown Object (File)
Mon, Nov 24, 11:43 AM
Unknown Object (File)
Sun, Nov 23, 1:23 PM
Unknown Object (File)
Sat, Nov 22, 5:34 PM
Unknown Object (File)
Sat, Nov 22, 3:45 AM
Unknown Object (File)
Fri, Nov 21, 9:26 AM
Subscribers
None

Details

Summary
Provide (transitional) vm_fault_quick_hold_pages_e() function that
returns distinguishable errors in different failure situation.  Also it
does not panic() on too short array case, but return an error, allowing
sometimes lessen the burden of the check from the caller.

vm_fault_quick_hold_pages() becomes a wrapper, that should be eliminated
eventually.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Aug 26 2025, 3:07 PM
kib created this revision.
markj added inline comments.
sys/vm/vm_fault.c
2034

EINVAL strikes me as more "correct" there.

2035

Or

count = atop(end - addr);
if (count > max_count)
    return (ENOSPC);

to avoid some minor duplication.

This revision is now accepted and ready to land.Aug 26 2025, 4:48 PM
kib marked an inline comment as done.Aug 26 2025, 5:42 PM
kib added inline comments.
sys/vm/vm_fault.c
2035

With count having the int type, I think this would be not correct.

This revision now requires review to proceed.Aug 26 2025, 5:42 PM

Generally I like it, but the name is very long and specific for the logical concept of 'map this into the physical for I/O and keep it there'. But I have no better name, so I'll just grouse because I never could remember the order of the verbs when I was writing the nvme mapping code.

sys/vm/vm_fault.c
2005

s/error is returned/error is returned and any holds are released./ maybe? Either *ALL* the pages are held, or NONE of them are, never some subset (there's code that thinks that a subset can be a possible result in the tree that we should attend to).

2035

Yea, I agree. Logically it makes sense, but in the face of possible overflows, the current conservatism is better.

This revision is now accepted and ready to land.Aug 26 2025, 7:12 PM
sys/vm/vm_fault.c
2114

This needs to be updated too.

kib marked 4 inline comments as done.

Check against EINVAL.
Comment update.

This revision now requires review to proceed.Aug 26 2025, 10:13 PM

thanks for the update.

This revision is now accepted and ready to land.Aug 26 2025, 10:48 PM
In D52165#1191863, @imp wrote:

Generally I like it, but the name is very long and specific for the logical concept of 'map this into the physical for I/O and keep it there'. But I have no better name, so I'll just grouse because I never could remember the order of the verbs when I was writing the nvme mapping code.

I would suggest dropping "quick_" from the name before anyone actually starts using it. The origin of "quick_" dates back to the Dyson-era, and represents the fact that the code tries to lookup the physical page(s) from the pmap before consulting the machine-independent data structures. Today, I don't see that as being important.