The multi-order radix tree
The core idea behind this work is to allow the radix tree to hold a single
entry to represent an entire huge page. This is useful for persistent
memory, which is most efficiently managed as huge pages, but it is also
desirable for the transparent huge pages mechanism. There have been
suggestions that it might assist filesystems in the management of large
file blocks, but Matthew is not sure whether that is true or not.
Regardless, he wanted developers to know that this functionality is now
available.
The radix tree API has changed little as a result of this work. The low-level functions __radix_tree_create() and __radix_tree_insert() now have order arguments indicating the size of the inserted entry. Code making use of multi-order radix trees may require significant changes, though, so that the code is prepared for the multi-order entries that can be returned by lookup operations.
Internally, the feature is implemented by tagging pointers with an "indirect" bit to indicate nodes in the tree; if that bit is clear, the pointer refers to user data instead. At the bottom level of the tree, a number of "sibling" entries contain pointers to the canonical entry for the page. Notably, the tree doesn't store the order of the page; users have to get that information via some other means.
James Bottomley asked whether the tree could be used to detect
opportunities for the use of larger pages; Matthew answered that it was
probably not the right place for that. Chris Mason said that he once tried
to get Btrfs to use
stubs in the radix tree as a sort of lock when direct I/O is being
performed; that technique might be more easily implemented using the
multi-order feature. It could, perhaps,
make direct I/O "a bit less of a nightmare." Jan Kara noted that
similar things are done to support the DAX direct-access mechanism. He
also said that the page cache uses radix-tree entries to mark evicted
pages, which could perhaps interfere with other uses. The right solution,
perhaps, would be the long-discussed range-locking mechanism; at this
point, though, the session wound down and the idea was not discussed
further.
| Index entries for this article | |
|---|---|
| Kernel | Radix tree |
| Conference | Storage, Filesystem, and Memory-Management Summit/2016 |
