]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
pctrie: change for vm_radix compatibility
authorDoug Moore <dougm@FreeBSD.org>
Mon, 21 Aug 2023 17:28:51 +0000 (12:28 -0500)
committerDoug Moore <dougm@FreeBSD.org>
Mon, 21 Aug 2023 17:28:51 +0000 (12:28 -0500)
commit3b7ffacdee49f90716cba2bcf8af3fc1971ae031
treeefaf12449bf42941fb074bef7bcd31056f8b9822
parent2c135a2aecdb979e34d651f33b2440372d7529d7
pctrie: change for vm_radix compatibility

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.

2. Offer a version of remove that does not panic and returns the freed
value (or NULL).
3. 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.

Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D41396
sys/kern/subr_pctrie.c
sys/sys/pctrie.h