Page MenuHomeFreeBSD

pctrie: change for vm_radix compatibility
ClosedPublic

Authored by dougm on Aug 9 2023, 5:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 8, 9:46 AM
Unknown Object (File)
Mon, Nov 4, 6:58 PM
Unknown Object (File)
Tue, Oct 29, 6:18 AM
Unknown Object (File)
Oct 21 2024, 1:05 AM
Unknown Object (File)
Oct 21 2024, 1:05 AM
Unknown Object (File)
Oct 21 2024, 1:05 AM
Unknown Object (File)
Oct 21 2024, 1:05 AM
Unknown Object (File)
Oct 21 2024, 1:05 AM
Subscribers

Details

Summary

Restructure parts of pctrie code to make it more compatible with the needs of vm_radix code.

  1. End passing function pointers for memory management.

By breaking insertion into two functions, the call for allocating memory can happen at the top level and be inlined, rather than happening via an function pointer to a memory allocator.

By changing the remove function slightly, freeing of memory, when necessary, can happen at the top level and be inlined.

By turning the reclamation code into two functions, one for starting iteration over to-be-freed nodes and the other continuing it, all the freeing can happen at the top level and be inlined.

  1. Offer a version of remove that does not panic and returns the freed value (or NULL).
  2. Offer a 'replace' operation, to replace one leaf with another that has the same key.

These are three of the roadblocks that prevent code sharing between pctrie and vm_radix code.

Test Plan

I have booted a kernel with these changes in place.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Aug 9 2023, 5:48 PM
dougm created this revision.

Rename 'rtree' to 'ptree' in a few places to keep consistent with pctrie naming conventions.

This revision is now accepted and ready to land.Aug 11 2023, 10:52 AM
sys/kern/subr_pctrie.c
270–272

The function also inserts the value in some cases.

570

This line looks to be too long.

dougm marked 2 inline comments as done.
This revision now requires review to proceed.Aug 11 2023, 4:02 PM

Expose PCTRIE_PAD in the header file, since it exists only to remind users of pctries not to allocate nodes at odd addresses.

Correct a typo in a comment.

Is there any more feedback to offer on this change?

This revision was not accepted when it landed; it landed in state Needs Review.Aug 21 2023, 5:35 PM
This revision was automatically updated to reflect the committed changes.