tools/perf/util/block-range.c
Source file repositories/reference/linux-study-clean/tools/perf/util/block-range.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/block-range.c- Extension
.c- Size
- 7033 bytes
- Lines
- 333
- 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
block-range.hannotate.hassert.hstdlib.h
Detected Declarations
function block_range__debugfunction rb_link_left_of_nodefunction rb_link_right_of_nodefunction block_range__createfunction block_range__coverage
Annotated Snippet
if (entry->end < start) {
n = rb_next(n);
if (!n)
goto do_whole;
}
next = rb_entry(n, struct block_range, node);
if (next->start <= end) { /* add head: [start...][n->start...] */
struct block_range *head = malloc(sizeof(struct block_range));
if (!head)
return iter;
*head = (struct block_range){
.start = start,
.end = next->start - 1,
.is_target = 1,
.is_branch = 0,
};
rb_link_left_of_node(&head->node, &next->node);
rb_insert_color(&head->node, &block_ranges.root);
block_range__debug();
iter.start = head;
goto do_tail;
}
do_whole:
/*
* The whole [start..end] range is non-overlapping.
*/
entry = malloc(sizeof(struct block_range));
if (!entry)
return iter;
*entry = (struct block_range){
.start = start,
.end = end,
.is_target = 1,
.is_branch = 1,
};
rb_link_node(&entry->node, parent, p);
rb_insert_color(&entry->node, &block_ranges.root);
block_range__debug();
iter.start = entry;
iter.end = entry;
goto done;
}
/*
* We found a range that overlapped with ours, split if needed.
*/
if (entry->start < start) { /* split: [e->start...][start...] */
struct block_range *head = malloc(sizeof(struct block_range));
if (!head)
return iter;
*head = (struct block_range){
.start = entry->start,
.end = start - 1,
.is_target = entry->is_target,
.is_branch = 0,
.coverage = entry->coverage,
.entry = entry->entry,
};
entry->start = start;
entry->is_target = 1;
entry->entry = 0;
rb_link_left_of_node(&head->node, &entry->node);
rb_insert_color(&head->node, &block_ranges.root);
block_range__debug();
} else if (entry->start == start)
entry->is_target = 1;
iter.start = entry;
do_tail:
/*
* At this point we've got: @iter.start = [@start...] but @end can still be
* inside or beyond it.
*/
entry = iter.start;
for (;;) {
/*
Annotation
- Immediate include surface: `block-range.h`, `annotate.h`, `assert.h`, `stdlib.h`.
- Detected declarations: `function block_range__debug`, `function rb_link_left_of_node`, `function rb_link_right_of_node`, `function block_range__create`, `function block_range__coverage`.
- 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.