include/linux/maple_tree.h
Source file repositories/reference/linux-study-clean/include/linux/maple_tree.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/maple_tree.h- Extension
.h- Size
- 30640 bytes
- Lines
- 937
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/rcupdate.hlinux/spinlock.h
Detected Declarations
struct maple_metadatastruct maple_range_64struct maple_arange_64struct maple_topiarystruct maple_copystruct maple_treestruct maple_nodestruct ma_topiarystruct ma_statestruct ma_wr_stateenum maple_typeenum store_typeenum maple_statusenum mt_dump_formatfunction MTREE_INITfunction mtree_emptyfunction mas_initfunction mas_is_activefunction mas_is_errfunction mas_resetfunction __mas_set_rangefunction mas_set_rangefunction mas_setfunction mt_external_lockfunction mt_init_flagsfunction mt_initfunction mt_in_rcufunction mt_clear_in_rcufunction mt_set_in_rcufunction mt_height
Annotated Snippet
struct maple_metadata {
unsigned char end; /* end of data */
unsigned char gap; /* offset of largest gap */
};
/*
* Leaf nodes do not store pointers to nodes, they store user data. Users may
* store almost any bit pattern. As noted above, the optimisation of storing an
* entry at 0 in the root pointer cannot be done for data which have the bottom
* two bits set to '10'. We also reserve values with the bottom two bits set to
* '10' which are below 4096 (ie 2, 6, 10 .. 4094) for internal use. Some APIs
* return errnos as a negative errno shifted right by two bits and the bottom
* two bits set to '10', and while choosing to store these values in the array
* is not an error, it may lead to confusion if you're testing for an error with
* mas_is_err().
*
* Non-leaf nodes store the type of the node pointed to (enum maple_type in bits
* 3-6), bit 2 is reserved. That leaves bits 0-1 unused for now.
*
* In regular B-Tree terms, pivots are called keys. The term pivot is used to
* indicate that the tree is specifying ranges, Pivots may appear in the
* subtree with an entry attached to the value whereas keys are unique to a
* specific position of a B-tree. Pivot values are inclusive of the slot with
* the same index.
*/
struct maple_range_64 {
struct maple_pnode *parent;
unsigned long pivot[MAPLE_RANGE64_SLOTS - 1];
union {
void __rcu *slot[MAPLE_RANGE64_SLOTS];
struct {
void __rcu *pad[MAPLE_RANGE64_SLOTS - 1];
struct maple_metadata meta;
};
};
};
/*
* At tree creation time, the user can specify that they're willing to trade off
* storing fewer entries in a tree in return for storing more information in
* each node.
*
* The maple tree supports recording the largest range of NULL entries available
* in this node, also called gaps. This optimises the tree for allocating a
* range.
*/
struct maple_arange_64 {
struct maple_pnode *parent;
unsigned long pivot[MAPLE_ARANGE64_SLOTS - 1];
void __rcu *slot[MAPLE_ARANGE64_SLOTS];
unsigned long gap[MAPLE_ARANGE64_SLOTS];
struct maple_metadata meta;
};
struct maple_topiary {
struct maple_pnode *parent;
struct maple_enode *next; /* Overlaps the pivot */
};
enum maple_type {
maple_dense,
maple_leaf_64,
maple_range_64,
maple_arange_64,
maple_copy,
};
enum store_type {
wr_invalid,
wr_new_root,
wr_store_root,
wr_exact_fit,
wr_spanning_store,
wr_split_store,
wr_rebalance,
wr_append,
wr_node_store,
wr_slot_store,
};
struct maple_copy {
/*
* min, max, and pivots are values
* start, end, split are indexes into arrays
* data is a size
*/
struct {
struct maple_node *node;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/rcupdate.h`, `linux/spinlock.h`.
- Detected declarations: `struct maple_metadata`, `struct maple_range_64`, `struct maple_arange_64`, `struct maple_topiary`, `struct maple_copy`, `struct maple_tree`, `struct maple_node`, `struct ma_topiary`, `struct ma_state`, `struct ma_wr_state`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.