mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-13 20:14:37 -04:00
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>
This commit is contained in:
committed by
Vasily Gorbik
parent
10a79b6fdd
commit
88e87cb7b8
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user