about summary refs log tree commit diff
path: root/include/clone_internal.h
diff options
context:
space:
mode:
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>2023-01-12 10:58:53 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-02-01 08:42:11 -0300
commit98f9435f336cbee5d57a1a16373331ca1bc648db (patch)
treef6e57c478194afb2323db3cba00db96e7582164b /include/clone_internal.h
parent1e442efd57f231bf76030d7a30f2095d1261db20 (diff)
downloadglibc-98f9435f336cbee5d57a1a16373331ca1bc648db.tar.gz
glibc-98f9435f336cbee5d57a1a16373331ca1bc648db.tar.xz
glibc-98f9435f336cbee5d57a1a16373331ca1bc648db.zip
Linux: optimize clone3 internal usage
Add an optimization to avoid calling clone3 when glibc detects that
there is no kernel support.  It also adds __ASSUME_CLONE3, which allows
skipping this optimization and issuing the clone3 syscall directly.

It does not handle the the small window between 5.3 and 5.5 for
posix_spawn (CLONE_CLEAR_SIGHAND was added in 5.5).

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'include/clone_internal.h')
-rw-r--r--include/clone_internal.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/clone_internal.h b/include/clone_internal.h
index 3b6cd85f02..dd380f119e 100644
--- a/include/clone_internal.h
+++ b/include/clone_internal.h
@@ -24,6 +24,11 @@ extern int __clone3 (struct clone_args *__cl_args, size_t __size,
    fall back to clone or clone2.  */
 extern int __clone_internal (struct clone_args *__cl_args,
 			     int (*__func) (void *__arg), void *__arg);
+/* clone3 wrapper with a sticky check to avoid re-issuing the syscall if
+   it fails with ENOSYS.  */
+extern int __clone3_internal (struct clone_args *cl_args,
+			      int (*func) (void *args), void *arg)
+     attribute_hidden;
 /* The fallback code which calls clone/clone2 based on clone3 arguments.  */
 extern int __clone_internal_fallback (struct clone_args *__cl_args,
 				      int (*__func) (void *__arg),