LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] x86_64: use immediate constants in __clear_user()
@ 2018-05-07 21:39 Alexey Dobriyan
  2018-05-14 12:52 ` [tip:x86/asm] x86/asm/64: Micro-optimize __clear_user() - Use immediate constants tip-bot for Alexey Dobriyan
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2018-05-07 21:39 UTC (permalink / raw)
  To: tglx, mingo, hpa; +Cc: linux-kernel, x86

Save 2 registers. Adding constants should be just as fast as adding
registers.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 arch/x86/lib/usercopy_64.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/arch/x86/lib/usercopy_64.c
+++ b/arch/x86/lib/usercopy_64.c
@@ -23,13 +23,13 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
 	asm volatile(
 		"	testq  %[size8],%[size8]\n"
 		"	jz     4f\n"
-		"0:	movq %[zero],(%[dst])\n"
-		"	addq   %[eight],%[dst]\n"
+		"0:	movq $0,(%[dst])\n"
+		"	addq   $8,%[dst]\n"
 		"	decl %%ecx ; jnz   0b\n"
 		"4:	movq  %[size1],%%rcx\n"
 		"	testl %%ecx,%%ecx\n"
 		"	jz     2f\n"
-		"1:	movb   %b[zero],(%[dst])\n"
+		"1:	movb   $0,(%[dst])\n"
 		"	incq   %[dst]\n"
 		"	decl %%ecx ; jnz  1b\n"
 		"2:\n"
@@ -40,8 +40,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
 		_ASM_EXTABLE(0b,3b)
 		_ASM_EXTABLE(1b,2b)
 		: [size8] "=&c"(size), [dst] "=&D" (__d0)
-		: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
-		  [zero] "r" (0UL), [eight] "r" (8UL));
+		: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr));
 	clac();
 	return size;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip:x86/asm] x86/asm/64: Micro-optimize __clear_user() - Use immediate constants
  2018-05-07 21:39 [PATCH] x86_64: use immediate constants in __clear_user() Alexey Dobriyan
@ 2018-05-14 12:52 ` tip-bot for Alexey Dobriyan
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Alexey Dobriyan @ 2018-05-14 12:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, mingo, torvalds, hpa, adobriyan, peterz, linux-kernel

Commit-ID:  1153933703d927b3d4874c0bc801de32b1b58be9
Gitweb:     https://git.kernel.org/tip/1153933703d927b3d4874c0bc801de32b1b58be9
Author:     Alexey Dobriyan <adobriyan@gmail.com>
AuthorDate: Tue, 8 May 2018 00:39:37 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 14 May 2018 11:38:51 +0200

x86/asm/64: Micro-optimize __clear_user() - Use immediate constants

Save two registers. Adding constants should be just as fast as adding registers.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180507213937.GB32406@avx2
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/lib/usercopy_64.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
index 75d3776123cc..a624dcc4de10 100644
--- a/arch/x86/lib/usercopy_64.c
+++ b/arch/x86/lib/usercopy_64.c
@@ -23,13 +23,13 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
 	asm volatile(
 		"	testq  %[size8],%[size8]\n"
 		"	jz     4f\n"
-		"0:	movq %[zero],(%[dst])\n"
-		"	addq   %[eight],%[dst]\n"
+		"0:	movq $0,(%[dst])\n"
+		"	addq   $8,%[dst]\n"
 		"	decl %%ecx ; jnz   0b\n"
 		"4:	movq  %[size1],%%rcx\n"
 		"	testl %%ecx,%%ecx\n"
 		"	jz     2f\n"
-		"1:	movb   %b[zero],(%[dst])\n"
+		"1:	movb   $0,(%[dst])\n"
 		"	incq   %[dst]\n"
 		"	decl %%ecx ; jnz  1b\n"
 		"2:\n"
@@ -40,8 +40,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
 		_ASM_EXTABLE(0b,3b)
 		_ASM_EXTABLE(1b,2b)
 		: [size8] "=&c"(size), [dst] "=&D" (__d0)
-		: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
-		  [zero] "r" (0UL), [eight] "r" (8UL));
+		: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr));
 	clac();
 	return size;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-14 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07 21:39 [PATCH] x86_64: use immediate constants in __clear_user() Alexey Dobriyan
2018-05-14 12:52 ` [tip:x86/asm] x86/asm/64: Micro-optimize __clear_user() - Use immediate constants tip-bot for Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).