Caution The slab cache stores only the data structures needed to create the tree This has nothing to do with the memory used for the cached pages which is allocated and managed independently

Each radix tree also has a per-CPU pool of pre-allocated node elements to further speed the insertion of new elements into the tree. radix_tree_preload is a container that ensures that at least one element resides in this cache. The function is always invoked before an individual element is added to the radix tree using radix_tree_insert (this is ignored in the following sections).4

Locking

Radix trees do not provide any form of protection against concurrent access in general. As usual in the kernel, it is the responsibility of each subsystem that deploys radix trees to care for correction locking or any other synchronization primitive, as discussed in Chapter 5. However, an exception is made for several important read functions. This includes radix_tree_lookup to perform a lookup operation, radix_tree_tag_get to obtain a tag on a radix tree node, and radix_tree_tagged to test whether any items in the tree are tagged.

The first two functions can be called without subsystem-specific locking if they are embraced by rcu_read_lock() ... rcu_read_unlock(), while the third function does not require any lock at all.

rcu_head provides the required connection between radix tree nodes and the RCU implementation. Notice that <radix-tree.h> contains more advice on how to implement proper synchronization for radix trees, so I will not discuss the problem in more detail here.

Continue reading here: Operations on Address Spaces

Was this article helpful?

0 0