From 98f9435f336cbee5d57a1a16373331ca1bc648db Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Netto Date: Thu, 12 Jan 2023 10:58:53 -0300 Subject: 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 --- include/clone_internal.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/clone_internal.h') 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), -- cgit v1.2.3