From: Wei Liu <wei.liu@kernel.org>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>
Subject: Re: [PATCH RESEND] mshv: Use try_cmpxchg() instead of cmpxchg()
Date: Wed, 18 Feb 2026 23:27:47 +0000 [thread overview]
Message-ID: <20260218232747.GK2236050@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <20260218110041.179949-1-ubizjak@gmail.com>
On Wed, Feb 18, 2026 at 12:00:18PM +0100, Uros Bizjak wrote:
> Use !try_cmpxchg() instead of cmpxchg (*ptr, old, new) != old.
> x86 CMPXCHG instruction returns success in ZF flag, so this
> change saves a compare after CMPXCHG.
>
> The generated assembly code improves from e.g.:
>
> 415: 48 8b 44 24 30 mov 0x30(%rsp),%rax
> 41a: 48 8b 54 24 38 mov 0x38(%rsp),%rdx
> 41f: f0 49 0f b1 91 a8 02 lock cmpxchg %rdx,0x2a8(%r9)
> 426: 00 00
> 428: 48 3b 44 24 30 cmp 0x30(%rsp),%rax
> 42d: 0f 84 09 ff ff ff je 33c <...>
>
> to:
>
> 415: 48 8b 44 24 30 mov 0x30(%rsp),%rax
> 41a: 48 8b 54 24 38 mov 0x38(%rsp),%rdx
> 41f: f0 49 0f b1 91 a8 02 lock cmpxchg %rdx,0x2a8(%r9)
> 426: 00 00
> 428: 0f 84 0e ff ff ff je 33c <...>
>
> No functional change intended.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Long Li <longli@microsoft.com>
Applied. Thanks.
prev parent reply other threads:[~2026-02-18 23:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 10:25 [PATCH] " Uros Bizjak
2026-02-18 11:00 ` [PATCH RESEND] " Uros Bizjak
2026-02-18 23:27 ` Wei Liu [this message]
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=20260218232747.GK2236050@liuwe-devbox-debian-v2.local \
--to=wei.liu@kernel.org \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--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
all inboxes | Powered by JetHome®