Skip to content

Commit 1153933

Browse files
Alexey DobriyanIngo Molnar
authored andcommitted
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 <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/20180507213937.GB32406@avx2 Signed-off-by: Ingo Molnar <[email protected]>
1 parent 67b8d5c commit 1153933

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

arch/x86/lib/usercopy_64.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
2323
asm volatile(
2424
" testq %[size8],%[size8]\n"
2525
" jz 4f\n"
26-
"0: movq %[zero],(%[dst])\n"
27-
" addq %[eight],%[dst]\n"
26+
"0: movq $0,(%[dst])\n"
27+
" addq $8,%[dst]\n"
2828
" decl %%ecx ; jnz 0b\n"
2929
"4: movq %[size1],%%rcx\n"
3030
" testl %%ecx,%%ecx\n"
3131
" jz 2f\n"
32-
"1: movb %b[zero],(%[dst])\n"
32+
"1: movb $0,(%[dst])\n"
3333
" incq %[dst]\n"
3434
" decl %%ecx ; jnz 1b\n"
3535
"2:\n"
@@ -40,8 +40,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
4040
_ASM_EXTABLE(0b,3b)
4141
_ASM_EXTABLE(1b,2b)
4242
: [size8] "=&c"(size), [dst] "=&D" (__d0)
43-
: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
44-
[zero] "r" (0UL), [eight] "r" (8UL));
43+
: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr));
4544
clac();
4645
return size;
4746
}

0 commit comments

Comments
 (0)