Page MenuHomeFreeBSD

vm_reserv: Introduce vm_reserv_alloc_npages
Needs ReviewPublic

Authored by bnovkov on Thu, Oct 10, 9:39 PM.
Tags
None
Referenced Files
F101984589: D47048.diff
Wed, Nov 6, 4:33 AM
Unknown Object (File)
Sun, Nov 3, 1:43 PM
Unknown Object (File)
Fri, Nov 1, 3:25 PM
Unknown Object (File)
Wed, Oct 30, 2:50 AM
Unknown Object (File)
Sun, Oct 20, 7:35 AM
Unknown Object (File)
Sat, Oct 19, 6:55 PM
Unknown Object (File)
Sat, Oct 12, 10:02 PM
Unknown Object (File)
Fri, Oct 11, 4:50 PM
Subscribers

Details

Reviewers
markj
alc
kib
Summary

This change adds an interface for allocating multiple pages
from a reservation. It is meant to be used instead of invoking
vm_reserv_alloc_page in a loop.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59894
Build 56779: arc lint + arc unit

Event Timeline

sys/vm/vm_reserv.c
812

How is it possible for the pages to not be physically contiguous? Don't they always come from a single reservation?

Correct comment pointed out by @markj .

sys/vm/vm_reserv.c
812

You are right, after taking a closer look at the reservation lifecycle I see that this cannot happen. I've corrected the comment.
We should also probably break from the allocation loop (and possibly even panic after further checks) instead of continuing when encountering an allocated page.

sys/vm/vm_reserv.c
922

Can this condition actually arise? That would mean that the page is already allocated, which is presumably due to a bug in the caller.

924

If you assume that the returned run of pages is always contiguous, then you don't need to return a pointer to each page. You can simply return a point to the first page in the run, and a count.

Then, it's probably profitable to have a variant of vm_reserv_populate() which adjusts the reservation for count pages starting at index, e.g., using bit_nset() rather than a loop.

sys/vm/vm_reserv.c
922

Other than a caller bug or a vm_reserv bug I don't think so.
I still think it is useful to check for this, but we can have this check along with the approach you described in the other comment.

924

Right, I'll work that assumption into the code. Callers can "unpack" the returned run into individual 0-order pages if need be.

sys/vm/vm_reserv.c
922

It happens due to vm_page_rename()s by, for example, vm_fault(). (I'm incredibly busy this week, when my workload lightens next week, I will elaborate.)

sys/vm/vm_reserv.c
922

Ahh, right, I forgot that it's possible for a page to be allocated from a reservation without belonging to the object that "owns" the reservation.

But, in this case I believe we have to terminate the loop, not continue.

Update diff according to @markj 's suggestion - pages are now allocated using a combination of bit_nset and bit_ffs_at.