git: 9cfed089ac48 - main - radix_trie: clean up overlong lines

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Tue, 27 Jun 2023 17:01:51 UTC
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=9cfed089ac4820b95457818f1aa1bd199535ddca

commit 9cfed089ac4820b95457818f1aa1bd199535ddca
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2023-06-27 16:59:12 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2023-06-27 17:01:33 +0000

    radix_trie: clean up overlong lines
    
    This is purely a cosmetic change. vm_radix.c has lines that reach past
    column 80 and this change cleans that up. The associated changes to
    subr_pctrie.c are just to keep mirroring vm_radix.c.
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D40764
---
 sys/kern/subr_pctrie.c | 13 +++++++++++--
 sys/vm/vm_radix.c      | 31 ++++++++++++++++++++-----------
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c
index d9269bfb3885..b5dee2163a40 100644
--- a/sys/kern/subr_pctrie.c
+++ b/sys/kern/subr_pctrie.c
@@ -228,6 +228,15 @@ pctrie_isleaf(struct pctrie_node *node)
 	return (((uintptr_t)node & PCTRIE_ISLEAF) != 0);
 }
 
+/*
+ * Returns val with leaf bit set.
+ */
+static __inline void *
+pctrie_toleaf(uint64_t *val)
+{
+	return ((void *)((uintptr_t)val | PCTRIE_ISLEAF));
+}
+
 /*
  * Returns the associated val extracted from node.
  */
@@ -249,7 +258,7 @@ pctrie_addval(struct pctrie_node *node, uint64_t index, uint16_t clev,
 
 	slot = pctrie_slot(index, clev);
 	pctrie_node_store(&node->pn_child[slot],
-	    (void *)((uintptr_t)val | PCTRIE_ISLEAF), access);
+	    pctrie_toleaf(val), access);
 }
 
 /*
@@ -356,7 +365,7 @@ pctrie_insert(struct pctrie *ptree, uint64_t *val, pctrie_alloc_t allocfn)
 	 */
 	node = pctrie_root_load(ptree, NULL, PCTRIE_LOCKED);
 	if (node == NULL) {
-		ptree->pt_root = (uintptr_t)val | PCTRIE_ISLEAF;
+		ptree->pt_root = (uintptr_t)pctrie_toleaf(val);
 		return (0);
 	}
 	parentp = (smr_pctnode_t *)&ptree->pt_root;
diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c
index 9c8ba5287d4e..a34de9e6ff92 100644
--- a/sys/vm/vm_radix.c
+++ b/sys/vm/vm_radix.c
@@ -254,6 +254,15 @@ vm_radix_isleaf(struct vm_radix_node *rnode)
 	return (((uintptr_t)rnode & VM_RADIX_ISLEAF) != 0);
 }
 
+/*
+ * Returns page cast to radix node with leaf bit set.
+ */
+static __inline struct vm_radix_node *
+vm_radix_toleaf(vm_page_t page)
+{
+	return ((struct vm_radix_node *)((uintptr_t)page | VM_RADIX_ISLEAF));
+}
+
 /*
  * Returns the associated page extracted from rnode.
  */
@@ -275,7 +284,7 @@ vm_radix_addpage(struct vm_radix_node *rnode, vm_pindex_t index, uint16_t clev,
 
 	slot = vm_radix_slot(index, clev);
 	vm_radix_node_store(&rnode->rn_child[slot],
-	    (struct vm_radix_node *)((uintptr_t)page | VM_RADIX_ISLEAF), access);
+	    vm_radix_toleaf(page), access);
 }
 
 /*
@@ -325,7 +334,8 @@ vm_radix_reclaim_allnodes_int(struct vm_radix_node *rnode)
 	KASSERT(rnode->rn_count <= VM_RADIX_COUNT,
 	    ("vm_radix_reclaim_allnodes_int: bad count in rnode %p", rnode));
 	for (slot = 0; rnode->rn_count != 0; slot++) {
-		child = vm_radix_node_load(&rnode->rn_child[slot], UNSERIALIZED);
+		child = vm_radix_node_load(&rnode->rn_child[slot],
+		    UNSERIALIZED);
 		if (child == NULL)
 			continue;
 		if (!vm_radix_isleaf(child))
@@ -395,7 +405,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page)
 	 */
 	rnode = vm_radix_root_load(rtree, LOCKED);
 	if (rnode == NULL) {
-		rtree->rt_root = (uintptr_t)page | VM_RADIX_ISLEAF;
+		rtree->rt_root = (uintptr_t)vm_radix_toleaf(page);
 		return (0);
 	}
 	parentp = (smrnode_t *)&rtree->rt_root;
@@ -764,7 +774,8 @@ vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index)
 			m = vm_radix_topage(tmp);
 			if (m->pindex != index)
 				return (NULL);
-			vm_radix_node_store(&rnode->rn_child[slot], NULL, LOCKED);
+			vm_radix_node_store(
+			    &rnode->rn_child[slot], NULL, LOCKED);
 			rnode->rn_count--;
 			if (rnode->rn_count > 1)
 				return (m);
@@ -838,7 +849,7 @@ vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage)
 		if (m->pindex != index)
 			panic("%s: original replacing root key not found",
 			    __func__);
-		rtree->rt_root = (uintptr_t)newpage | VM_RADIX_ISLEAF;
+		rtree->rt_root = (uintptr_t)vm_radix_toleaf(newpage);
 		return (m);
 	}
 	for (;;) {
@@ -846,13 +857,11 @@ vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage)
 		tmp = vm_radix_node_load(&rnode->rn_child[slot], LOCKED);
 		if (vm_radix_isleaf(tmp)) {
 			m = vm_radix_topage(tmp);
-			if (m->pindex == index) {
-				vm_radix_node_store(&rnode->rn_child[slot],
-				    (struct vm_radix_node *)((uintptr_t)newpage |
-				    VM_RADIX_ISLEAF), LOCKED);
-				return (m);
-			} else
+			if (m->pindex != index)
 				break;
+			vm_radix_node_store(&rnode->rn_child[slot],
+			    vm_radix_toleaf(newpage), LOCKED);
+			return (m);
 		} else if (tmp == NULL || vm_radix_keybarr(tmp, index))
 			break;
 		rnode = tmp;