All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/copy_user.S: Remove zero byte check before copy user buffer.
@ 2013-11-16 20:37 Fenghua Yu
  2013-11-17  6:18 ` [tip:x86/asm] x86-64, copy_user: " tip-bot for Fenghua Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Fenghua Yu @ 2013-11-16 20:37 UTC (permalink / raw)
  To: Linus Torvalds, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-kernel, Fenghua Yu

From: Fenghua Yu <fenghua.yu@intel.com>

Operation of rep movsb instruction handles zero byte copy. As pointed out by
Linus, there is no need to check zero size in kernel. Removing this redundant
check saves a few cycles in copy user functions.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/x86/lib/copy_user_64.S | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
index a30ca15..ffe4eb9 100644
--- a/arch/x86/lib/copy_user_64.S
+++ b/arch/x86/lib/copy_user_64.S
@@ -236,8 +236,6 @@ ENDPROC(copy_user_generic_unrolled)
 ENTRY(copy_user_generic_string)
 	CFI_STARTPROC
 	ASM_STAC
-	andl %edx,%edx
-	jz 4f
 	cmpl $8,%edx
 	jb 2f		/* less than 8 bytes, go to byte copy loop */
 	ALIGN_DESTINATION
@@ -249,7 +247,7 @@ ENTRY(copy_user_generic_string)
 2:	movl %edx,%ecx
 3:	rep
 	movsb
-4:	xorl %eax,%eax
+	xorl %eax,%eax
 	ASM_CLAC
 	ret
 
@@ -279,12 +277,10 @@ ENDPROC(copy_user_generic_string)
 ENTRY(copy_user_enhanced_fast_string)
 	CFI_STARTPROC
 	ASM_STAC
-	andl %edx,%edx
-	jz 2f
 	movl %edx,%ecx
 1:	rep
 	movsb
-2:	xorl %eax,%eax
+	xorl %eax,%eax
 	ASM_CLAC
 	ret
 
-- 
1.8.0.1


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

end of thread, other threads:[~2013-11-20 22:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-16 20:37 [PATCH] x86/copy_user.S: Remove zero byte check before copy user buffer Fenghua Yu
2013-11-17  6:18 ` [tip:x86/asm] x86-64, copy_user: " tip-bot for Fenghua Yu
     [not found]   ` <CA+55aFyFz_6oy8-1jb5Jzk+4VC5MLA5d0KbqhZxki0=+DmggBg@mail.gmail.com>
2013-11-17  6:51     ` H. Peter Anvin
2013-11-19  4:37     ` H. Peter Anvin
2013-11-19 19:38       ` Linus Torvalds
2013-11-20 19:12         ` H. Peter Anvin
2013-11-20 19:28     ` H. Peter Anvin
2013-11-20 20:13       ` Linus Torvalds
2013-11-20 20:36         ` H. Peter Anvin
2013-11-20 21:44           ` Linus Torvalds
2013-11-20 20:54 ` [tip:x86/asm] x86-64, copy_user: Use leal to produce 32-bit results tip-bot for H. Peter Anvin
2013-11-20 22:00 ` tip-bot for H. Peter Anvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.