From: "H. Peter Anvin" <hpa@zytor.com>
To: Alexey Dobriyan <adobriyan@gmail.com>, Ingo Molnar <mingo@kernel.org>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] x86/asm: delete dummy variables in movdir64b()
Date: Fri, 07 Mar 2025 08:23:17 -0800 [thread overview]
Message-ID: <686459FE-58F5-4009-AF13-B2BF43CF5550@zytor.com> (raw)
In-Reply-To: <d9d6b9db-dcdb-4024-a14a-bdcbe6afe00a@p183>
On March 7, 2025 8:15:42 AM PST, Alexey Dobriyan <adobriyan@gmail.com> wrote:
>On Fri, Mar 07, 2025 at 12:49:26PM +0100, Ingo Molnar wrote:
>>
>> * Alexey Dobriyan <adobriyan@gmail.com> wrote:
>>
>> > Cast to pointer-to-array instead.
>> >
>> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>> > ---
>> > arch/x86/include/asm/special_insns.h | 9 +++------
>> > 1 file changed, 3 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
>> > index d349aa0f0a83..b24c6c945c38 100644
>> > --- a/arch/x86/include/asm/special_insns.h
>> > +++ b/arch/x86/include/asm/special_insns.h
>> > @@ -215,13 +215,10 @@ static __always_inline void serialize(void)
>> > /* The dst parameter must be 64-bytes aligned */
>> > static inline void movdir64b(void *dst, const void *src)
>> > {
>> > - const struct { char _[64]; } *__src = src;
>> > - struct { char _[64]; } *__dst = dst;
>> > -
>> > /*
>> > * MOVDIR64B %(rdx), rax.
>> > *
>> > - * Both __src and __dst must be memory constraints in order to tell the
>> > + * Both src and dst must be memory constraints in order to tell the
>> > * compiler that no other memory accesses should be reordered around
>> > * this one.
>> > *
>> > @@ -230,8 +227,8 @@ static inline void movdir64b(void *dst, const void *src)
>> > * I.e., not the pointers but what they point to, thus the deref'ing '*'.
>> > */
>> > asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
>> > - : "+m" (*__dst)
>> > - : "m" (*__src), "a" (__dst), "d" (__src));
>> > + : "+m" (*(char(*)[64])dst)
>> > + : "m" (*(const char(*)[64])src), "a" (dst), "d" (src));
>>
>> In what world is putting type casts inside asm() statements an
>> improvement to the code?
>
>In the same world where creating distracting variable whose only purpose
>is to make a cast is considered not good.
>
>Notice the cast is shorter, there is not "struct", so it is positive in
>both vertical and horizontal directions.
Stuffing more into a single statement – and asm statements are invariably complex – is not good for clarity. Please, no.
next prev parent reply other threads:[~2025-03-07 16:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 6:12 [PATCH 1/4] x86/asm: inline constant inputs in rdpkru(), wrpkru() Alexey Dobriyan
2025-03-07 6:12 ` [PATCH 2/4] x86/asm: delete dummy variable in clwb() Alexey Dobriyan
2025-03-07 6:12 ` [PATCH 3/4] x86/asm: delete dummy variables in movdir64b() Alexey Dobriyan
2025-03-07 11:49 ` Ingo Molnar
2025-03-07 11:54 ` H. Peter Anvin
2025-03-07 16:15 ` Alexey Dobriyan
2025-03-07 16:23 ` H. Peter Anvin [this message]
2025-03-07 6:12 ` [PATCH 4/4] x86/asm: delete dummy variable in enqcmds() Alexey Dobriyan
2025-03-07 16:29 ` [PATCH 1/4] x86/asm: inline constant inputs in rdpkru(), wrpkru() Dave Hansen
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=686459FE-58F5-4009-AF13-B2BF43CF5550@zytor.com \
--to=hpa@zytor.com \
--cc=adobriyan@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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®