From patchwork Thu Jan 12 13:58:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 55409 Return-Path: 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 E687338543BA for ; Thu, 12 Jan 2023 13:59:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E687338543BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673531961; bh=mDTEYyGMImO6XNr8xyfL3W09LQbTolIkt29snyHBIcs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yyhC+7//zRFzvWGBOcA/0MxoWrFKzZwtyCOKtSUVVyslHOQQndG9VjVMu8OJMKWp6 s/3avmep7U3VD2VdHjP59yZA1Ueh4yAb6ZDDhAL2P5BWtBH4919MM7IlOBpSvTHgrk 5Cd5k5hgiSK6mPuEnkI8RXmnv8VK8Z0THL3wBpjE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by sourceware.org (Postfix) with ESMTPS id 4BF893858C66 for ; Thu, 12 Jan 2023 13:58:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4BF893858C66 Received: by mail-oo1-xc34.google.com with SMTP id d2-20020a4ab202000000b004ae3035538bso4821721ooo.12 for ; Thu, 12 Jan 2023 05:58:59 -0800 (PST) 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:message-id:reply-to; bh=mDTEYyGMImO6XNr8xyfL3W09LQbTolIkt29snyHBIcs=; b=jrUdgg0Lo85hki/yl/gY8IbDXZmDH20GFbdMWkkQsVKZXLCVqyHskwM1RCaA+OIUxo ixGwSjitvhV7ksJeqXcYT2foah7xfJzVu2+K+Zq/cQEaUr2k7PXiq6oz7345R79BGVPe u2/DklEiFwX4DflaaK6bFjgIX2HUfw44e0+HS18Zc0biSq50EW1+CQVInbmfodd7+vbr 7MK6cheVat8QXYN/pzfZdYEiJH3mKfQ9Lk9WGURhyuMNhFjq0ZyAZOkS0UQtZKVXIMgi kPsXDvMSDr6oRfX08wadml7YutgWTTNvBBnisNRA8HGMiAGcx2tB+2WoWlcualpQkM6O Iy7g== X-Gm-Message-State: AFqh2kp0QdxNafmDi2b84oSX2ZOZKQSfCT4mfdn8wtv0i7X9U74y9h2a esJO4+jITPRao7rBxSPFMX25kNNISKN5mfbsoWI= X-Google-Smtp-Source: AMrXdXt+g30F9g7xq3U0LJzT7Yvlcg0WyAbtKLpK17ehhceh+IY1D7pfep2vn/kqqZVp0xYpfFzwXQ== X-Received: by 2002:a4a:ce8b:0:b0:4f2:85eb:a with SMTP id f11-20020a4ace8b000000b004f285eb000amr439050oos.4.1673531937914; Thu, 12 Jan 2023 05:58:57 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:bf1c:dea8:4fd2:4310]) by smtp.gmail.com with ESMTPSA id m26-20020a4abc9a000000b004a0aac2d28fsm8335402oop.35.2023.01.12.05.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 05:58:57 -0800 (PST) To: libc-alpha@sourceware.org, Carlos O'Donell Subject: [PATCH v4 0/6] Optimize posix_spawn signal setup with clone3 Date: Thu, 12 Jan 2023 10:58:47 -0300 Message-Id: <20230112135853.3786675-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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. 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 signals). * Changes from v3: - Changes commit message and comments wording. - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations. * Changes from v2: - Improve clone3 internal documentation. * 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 (6): 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 aarch64: Add the clone3 wrapper Linux: optimize clone3 internal usage include/clone_internal.h | 37 +++- 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/clone-internal.c | 59 ++++-- sysdeps/unix/sysv/linux/clone3.h | 15 +- sysdeps/unix/sysv/linux/kernel-features.h | 9 + sysdeps/unix/sysv/linux/spawni.c | 33 +++- .../sysv/linux/tst-misalign-clone-internal.c | 74 -------- sysdeps/unix/sysv/linux/x86_64/clone3.S | 3 - 12 files changed, 384 insertions(+), 118 deletions(-) create mode 100644 posix/tst-spawn7.c create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c