[PATCH 0/6] maple_tree: Change replacement strategy
From: Liam R. Howlett
Date: Fri Aug 04 2023 - 13:00:38 EST
The maple tree marks nodes dead as soon as they are going to be
replaced. This could be problematic when used in the RCU context since
the writer may be starved of CPU time by the readers. This patch set
addresses the issue by switching the data replacement strategy to one
that will only mark data as dead once the new data is available.
This series changes the ordering of the node replacement so that the new
data is live before the old data is marked 'dead'. When readers hit
'dead' nodes, they will restart from the top of the tree and end up in
the new data.
In more complex scenarios, the replacement strategy means a subtree is
built and graphed into the tree leaving some nodes to point to the old
parent. The view of tasks into the old data will either remain with the
old data, or see the new data once the old data is marked 'dead'.
Iterators will see the 'dead' node and restart on their own and switch
to the new data. There is no risk of the reader seeing old data in
these cases.
The 'dead' subtree of data is then fully marked dead, but reused nodes
will still point to the dead nodes until the parent pointer is updated.
Walking up to a 'dead' node will cause a re-walk from the top of the
tree and enter the new data area where old data is not reachable.
Once the parent pointers are fully up to date in the active data, the
'dead' subtree is iterated to collect entirely 'dead' subtrees, and dead
nodes (nodes that partially contained reused data).
Liam R. Howlett (6):
maple_tree: Add hex output to maple_arange64 dump
maple_tree: Reorder replacement of nodes to avoid live lock
maple_tree: introduce mas_put_in_tree()
maple_tree: Introduce mas_tree_parent() definition
maple_tree: Change mas_adopt_children() parent usage
maple_tree: Replace data before marking dead in split and spanning
store
lib/maple_tree.c | 607 +++++++++++++++++++----------------------------
1 file changed, 240 insertions(+), 367 deletions(-)
--
2.39.2