All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li kunyu <kunyu@nfschina.com>
To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Li kunyu <kunyu@nfschina.com>
Subject: [PATCH] x86/boot/arch/variable: I don't think (void *) Pointers need to be cast
Date: Mon, 25 Jul 2022 12:23:58 +0800	[thread overview]
Message-ID: <20220725042358.3377-1-kunyu@nfschina.com> (raw)

I first observe (void *) type coercion and non coercion through assembly
language. It seems that there is no difference.
Then I output the assigned information through the print function and
found that the pointer that is not coerced is directly assigned when
executing the print function (opcode a1), while the coerced pointer
needs to execute the assembly instruction xlat (opcode d7), which seems
to be more efficient without coerced conversion.
At present, I just started to try to analyze this part of knowledge
(machine code), please forgive me if the analysis is wrong.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 arch/x86/boot/bitops.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
index 02e1dea11d94..8518ae214c9b 100644
--- a/arch/x86/boot/bitops.h
+++ b/arch/x86/boot/bitops.h
@@ -19,13 +19,13 @@
 
 static inline bool constant_test_bit(int nr, const void *addr)
 {
-	const u32 *p = (const u32 *)addr;
+	const u32 *p = addr;
 	return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0;
 }
 static inline bool variable_test_bit(int nr, const void *addr)
 {
 	bool v;
-	const u32 *p = (const u32 *)addr;
+	const u32 *p = addr;
 
 	asm("btl %2,%1" CC_SET(c) : CC_OUT(c) (v) : "m" (*p), "Ir" (nr));
 	return v;
-- 
2.18.2


             reply	other threads:[~2022-07-25  4:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  4:23 Li kunyu [this message]
2022-08-03  9:33 ` [PATCH] x86/boot/arch/variable: I don't think (void *) Pointers need to be cast Ingo Molnar
2022-08-03 15:42 ` [tip: x86/cleanups] x86/boot: Remove superfluous type casting from arch/x86/boot/bitops.h tip-bot2 for Li kunyu
2022-08-15 19:25 ` tip-bot2 for Li kunyu

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=20220725042358.3377-1-kunyu@nfschina.com \
    --to=kunyu@nfschina.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.