Page MenuHomeFreeBSD

Micro-optimize kmem_unback().
ClosedPublic

Authored by markj on Aug 10 2017, 1:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 9:21 AM
Unknown Object (File)
Fri, Nov 1, 4:37 PM
Unknown Object (File)
Sep 19 2024, 9:54 PM
Unknown Object (File)
Sep 17 2024, 7:03 AM
Unknown Object (File)
Sep 1 2024, 5:33 PM
Unknown Object (File)
Sep 1 2024, 3:39 PM
Unknown Object (File)
Aug 31 2024, 1:08 AM
Unknown Object (File)
Aug 29 2024, 10:19 PM
Subscribers
None

Details

Summary

As with vm_page_grab_pages(), we can avoid a radix tree lookup on each
page in the range by using the object memq.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
sys/vm/vm_kern.c
400 ↗(On Diff #31842)

for (; pindex++ < end; m = next) {

This revision is now accepted and ready to land.Aug 10 2017, 8:47 AM

To be clear, I'm happy with the concept, and in general eliminating vm_page_lookup() calls inside of loops.

sys/vm/vm_kern.c
390 ↗(On Diff #31842)

Switching from vm_offset_t to vm_pindex_t is a pessimization for 32-bit architectures because it forces them to perform 64-bit arithmetic where before they used 32-bit arithmetic.

401 ↗(On Diff #31842)

Just to be clear, the reason to use vm_page_next() rather than TAILQ_NEXT() here is that it will preserve the current behavior of panic'ing on a NULL pointer dereference if a page is missing.

markj edited edge metadata.
  • Let kmem_unback() use vm_offset_t instead of vm_pindex_t
  • Use a for-loop
This revision now requires review to proceed.Aug 10 2017, 9:10 PM
markj added inline comments.
sys/vm/vm_kern.c
401 ↗(On Diff #31842)

Right. I had originally written

next = TAILQ_NEXT(m, listq);
MPASS(next->pindex == pindex);

and then I remembered that vm_page_next() exists.

This revision is now accepted and ready to land.Aug 10 2017, 11:21 PM
This revision was automatically updated to reflect the committed changes.