Re: [PATCH] xfs: Use xchg() in xlog_cil_insert_pcp_aggregate()

From: Uros Bizjak
Date: Wed Nov 20 2024 - 11:41:12 EST


On Wed, Nov 20, 2024 at 4:34 PM Alex Elder <elder@xxxxxxxxxxxx> wrote:
>
> On 11/20/24 9:06 AM, Uros Bizjak wrote:
> > try_cmpxchg() loop with constant "new" value can be substituted
> > with just xchg() to atomically get and clear the location.
>
> You're right. With a constant new value (0), there is no need
> to loop to ensure we get a "stable" update.
>
> Is the READ_ONCE() is still needed?

No, xchg() guarantees atomic access on its own.

Uros.