Re: [PATCH] x86/atomic: Add arch_atomic_not()
From: Ziran Zhang
Date: Wed Jul 15 2026 - 10:52:40 EST
On Wed, 15 Jul 2026 12:49:20 +0100, Gary Guo wrote:
> > The kernel already has non-atomic bitmap_complement(), but
> > no direct atomic implementation.
> >
> > According to Intel and AMD manuals, the NOT instruction
> > supports a LOCK prefix.
> >
> > Currently the only way to achieve this is arch_atomic_xor(-1, v),
> > which is non-obvious and hurts readability, so add arch_atomic_not()
> > to provide an explicit atomic complement operation.
>
> What do you need this for?
>
> Best,
> Gary
Hi Gary,
At present there is no code in kernel that would call
arch_atomic_not() or arch_atomic_xor(~0,v).
I'll drop this patch and revisit if a real use case
shows up in the future.
Thanks for the review!
Regards,
Ziran Zhang