Page MenuHomeFreeBSD

Drop duplicate ascending range enqueing
Needs ReviewPublic

Authored by dougm on Jan 16 2022, 7:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 12:57 AM
Unknown Object (File)
Dec 12 2023, 3:17 AM
Unknown Object (File)
Nov 7 2023, 2:29 AM
Unknown Object (File)
Nov 6 2023, 4:47 PM
Unknown Object (File)
Oct 6 2023, 1:23 AM
Unknown Object (File)
Oct 5 2023, 3:45 PM
Unknown Object (File)
Jul 22 2023, 7:38 AM
Unknown Object (File)
Jun 19 2023, 8:38 PM
Subscribers
None
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Two places in vm_phys.c iterate over free blocks of increasing size and put each block in a free list. The first of them is in vm_phys_enq_range; that's all that it does. The second is near the start of vm_phys_enqueue_contig. Replace that second instance with a call to vm_phys_enq_range.

Drop some unnecessary variable updating from vm_phys_enq_range.

Test Plan

A kernel with this change has run successfully for a little while.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Jan 16 2022, 7:27 AM
dougm created this revision.

Avoid passing pointer differences to ffs, fls.

And in a mask to make clear that an int is big enough to hold the essential parts of an address.

Correct error in KASSERT print output.

Reverse the order in which diminishing-sized free blocks are enlisted.

dougm added a reviewer: markj.

Refresh. Move max_order closer to the only (unused) function that uses it.

Rename vm_phys_enq_range to vm_phys_enq_end, since it concerns pages
at the end of an aligned page set. Add vm_phys_enq_beg do to the same
thing, but for pages at the beginning of an aligned page set. Use the new
function in vm_phys_enqueue_contig. Use both functions in vm_phys_unfree_page
instead of the loop that's there now.

Recognize that vm_phys_split_ranges is easily implemented as a call to vm_phys_enq_end with appropriate parameters.

Update comments. Remove gratuitous differences between unfree_page and free_pages regarding 'pa' and masking.

sys/vm/vm_phys.c
759

vm_phys_split_pages() is frequently used, and this reimplementation makes it shorter by replacing a simple, fast, specialized implementation by a more general, costly implementation.

Add a zero-check in unfree_page.

dougm marked an inline comment as done.

Restore vm_phys_split_pages to original form. Modify code to avoid computing the difference between vm_page pointers.

Speed up the search loop in vm_phys_unfree page by iterating only over the 1-bits, where the m_set value changes, and by setting the upper bound on order low enough to stop the loop before pa can be reduced below seg->start.

sys/vm/vm_phys.c
743

It would be useful for the comment to explain how "order" and "oind" relate to the size of the set of pages.

1341

The indentation here is wrong.

dougm marked 2 inline comments as done.

Fix whitespace. Add comment. Put split_pages back where I found it.