linux-stable/tools/testing/radix-tree
Liam R. Howlett 2780b421b8 maple_tree: fix write memory barrier of nodes once dead for RCU mode
[ Upstream commit c13af03de4 ]

During the development of the maple tree, the strategy of freeing multiple
nodes changed and, in the process, the pivots were reused to store
pointers to dead nodes.  To ensure the readers see accurate pivots, the
writers need to mark the nodes as dead and call smp_wmb() to ensure any
readers can identify the node as dead before using the pivot values.

There were two places where the old method of marking the node as dead
without smp_wmb() were being used, which resulted in RCU readers seeing
the wrong pivot value before seeing the node was dead.  Fix this race
condition by using mte_set_node_dead() which has the smp_wmb() call to
ensure the race is closed.

Add a WARN_ON() to the ma_free_rcu() call to ensure all nodes being freed
are marked as dead to ensure there are no other call paths besides the two
updated paths.

This is necessary for the RCU mode of the maple tree.

Link: https://lkml.kernel.org/r/20230227173632.3292573-6-surenb@google.com
Fixes: 54a611b605 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-20 12:36:58 +02:00
..
generated maple_tree: reorganize testing to restore module testing 2022-11-08 15:57:22 -08:00
linux radix tree test suite: add lockdep_is_held to header 2022-09-26 19:46:14 -07:00
trace/events Maple Tree: add new data structure 2022-09-26 19:46:13 -07:00
.gitignore maple_tree: reorganize testing to restore module testing 2022-11-08 15:57:22 -08:00
benchmark.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
bitmap.c
idr-test.c idr test suite: Improve reporting from idr_find_test_1 2021-04-01 07:50:42 -04:00
iteration_check.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
iteration_check_2.c xarray: Fix early termination of xas_for_each_marked 2020-03-12 17:42:08 -04:00
linux.c maple_tree: reorganize testing to restore module testing 2022-11-08 15:57:22 -08:00
main.c xarray: Fix early termination of xas_for_each_marked 2020-03-12 17:42:08 -04:00
Makefile maple_tree: reorganize testing to restore module testing 2022-11-08 15:57:22 -08:00
maple.c maple_tree: fix write memory barrier of nodes once dead for RCU mode 2023-04-20 12:36:58 +02:00
multiorder.c radix tree test suite: Register the main thread with the RCU library 2021-04-01 07:41:30 -04:00
regression.h
regression1.c
regression2.c
regression3.c
regression4.c
tag_check.c
test.c
test.h radix tree test suite: Fix compilation 2020-10-07 09:07:49 -04:00
xarray.c radix tree test suite: Register the main thread with the RCU library 2021-04-01 07:41:30 -04:00