浅析Linux Radix-Tree
Radix-Tree在Linux内核中有着广泛的应用,如page cache,swap cache通过Radix-Tree来管理虚拟地址到page cache之间的映射关系.
Radix-Tree的特点是可以通过整数作为index来找到对应的数据结构,而无需像数组一样需要事先定义好整数index的范围,也就是Index可以是离散的,查找速度相较数组也不会逊色太多,在空间和时间上取得一个均衡.
如下内容主要基于Linux-3.18.
主要数据结构及说明
数据结构
struct radix_tree_node {
unsigned int path; /* Offset in parent & height from the bottom */
unsigned int count;/*current used slot in this node*/
union {
struct {
/* Used when ascending tree */