Commit 11539337 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Ingo Molnar

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: default avatarAlexey 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@avx2Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 67b8d5c7
...@@ -23,13 +23,13 @@ unsigned long __clear_user(void __user *addr, unsigned long size) ...@@ -23,13 +23,13 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
asm volatile( asm volatile(
" testq %[size8],%[size8]\n" " testq %[size8],%[size8]\n"
" jz 4f\n" " jz 4f\n"
"0: movq %[zero],(%[dst])\n" "0: movq $0,(%[dst])\n"
" addq %[eight],%[dst]\n" " addq $8,%[dst]\n"
" decl %%ecx ; jnz 0b\n" " decl %%ecx ; jnz 0b\n"
"4: movq %[size1],%%rcx\n" "4: movq %[size1],%%rcx\n"
" testl %%ecx,%%ecx\n" " testl %%ecx,%%ecx\n"
" jz 2f\n" " jz 2f\n"
"1: movb %b[zero],(%[dst])\n" "1: movb $0,(%[dst])\n"
" incq %[dst]\n" " incq %[dst]\n"
" decl %%ecx ; jnz 1b\n" " decl %%ecx ; jnz 1b\n"
"2:\n" "2:\n"
...@@ -40,8 +40,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size) ...@@ -40,8 +40,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
_ASM_EXTABLE(0b,3b) _ASM_EXTABLE(0b,3b)
_ASM_EXTABLE(1b,2b) _ASM_EXTABLE(1b,2b)
: [size8] "=&c"(size), [dst] "=&D" (__d0) : [size8] "=&c"(size), [dst] "=&D" (__d0)
: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr), : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr));
[zero] "r" (0UL), [eight] "r" (8UL));
clac(); clac();
return size; return size;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment