Refer:
Radix tree in kernel: trees I: Radix trees
Http://lwn.net/articles/175432/ordinary Radix tree (note: this is not the radix tree used in the kernel)
Http://en.wikipedia.org/wiki/Radix_tree
The variant Radix tree is discussed here. Please note.
What is the core idea of Radix tree?The radix tree used in the kernel is not a strict Radix tree, but a variant Radix tree. essentially multi-level hash. the Linux kernel uses the radix tree to organize the page cache so that you can quickly find whether an address is in the page cache. the hash conflict processing policy is Zipper.
The hash key is an integer value (address), and the value is a pointer. It is a multi-level hash_map. The implementation of multi-level hash is that the first few digits of the integer value (1 ~ 6 bit) used for hash, the number of digits in the middle (7 ~ 12) used for second-level hash. The next few digits (13 ~ 18) as hash is used for level-3 hash, the search speed is extremely fast. Because the tree height is only three layers, you only need to perform three searches (without considering hash conflicts ).
Why use multi-level hash? Instead of common hash?If hash is used, the length of the hash algorithm in the kernel is fixed at the beginning. if it is set to an excessively small value, when the page cache becomes larger, there will be many conflicts. if the setting is too large, it is a waste of time when the page cache is very small! Therefore, the kernel uses multi-level hash. the benefits of multi-level hash are that the storage efficiency is extremely high in the face of sparse page cache, so there is no waste of space. because most of the child nodes are empty, that is, there is no child branch. for example, if there is only one page in the page cache, the radix tree only needs three internal nodes. The first layer has one node: root, and the second layer has only one node, the third layer has only one node !! Such as a radix tree of the running kernel.