Page MenuHomeFreeBSD

alloc memory from reservation before breaking it
ClosedPublic

Authored by dougm on Dec 24 2021, 5:33 AM.

Details

Summary

vm_reserv_reclaim_contig breaks a reservation with enough free space to satisfy an allocation request and returns the free space to the buddy allocator. Change the function to allocate the request memory from the reservation before breaking it, and returning that memory to the caller. That avoids a second call to the buddy allocator and guarantees successful allocation after breaking the reservation, where that success is not currently guaranteed.

Diff Detail

Repository
rG 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

dougm requested review of this revision.Dec 24 2021, 5:33 AM
dougm created this revision.
sys/vm/vm_page.c
2200

This has to move. If "reclaim" succeeds, you don't want to do this.

Correct page accounting problem.

This revision is now accepted and ready to land.Dec 24 2021, 5:38 PM
sys/vm/vm_page.c
2205–2208

The indentation looks wrong.

2229–2231

As an aside, I find this KASSERT confusing because we disallow VM_ALLOC_WAITOK in the very first KASSERT.

2246

As an aside, I don't see the point of this loop because because we disallow VM_ALLOC_WAITOK in the very first KASSERT. Kostik? Mark?

sys/vm/vm_reserv.c
1390–1397

This could all be performed after the reservation is unlocked.

1402

This can be done before marking the pages as allocated.

dougm marked 3 inline comments as done.

Fix indentation. Move some code out of the scope of locks, as suggested.

This revision now requires review to proceed.Dec 24 2021, 6:37 PM
This revision is now accepted and ready to land.Dec 24 2021, 6:57 PM
This revision was automatically updated to reflect the committed changes.