[RFC PATCH v1 4/9] uaccess: Introduce copy_{to/from}_user_partial()
Christophe Leroy (CS GROUP)
chleroy at kernel.org
Tue Apr 28 03:13:45 AEST 2026
Today there are approximately 3000 calls for copy_to_user() and
3000 calls to copy_from_user().
The majority of callers of copy_{to/from}_user() don't care about the
return value, they only check whether it is 0 or not, and when it is
not 0 they handle it as a -EACCES.
In order to allow better optimisation of copy_{to/from}_user() when
the size of the copy is known at build time, create new fonctions
named copy_{to/from}_user_partial() to be used by the few callers
that are interested in partial copies and need to now how many
bytes remain at the end of the copy.
For the time being it is just the same as copy_{to/from}_user().
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy at kernel.org>
---
include/linux/uaccess.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index bd1201c81d94..2d37173782b3 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -221,6 +221,8 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
return _inline_copy_from_user(to, from, n);
}
+#define copy_from_user_partial copy_from_user
+
static __always_inline unsigned long __must_check
copy_to_user(void __user *to, const void *from, unsigned long n)
{
@@ -233,6 +235,8 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
return _inline_copy_to_user(to, from, n);
}
+#define copy_to_user_partial copy_to_user
+
#ifndef copy_mc_to_kernel
/*
* Without arch opt-in this generic copy_mc_to_kernel() will not handle
--
2.49.0
More information about the Linuxppc-dev
mailing list