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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 10983
Build 11370: arc lint + arc unit

Event Timeline

kib added inline comments.
sys/vm/vm_kern.c
400

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

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

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

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.