[PATCH v2 4/4] tools: testing: Use existing atomic.h for vma/maple tests
Pedro Falcato
pfalcato at suse.de
Mon Sep 1 03:29:05 PDT 2025
On Thu, Aug 28, 2025 at 12:28:01PM +0000, Brendan Jackman wrote:
> The shared userspace logic used for unit-testing maple tree and VMA code
> currently has its own replacements for atomics helpers. This is not
> needed as the necessary APIs already have userspace implementations in
> the tools tree. Switching over to that allows deleting a bit of code.
>
> Note that the implementation is different; while the version being
> deleted here is implemented using liburcu, the existing version in tools
> uses either x86 asm or compiler builtins. It's assumed that both are
> equally likely to be correct.
>
> The tools tree's version of atomic_t is a struct type while the version
> being deleted was just a typedef of an integer. This means it's no
> longer valid to call __sync_bool_compare_and_swap() directly on it. One
> option would be to just peek into the struct and call it on the field,
> but it seems a little cleaner to just use the corresponding atomic.h
> API whic has been added recently. Now the fake mapping_map_writable() is
> copied from the real one.
>
> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes at oracle.com>
> Signed-off-by: Brendan Jackman <jackmanb at google.com>
Reviewed-by: Pedro Falcato <pfalcato at suse.de>
> ---
> tools/testing/shared/linux/maple_tree.h | 6 ++----
> tools/testing/vma/linux/atomic.h | 17 -----------------
> tools/testing/vma/vma_internal.h | 12 +++---------
> 3 files changed, 5 insertions(+), 30 deletions(-)
Yay, less code! :)
--
Pedro
More information about the maple-tree
mailing list