diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2018-05-07 17:39:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-05-14 05:38:51 -0400 |
commit | 1153933703d927b3d4874c0bc801de32b1b58be9 (patch) | |
tree | e2ace18c80c137e9feb056c4c6e5e4bb7a47e7a2 | |
parent | 67b8d5c7081221efa252e111cd52532ec6d4266f (diff) |
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>
-rw-r--r-- | arch/x86/lib/usercopy_64.c | 9 |
1 files 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) | |||
23 | asm volatile( | 23 | asm volatile( |
24 | " testq %[size8],%[size8]\n" | 24 | " testq %[size8],%[size8]\n" |
25 | " jz 4f\n" | 25 | " jz 4f\n" |
26 | "0: movq %[zero],(%[dst])\n" | 26 | "0: movq $0,(%[dst])\n" |
27 | " addq %[eight],%[dst]\n" | 27 | " addq $8,%[dst]\n" |
28 | " decl %%ecx ; jnz 0b\n" | 28 | " decl %%ecx ; jnz 0b\n" |
29 | "4: movq %[size1],%%rcx\n" | 29 | "4: movq %[size1],%%rcx\n" |
30 | " testl %%ecx,%%ecx\n" | 30 | " testl %%ecx,%%ecx\n" |
31 | " jz 2f\n" | 31 | " jz 2f\n" |
32 | "1: movb %b[zero],(%[dst])\n" | 32 | "1: movb $0,(%[dst])\n" |
33 | " incq %[dst]\n" | 33 | " incq %[dst]\n" |
34 | " decl %%ecx ; jnz 1b\n" | 34 | " decl %%ecx ; jnz 1b\n" |
35 | "2:\n" | 35 | "2:\n" |
@@ -40,8 +40,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size) | |||
40 | _ASM_EXTABLE(0b,3b) | 40 | _ASM_EXTABLE(0b,3b) |
41 | _ASM_EXTABLE(1b,2b) | 41 | _ASM_EXTABLE(1b,2b) |
42 | : [size8] "=&c"(size), [dst] "=&D" (__d0) | 42 | : [size8] "=&c"(size), [dst] "=&D" (__d0) |
43 | : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr), | 43 | : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr)); |
44 | [zero] "r" (0UL), [eight] "r" (8UL)); | ||
45 | clac(); | 44 | clac(); |
46 | return size; | 45 | return size; |
47 | } | 46 | } |