Page MenuHomeFreeBSD

D40764.diff
No OneTemporary

D40764.diff

diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c
--- a/sys/kern/subr_pctrie.c
+++ b/sys/kern/subr_pctrie.c
@@ -228,6 +228,15 @@
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 @@
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 @@
*/
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
--- a/sys/vm/vm_radix.c
+++ b/sys/vm/vm_radix.c
@@ -254,6 +254,15 @@
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 @@
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 @@
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 @@
*/
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 @@
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 @@
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 @@
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;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 5:22 PM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14661991
Default Alt Text
D40764.diff (3 KB)

Event Timeline