|
|
Log in / Subscribe / Register

The multi-order radix tree

By Jonathan Corbet
April 27, 2016

LSFMM 2016
Radix trees have a number of uses in the kernel, the most prominent of which is storing the association between pages in memory and the file blocks that hold their backing store. That particular tree was designed under the assumption that all pages are the same size. When huge pages are used, each single page must be represented by many (typically 512) entries in the radix tree, which is less than fully efficient. Matthew Wilcox has been working on adding multi-order (multiple sizes) support to the radix tree; he described this work in a plenary session at the 2016 Linux Storage, Filesystem, and Memory-Management Summit.

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 [Matthew Wilcox] 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
KernelRadix tree
ConferenceStorage, Filesystem, and Memory-Management Summit/2016


to post comments


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds