aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2025-02-11 20:19:29 +0100
committerVasily Gorbik <gor@linux.ibm.com>2025-03-04 17:18:03 +0100
commit88e87cb7b8f8afcf1776d5b8a3ddd17fe8d2a32f (patch)
tree599444e250ca73b57bd710742836bf24fc6e0a6e
parents390/uaccess: Define INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER (diff)
downloadwireguard-linux-88e87cb7b8f8afcf1776d5b8a3ddd17fe8d2a32f.tar.xz
wireguard-linux-88e87cb7b8f8afcf1776d5b8a3ddd17fe8d2a32f.zip
s390/uaccess: Optimize raw_copy_from_user() / raw_copy_to_user() for constant sizes
Avoid that the compiler generates an mvcos loop for constant sizes smaller than 4096 bytes. The mvcos instruction copies between zero and 4096 bytes (effective length) with one operation. Therefore it is not necessary to implement a loop for sizes smaller or equal to 4096 bytes. This reduces the kernel text size by ~50kb (defconfig, gcc 14.2.0): add/remove: 4/5 grow/shrink: 6/471 up/down: 2294/-51700 (-49406) Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-rw-r--r--arch/s390/include/asm/uaccess.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 333a2afc0d6f..b5712d690a93 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -49,6 +49,8 @@ raw_copy_from_user(void *to, const void __user *from, unsigned long size)
: CC_OUT(cc, cc), [size] "+d" (size), [to] "=Q" (*(char *)to)
: [spec] "I" (0x81), [from] "Q" (*(const char __user *)from)
: CC_CLOBBER_LIST("memory", "0"));
+ if (__builtin_constant_p(osize) && osize <= 4096)
+ return osize - size;
if (likely(CC_TRANSFORM(cc) == 0))
return osize - size;
size -= 4096;
@@ -75,6 +77,8 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long size)
: CC_OUT(cc, cc), [size] "+d" (size), [to] "=Q" (*(char __user *)to)
: [spec] "I" (0x81), [from] "Q" (*(const char *)from)
: CC_CLOBBER_LIST("memory", "0"));
+ if (__builtin_constant_p(osize) && osize <= 4096)
+ return osize - size;
if (likely(CC_TRANSFORM(cc) == 0))
return osize - size;
size -= 4096;