radix_trie: avoid reloading radix node

In the vm_radix:remove loop that searches for the last child, load
that child once, without loading it again after the search is over.
Change KASSERTS from index check to NULL node check.
Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D40721
This commit is contained in:
Doug Moore 2023-06-23 18:47:23 -05:00
parent e23d45187b
commit e8efee297c
2 changed files with 7 additions and 6 deletions

View File

@ -749,7 +749,7 @@ pctrie_remove(struct pctrie *ptree, uint64_t index, pctrie_free_t freefn)
if (tmp != NULL)
break;
}
KASSERT(i != PCTRIE_COUNT,
KASSERT(tmp != NULL,
("%s: invalid node configuration", __func__));
if (parent == NULL)
pctrie_root_store(ptree, tmp, PCTRIE_LOCKED);

View File

@ -773,13 +773,14 @@ vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index)
rnode->rn_count--;
if (rnode->rn_count > 1)
return (m);
for (i = 0; i < VM_RADIX_COUNT; i++)
if (vm_radix_node_load(&rnode->rn_child[i],
LOCKED) != NULL)
for (i = 0; i < VM_RADIX_COUNT; i++) {
tmp = vm_radix_node_load(&rnode->rn_child[i],
LOCKED);
if (tmp != NULL)
break;
KASSERT(i != VM_RADIX_COUNT,
}
KASSERT(tmp != NULL,
("%s: invalid node configuration", __func__));
tmp = vm_radix_node_load(&rnode->rn_child[i], LOCKED);
if (parent == NULL)
vm_radix_root_store(rtree, tmp, LOCKED);
else {