From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id 7F4933858C54 for ; Fri, 4 Nov 2022 19:01:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F4933858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x22c.google.com with SMTP id b124so6118088oia.4 for ; Fri, 04 Nov 2022 12:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tlTdfBcS2YQ5Q79uVsXMLxp3wCfmnR1xBC6/iBGNGrg=; b=UvrE72mLa+adyWd8nQ43aCnDiWOMjjE7p7zutGNQvkYaUlOTor/mKKioOGyyb/LLbp ZKpC8WG1xYBUkhyEtlH/2ASzppivsY79sSN8hhxBhEgdX9Vo6xvT8JXwS63gjKE+q4GP 4nU1uGriZgbPc1t+aJxH/EkSkBvelfXPx7OjUxsfSMunHqfOK6SeZoXksT+gj02zARJS Ft+WcrtSiqSMSI94Q8UB/LHe7gSioUzTtSyLsVMfNsKc1DY8/Kl+MDQ4pmy77jpK0GaU 4YxNKBl93C/26voRIDm4sJiHxEEBP4NrzT9kZE0N3legSDxPPXrVrqnjpxmWSJY6EIhF PYew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tlTdfBcS2YQ5Q79uVsXMLxp3wCfmnR1xBC6/iBGNGrg=; b=zn7Yh6L9BWq/bdLa4LEOzMFpy3aQbysXvzefvGidsSUd0z6ABC2gFqS/6mpkWtCeFF 9w8uPWT9mYCA26/FT2YQkuZiBnMEPY0Lycizg0pCykeLKFmGtLq4JkvYIRIgKxVB7e4/ LeZZ34FvEIIdTmQUdpS4xzkSCumx+LN94Kbh4XFFmbtiWUsA2Wnhx+Qqmui0ZlSp62EM gGqSwO9p5DO8PXu1f+msPrMmEpYIGqTeZuXkN98A2G5YoAUhnx4SHb8IoJ8aozxgNUbo YLtlG7bFUoMHfaInfXGLT9hPvxSfC5wBkAniuEKTgv15gi+PaZKzQRh6RfLcHxFdSuIG +pxA== X-Gm-Message-State: ACrzQf3tBNlrMDNDTLbaSkn6lIYBb5EbiMwpaTq6dXkGrt6YQaJb8sKj 33ALbp28NHPoG5DSOnl+ilh8QB21vyGW+Wf1 X-Google-Smtp-Source: AMsMyM6FHr16+dz7Jhkmoi6Wy0e2YKuuftjEsR5WnSiljOkNPEGWNwLIKxGi3PrBIXokfhDHYwK8vQ== X-Received: by 2002:a05:6808:1188:b0:351:5f92:3c52 with SMTP id j8-20020a056808118800b003515f923c52mr28600196oil.196.1667588476532; Fri, 04 Nov 2022 12:01:16 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:a9f4:f725:94bd:4cc1:1762]) by smtp.gmail.com with ESMTPSA id 24-20020aca1018000000b0035763a9a36csm1764713oiq.44.2022.11.04.12.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 12:01:15 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Szabolcs Nagy , "H . J . Lu" Cc: Christian Brauner Subject: [PATCH v2 00/11] Optimize posix_spawn signal setup with clone3 Date: Fri, 4 Nov 2022 16:01:01 -0300 Message-Id: <20221104190112.2566409-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Currently posix_spawn has to issue at least NSIG sigaction syscalls to obtain current signal disposition and more if they there are not either SIG_IGN or SIG_DFL. The new clone3 CLONE_CLEAR_SIGHAND flags introduced with Linux 5.5 resets all signal handlers of the child not set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this preparation phase. The exception is the signals defined by posix_spawnattr_setsigdefault when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN). In this case posix_spawn helper process needs to issue a sigction to set the signal disposition to SIG_DFL. The patchset also adds clone3 implementation for aarch64, powerpc64, s390x, riscv, arm, and mips. The clone3 for x86_64 is change to not align the stack, since this is not async-signal safe (although current calls does mask/unmask). * Changes from v1: - Extend clone3 documentation. - Remove x86_64 stack alignment on clone3 child. - Fixed powerpc64 missing initial stack frame. - Fixed missing save/restore r7 for arm. Adhemerval Zanella (11): linux: Do not reset signal handler in posix_spawn if it is already SIG_DFL linux: Extend internal clone3 documentation Linux: Do not align the stack for __clone3 linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn powerpc64: Add the clone3 wrapper aarch64: Add the clone3 wrapper s390x: Add the clone3 wrapper riscv: Add the clone3 wrapper arm: Add the clone3 wrapper mips: Add the clone3 wrapper Linux: optimize clone3 internal usage include/clone_internal.h | 39 +++- posix/Makefile | 3 +- posix/tst-spawn7.c | 179 ++++++++++++++++++ sysdeps/unix/sysv/linux/Makefile | 3 +- sysdeps/unix/sysv/linux/aarch64/clone3.S | 85 +++++++++ sysdeps/unix/sysv/linux/aarch64/sysdep.h | 2 + sysdeps/unix/sysv/linux/arm/clone3.S | 80 ++++++++ sysdeps/unix/sysv/linux/arm/sysdep.h | 1 + sysdeps/unix/sysv/linux/clone-internal.c | 59 ++++-- sysdeps/unix/sysv/linux/clone3.h | 15 +- sysdeps/unix/sysv/linux/kernel-features.h | 9 + sysdeps/unix/sysv/linux/mips/clone3.S | 139 ++++++++++++++ sysdeps/unix/sysv/linux/mips/sysdep.h | 2 + .../sysv/linux/powerpc/powerpc64/clone3.S | 152 +++++++++++++++ sysdeps/unix/sysv/linux/powerpc/sysdep.h | 1 + sysdeps/unix/sysv/linux/riscv/clone3.S | 80 ++++++++ sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + sysdeps/unix/sysv/linux/s390/s390-64/clone3.S | 81 ++++++++ sysdeps/unix/sysv/linux/s390/sysdep.h | 1 + sysdeps/unix/sysv/linux/spawni.c | 33 +++- .../sysv/linux/tst-misalign-clone-internal.c | 74 -------- sysdeps/unix/sysv/linux/x86_64/clone3.S | 3 - 22 files changed, 924 insertions(+), 118 deletions(-) create mode 100644 posix/tst-spawn7.c create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S create mode 100644 sysdeps/unix/sysv/linux/arm/clone3.S create mode 100644 sysdeps/unix/sysv/linux/mips/clone3.S create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S create mode 100644 sysdeps/unix/sysv/linux/riscv/clone3.S create mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/clone3.S delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c -- 2.34.1