[PATCH v2 1/4] tools/include: Implement a couple of atomic_t ops
Pedro Falcato
pfalcato at suse.de
Mon Sep 1 03:27:47 PDT 2025
On Thu, Aug 28, 2025 at 12:27:58PM +0000, Brendan Jackman wrote:
> The VMA tests need an operation equivalent to
> atomic_inc_unless_negative() to implement a fake mapping_map_writable().
> Adding it will enable them to switch to the shared atomic headers and
> simplify that fake implementation.
>
> In order to add that, also add atomic_try_cmpxchg() which can be used to
> implement it. This is copied from Documentation/atomic_t.txt. Then,
> implement atomic_inc_unless_negative() itself based on the
> raw_atomic_dec_unless_positive() in
> include/linux/atomic/atomic-arch-fallback.h.
>
> There's no present need for a highly-optimised version of this (nor any
> reason to think this implementation is sub-optimal on x86) so just
> implement this with generic C, no x86-specifics.
>
> Signed-off-by: Brendan Jackman <jackmanb at google.com>
Reviewed-by: Pedro Falcato <pfalcato at suse.de>
LGTM, thanks!
--
Pedro
More information about the maple-tree
mailing list