[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1435250653-30182-20-git-send-email-bp@alien8.de>
Date: Thu, 25 Jun 2015 18:44:13 +0200
From: Borislav Petkov <bp@...en8.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 19/19] x86/asm: Save an instruction in DECLARE_ARGS users
From: George Spelvin <linux@...izon.com>
Before, the code to do RDTSC looked like:
rdtsc
shl $0x20,%rdx
mov %eax,%eax
or %rdx,%rax
The "mov %eax,%eax" is required to clear the high 32 bits of %rax.
By declaring low and high as 64-bit variables, the code is simplified
to:
rdtsc
shl $0x20,%rdx
or %rdx,%rax
Yes, it's a 2-byte instruction that's not on a critical path, but there
are principles to be upheld.
Every user of EAX_EDX_RET has been checked. I tried to check users of
EAX_EDX_ARGS, but there weren't any, so I deleted it to be safe.
(There's no benefit to making "high" 64 bits, but it was the simplest
way to proceed.)
Signed-off-by: George Spelvin <linux@...izon.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: jacob.jun.pan@...ux.intel.com
Cc: x86-ml <x86@...nel.org>
Link: http://lkml.kernel.org/r/20150618075906.4615.qmail@ns.horizon.com
Signed-off-by: Borislav Petkov <bp@...e.de>
---
arch/x86/include/asm/msr.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 02bdd6c65017..131eec2ca137 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -47,14 +47,13 @@ static inline unsigned long long native_read_tscp(unsigned int *aux)
* it means rax *or* rdx.
*/
#ifdef CONFIG_X86_64
-#define DECLARE_ARGS(val, low, high) unsigned low, high
-#define EAX_EDX_VAL(val, low, high) ((low) | ((u64)(high) << 32))
-#define EAX_EDX_ARGS(val, low, high) "a" (low), "d" (high)
+/* Using 64-bit values saves one instruction clearing the high half of low */
+#define DECLARE_ARGS(val, low, high) unsigned long low, high
+#define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32)
#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
#else
#define DECLARE_ARGS(val, low, high) unsigned long long val
#define EAX_EDX_VAL(val, low, high) (val)
-#define EAX_EDX_ARGS(val, low, high) "A" (val)
#define EAX_EDX_RET(val, low, high) "=A" (val)
#endif
--
2.3.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists