public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add likely around access_ok for uaccess
@ 2003-09-14 11:17 Manfred Spraul
  2003-09-14 19:30 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Manfred Spraul @ 2003-09-14 11:17 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

Hi,

while trying to figure out why sysv msg is around 30% slower than pipes 
for data transfers I noticed that gcc's autodetection (3.2.2) guesses 
the "if(access_ok())" tests in uaccess.h wrong and puts the error memset 
into the direct path and the copy out of line.

The attached patch adds likely to the tests - any objections? What about 
the archs except i386?

--
    Manfred

[-- Attachment #2: patch-uaccess-likely --]
[-- Type: text/plain, Size: 1000 bytes --]

--- 2.6/include/asm-i386/uaccess.h	2003-09-12 21:53:58.000000000 +0200
+++ build-2.6/include/asm-i386/uaccess.h	2003-09-14 12:56:19.000000000 +0200
@@ -300,7 +300,7 @@
 	long __pu_err = -EFAULT;					\
 	__typeof__(*(ptr)) *__pu_addr = (ptr);				\
 	might_sleep();						\
-	if (access_ok(VERIFY_WRITE,__pu_addr,size))			\
+	if (likely(access_ok(VERIFY_WRITE,__pu_addr,size)))			\
 		__put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT);	\
 	__pu_err;							\
 })							
@@ -510,7 +510,7 @@
 direct_copy_to_user(void __user *to, const void *from, unsigned long n)
 {
 	might_sleep();
-	if (access_ok(VERIFY_WRITE, to, n))
+	if (likely(access_ok(VERIFY_WRITE, to, n)))
 		n = __direct_copy_to_user(to, from, n);
 	return n;
 }
@@ -535,7 +535,7 @@
 direct_copy_from_user(void *to, const void __user *from, unsigned long n)
 {
 	might_sleep();
-	if (access_ok(VERIFY_READ, from, n))
+	if (likely(access_ok(VERIFY_READ, from, n)))
 		n = __direct_copy_from_user(to, from, n);
 	else
 		memset(to, 0, n);

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <vD5l.6Wt.19@gated-at.bofh.it>]

end of thread, other threads:[~2003-09-17 16:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-14 11:17 [PATCH] add likely around access_ok for uaccess Manfred Spraul
2003-09-14 19:30 ` Andrew Morton
2003-09-14 19:45   ` Manfred Spraul
2003-09-14 19:48     ` Manfred Spraul
2003-09-14 20:00     ` Andrew Morton
2003-09-15 22:59 ` David S. Miller
2003-09-16 19:49 ` Pavel Machek
2003-09-16 20:55   ` Jeff Garzik
2003-09-16 20:59     ` Pavel Machek
2003-09-17 16:57       ` Manfred Spraul
     [not found] <vD5l.6Wt.19@gated-at.bofh.it>
2003-09-14 16:49 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox