[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZvHxTyS79BZSAYQf@dread.disaster.area>
Date: Tue, 24 Sep 2024 08:53:03 +1000
From: Dave Chinner <david@...morbit.com>
To: Uros Bizjak <ubizjak@...il.com>
Cc: linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
Christoph Hellwig <hch@...radead.org>,
Chandan Babu R <chandan.babu@...cle.com>,
"Darrick J. Wong" <djwong@...nel.org>
Subject: Re: [PATCH v3] xfs: Use try_cmpxchg() in
xlog_cil_insert_pcp_aggregate()
On Mon, Sep 23, 2024 at 02:22:17PM +0200, Uros Bizjak wrote:
> Use !try_cmpxchg instead of cmpxchg (*ptr, old, new) != old in
> xlog_cil_insert_pcp_aggregate(). x86 CMPXCHG instruction returns
> success in ZF flag, so this change saves a compare after cmpxchg.
>
> Also, try_cmpxchg implicitly assigns old *ptr value to "old" when
> cmpxchg fails. There is no need to re-read the value in the loop.
>
> Note that the value from *ptr should be read using READ_ONCE to
> prevent the compiler from merging, refetching or reordering the read.
>
> No functional change intended.
>
> Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> Reviewed-by: Christoph Hellwig <hch@...radead.org>
> Cc: Chandan Babu R <chandan.babu@...cle.com>
> Cc: "Darrick J. Wong" <djwong@...nel.org>
Looks fine.
Reviewed-by: Dave Chinner <dchinner@...hat.com>
--
Dave Chinner
david@...morbit.com
Powered by blists - more mailing lists