Page MenuHomeFreeBSD

Micro-optimize kmem_unback().
ClosedPublic

Authored by markj on Aug 10 2017, 1:27 AM.
Tags
None
Referenced Files
F82038695: D11945.id31912.diff
Wed, Apr 24, 9:30 PM
Unknown Object (File)
Jan 12 2024, 10:04 AM
Unknown Object (File)
Dec 19 2023, 10:52 PM
Unknown Object (File)
Nov 20 2023, 12:54 PM
Unknown Object (File)
Sep 29 2023, 10:13 PM
Unknown Object (File)
Aug 31 2023, 11:39 PM
Unknown Object (File)
Aug 9 2023, 10:44 AM
Unknown Object (File)
Jul 10 2023, 3:14 AM
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.