Page MenuHomeFreeBSD

vm_pageout: simplify pageout_cluster
ClosedPublic

Authored by dougm on Aug 3 2024, 5:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 8:43 AM
Unknown Object (File)
Wed, Nov 20, 8:37 AM
Unknown Object (File)
Wed, Nov 20, 7:08 AM
Unknown Object (File)
Wed, Nov 20, 7:05 AM
Unknown Object (File)
Thu, Nov 14, 9:22 AM
Unknown Object (File)
Tue, Nov 12, 11:18 PM
Unknown Object (File)
Sat, Nov 9, 7:29 PM
Unknown Object (File)
Wed, Oct 23, 10:39 AM
Subscribers

Details

Summary

Rewrite vm_pageout_cluster to eliminate redundant variables and duplicated code, without changing its functionality.

Remove tests on pindex to check for object boundary conditions, since the page_next and page_prev functions return NULL at the object boundaries. Fix an alignment error that could happen if pindex is aligned, and the first of vm_pageout_page_count flushable pages, and the page at pindex-1 is also flushable.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dougm requested review of this revision.Aug 3 2024, 5:43 AM
dougm created this revision.

For the most part, I am fine with this. Personally, I would prefer to see the NULL check remain in the caller, and I dislike the ok2cluster in vm_pageout_ok2cluster.

Amend to address @alc comments.

Add a comment to explain the ib > pindex test.

sys/vm/vm_pageout.c
393–394

Actually, this test is unnecessary. If ib > pindex, then m->pindex == 0 and vm_page_prev(m) is NULL, so the break will happen anyway.

sys/vm/vm_pageout.c
400–401

The object->size test is unnecessary, since if pindex + is == object->size, vm_page_next(m) will be NULL and terminate the loop.

Better to do that, and set a right_terminated flag before the break.

Then, in the first loop, move the % vm_pageout_page_count test to the top of the loop, but only test it if right_terminated is false.

And replace "ib == 0" with left_terminated ==true, and get rid of ib and is variables.

More changes, to remove needless tests and more variables.

Rewrite the alignment-test expression to make it more readable.

Move the "% vm_pageout_page_count" calculation out of the loop.

Remove a redundant 'num_ends' check from the alignment test.

Undo the last change, since it breaks the case with the first iteration of the forward loop fails.

This revision is now accepted and ready to land.Aug 4 2024, 10:07 AM
This revision was automatically updated to reflect the committed changes.