tools/testing/radix-tree/test.c
Source file repositories/reference/linux-study-clean/tools/testing/radix-tree/test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/radix-tree/test.c- Extension
.c- Size
- 6412 bytes
- Lines
- 288
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdlib.hassert.hstdio.hlinux/types.hlinux/kernel.hlinux/bitops.htest.h
Detected Declarations
function item_tag_setfunction item_tag_clearfunction item_tag_getfunction item_insertfunction item_sanityfunction item_freefunction item_deletefunction item_free_rcufunction item_delete_rcufunction item_check_presentfunction item_check_absentfunction passedfunction item_full_scanfunction tag_tagged_itemsfunction verify_nodefunction verify_tag_consistencyfunction item_kill_treefunction xas_for_eachfunction tree_verify_min_height
Annotated Snippet
if (slot->tags[tag][i]) {
anyset = 1;
break;
}
}
if (tagged != anyset) {
printf("tag: %u, shift %u, tagged: %d, anyset: %d\n",
tag, slot->shift, tagged, anyset);
for (j = 0; j < RADIX_TREE_MAX_TAGS; j++) {
printf("tag %d: ", j);
for (i = 0; i < RADIX_TREE_TAG_LONGS; i++)
printf("%016lx ", slot->tags[j][i]);
printf("\n");
}
return 1;
}
assert(tagged == anyset);
/* Go for next level */
if (slot->shift > 0) {
for (i = 0; i < RADIX_TREE_MAP_SIZE; i++)
if (slot->slots[i])
if (verify_node(slot->slots[i], tag,
!!test_bit(i, slot->tags[tag]))) {
printf("Failure at off %d\n", i);
for (j = 0; j < RADIX_TREE_MAX_TAGS; j++) {
printf("tag %d: ", j);
for (i = 0; i < RADIX_TREE_TAG_LONGS; i++)
printf("%016lx ", slot->tags[j][i]);
printf("\n");
}
return 1;
}
}
return 0;
}
void verify_tag_consistency(struct radix_tree_root *root, unsigned int tag)
{
struct radix_tree_node *node = root->xa_head;
if (!radix_tree_is_internal_node(node))
return;
verify_node(node, tag, !!root_tag_get(root, tag));
}
void item_kill_tree(struct xarray *xa)
{
XA_STATE(xas, xa, 0);
void *entry;
xas_for_each(&xas, entry, ULONG_MAX) {
if (!xa_is_value(entry)) {
item_free(entry, xas.xa_index);
}
xas_store(&xas, NULL);
}
assert(xa_empty(xa));
}
void tree_verify_min_height(struct radix_tree_root *root, int maxindex)
{
unsigned shift;
struct radix_tree_node *node = root->xa_head;
if (!radix_tree_is_internal_node(node)) {
assert(maxindex == 0);
return;
}
node = entry_to_node(node);
assert(maxindex <= node_maxindex(node));
shift = node->shift;
if (shift > 0)
assert(maxindex > shift_maxindex(shift - RADIX_TREE_MAP_SHIFT));
else
assert(maxindex > 0);
}
Annotation
- Immediate include surface: `stdlib.h`, `assert.h`, `stdio.h`, `linux/types.h`, `linux/kernel.h`, `linux/bitops.h`, `test.h`.
- Detected declarations: `function item_tag_set`, `function item_tag_clear`, `function item_tag_get`, `function item_insert`, `function item_sanity`, `function item_free`, `function item_delete`, `function item_free_rcu`, `function item_delete_rcu`, `function item_check_present`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.