From: Dave Chinner <david@fromorbit.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Chandan Babu R <chandan.babu@oracle.com>,
"Darrick J. Wong" <djwong@kernel.org>
Subject: Re: [PATCH v3] xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate()
Date: Tue, 24 Sep 2024 08:53:03 +1000 [thread overview]
Message-ID: <ZvHxTyS79BZSAYQf@dread.disaster.area> (raw)
In-Reply-To: <20240923122311.914319-1-ubizjak@gmail.com>
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@gmail.com>
> Reviewed-by: Christoph Hellwig <hch@infradead.org>
> Cc: Chandan Babu R <chandan.babu@oracle.com>
> Cc: "Darrick J. Wong" <djwong@kernel.org>
Looks fine.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-09-23 22:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-23 12:22 [PATCH v3] xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate() Uros Bizjak
2024-09-23 22:53 ` Dave Chinner [this message]
2024-09-27 18:45 ` Carlos Maiolino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZvHxTyS79BZSAYQf@dread.disaster.area \
--to=david@fromorbit.com \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ubizjak@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox