Message ID | 20220930192613.3491147-1-adhemerval.zanella@linaro.org |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 974F2385C33F for <patchwork@sourceware.org>; Fri, 30 Sep 2022 19:26:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 974F2385C33F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664566003; bh=ryfALtU2CfVPcHISjV7lei4Az8RmO1lvJXX2fgiqNYc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=bvx0VN6txMD3ouWKNrXYuJLpUVIRVJNkcEQ9JVjp8spqQ5BUhTGf6QXsaXDPDID1T +PlSooD/L7PwJkoZujCqAACaN6gYChH4ggvmvkew2ep+K05aGxbyuoaktqqB2HyukS 3ZjlVGmSXV3gF7YoKw1ouprMyY89C320YNVMAiac= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) by sourceware.org (Postfix) with ESMTPS id A867D3858D1E for <libc-alpha@sourceware.org>; Fri, 30 Sep 2022 19:26:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A867D3858D1E Received: by mail-ua1-x931.google.com with SMTP id e22so2100008uar.5 for <libc-alpha@sourceware.org>; Fri, 30 Sep 2022 12:26:18 -0700 (PDT) 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:to :from:x-gm-message-state:from:to:cc:subject:date; bh=ryfALtU2CfVPcHISjV7lei4Az8RmO1lvJXX2fgiqNYc=; b=ez87BBaXCw4NApB6slk/mQb6ms9T1fqG8LFDRc+8pu8maHlYBhZ2Wd/KCb9Ok4RpMH wbRAl6VeAN2wtEHquy2KxhowFLYrj/Wtq9IBR0Mk/PS0J0vbe01/02Mk3LqDQ0KY/HXA t617+dMRUPif3V+q2SDxPrbMPxH7x1d02XGEfaklIaHPCGKHSg3Hfa+c5Akn+bLMiHkE 5z+sRCj1onuDgUD2XY4HCtaobgwFuDmwCElc3mwH6cArzC/zuHgpidbl94I8T9oUYlM/ pWJ+jb3itggPLHbk6EBh5ic1mYtq8FsFXNWq0SJDz/2Kxr2KaSY4/0xe+8BnM+vbN+Sy YmyQ== X-Gm-Message-State: ACrzQf2PjgmhNJdeBcaPGeZy66E+fR2cyi4pO67/8r0n9Da6HFGzUMxj lhuKafdRLOSfB87RyfpEOXHJ3LGArNAxXOK1 X-Google-Smtp-Source: AMsMyM70HADuTnnnyvjUXUUCF2+O+KM3JlCHDKiJWdiXEKCj25DiDklBqMHEzV9sclCb8wJskQ7wEQ== X-Received: by 2002:a05:6130:291:b0:3be:ec87:9f84 with SMTP id q17-20020a056130029100b003beec879f84mr5875024uac.88.1664565977808; Fri, 30 Sep 2022 12:26:17 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:3736:cce5:8b83:d63b:2954]) by smtp.gmail.com with ESMTPSA id h197-20020a1f21ce000000b0039ecbaa55d8sm2381545vkh.44.2022.09.30.12.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 12:26:17 -0700 (PDT) To: libc-alpha@sourceware.org, Christian Brauner <brauner@kernel.org> Subject: [PATCH v2 0/9] Optimize posix_spawn signal setup with clone3 Date: Fri, 30 Sep 2022 16:26:04 -0300 Message-Id: <20220930192613.3491147-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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Adhemerval Zanella <adhemerval.zanella@linaro.org> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Optimize posix_spawn signal setup with clone3
|
|
Message
Adhemerval Zanella Netto
Sept. 30, 2022, 7:26 p.m. UTC
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. Changes from v1: * Adeed arm and mips clone3 implementation. Adhemerval Zanella (9): linux: Do not reset signal handler in posix_spawn if it is already SIG_DFL linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn powerpc64le: 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 | 10 + posix/Makefile | 3 +- posix/tst-spawn7.c | 179 ++++++++++++++++++ sysdeps/unix/sysv/linux/aarch64/clone3.S | 90 +++++++++ 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 | 6 + sysdeps/unix/sysv/linux/kernel-features.h | 9 + sysdeps/unix/sysv/linux/mips/clone3.S | 147 ++++++++++++++ sysdeps/unix/sysv/linux/mips/sysdep.h | 2 + .../sysv/linux/powerpc/powerpc64/clone3.S | 145 ++++++++++++++ sysdeps/unix/sysv/linux/powerpc/sysdep.h | 1 + sysdeps/unix/sysv/linux/riscv/clone3.S | 83 ++++++++ sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + sysdeps/unix/sysv/linux/s390/s390-64/clone3.S | 84 ++++++++ sysdeps/unix/sysv/linux/s390/sysdep.h | 1 + sysdeps/unix/sysv/linux/spawni.c | 33 +++- 19 files changed, 910 insertions(+), 26 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
Comments
Ping. On 30/09/22 16:26, Adhemerval Zanella wrote: > 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. > > Changes from v1: > * Adeed arm and mips clone3 implementation. > > Adhemerval Zanella (9): > linux: Do not reset signal handler in posix_spawn if it is already > SIG_DFL > linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn > powerpc64le: 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 | 10 + > posix/Makefile | 3 +- > posix/tst-spawn7.c | 179 ++++++++++++++++++ > sysdeps/unix/sysv/linux/aarch64/clone3.S | 90 +++++++++ > 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 | 6 + > sysdeps/unix/sysv/linux/kernel-features.h | 9 + > sysdeps/unix/sysv/linux/mips/clone3.S | 147 ++++++++++++++ > sysdeps/unix/sysv/linux/mips/sysdep.h | 2 + > .../sysv/linux/powerpc/powerpc64/clone3.S | 145 ++++++++++++++ > sysdeps/unix/sysv/linux/powerpc/sysdep.h | 1 + > sysdeps/unix/sysv/linux/riscv/clone3.S | 83 ++++++++ > sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + > sysdeps/unix/sysv/linux/s390/s390-64/clone3.S | 84 ++++++++ > sysdeps/unix/sysv/linux/s390/sysdep.h | 1 + > sysdeps/unix/sysv/linux/spawni.c | 33 +++- > 19 files changed, 910 insertions(+), 26 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 >
On 9/30/22 15:26, Adhemerval Zanella via Libc-alpha wrote: > 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. > I would like to trim this down for glibc 2.37. I think we can get the default implementation in place and enable this for x86_64. Everything else that adds custom assembly should be something we commit once 2.38 opens and so we can have time to review the generated code and make sure we don't break anything. I'd like to see a v3 posted with just the 3 patches required to turn this on: 1/9 linux: Do not reset signal handler in posix_spawn if it is already SIG_DFL 2/9 linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn 9/9 Linux: optimize clone3 internal usage > Changes from v1: > * Adeed arm and mips clone3 implementation. > > Adhemerval Zanella (9): > linux: Do not reset signal handler in posix_spawn if it is already > SIG_DFL > linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn > powerpc64le: 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 | 10 + > posix/Makefile | 3 +- > posix/tst-spawn7.c | 179 ++++++++++++++++++ > sysdeps/unix/sysv/linux/aarch64/clone3.S | 90 +++++++++ > 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 | 6 + > sysdeps/unix/sysv/linux/kernel-features.h | 9 + > sysdeps/unix/sysv/linux/mips/clone3.S | 147 ++++++++++++++ > sysdeps/unix/sysv/linux/mips/sysdep.h | 2 + > .../sysv/linux/powerpc/powerpc64/clone3.S | 145 ++++++++++++++ > sysdeps/unix/sysv/linux/powerpc/sysdep.h | 1 + > sysdeps/unix/sysv/linux/riscv/clone3.S | 83 ++++++++ > sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + > sysdeps/unix/sysv/linux/s390/s390-64/clone3.S | 84 ++++++++ > sysdeps/unix/sysv/linux/s390/sysdep.h | 1 + > sysdeps/unix/sysv/linux/spawni.c | 33 +++- > 19 files changed, 910 insertions(+), 26 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 >