From patchwork Wed May 26 16:57:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 43588 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 85AE3384803C; Wed, 26 May 2021 16:57:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85AE3384803C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1622048257; bh=GZA1mR9hqJx/331ByA5y0WKPy1wnDqDWQPgrTXJCvyQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=x9wOftPGTfF/XOe7melvTn+slt4chKdLOeVYWhEL/h7ocu9tCtljQOOIVOxSTu1Om KlCdjwjeQksLq+12PH8kyrjTOgFrtFcxM4CAJaZCftQ05wt5rWPgwGPqB5EMBOPxap psgDdspbUzYRWDElUTNN9ojUoVwdTWxC2FBv56qY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id 4F3A3385782E for ; Wed, 26 May 2021 16:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4F3A3385782E Received: by mail-qk1-x731.google.com with SMTP id 82so1660994qki.8 for ; Wed, 26 May 2021 09:57:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GZA1mR9hqJx/331ByA5y0WKPy1wnDqDWQPgrTXJCvyQ=; b=jmi8B3Ev/TaVnL5vl0NHN5Qpaia9b6yZpkWR8xLkSyGvDA0k3ZJWM7bbcXn3T1P7K5 XhMBc55eNCNHkxoS4fHHijzb1oMZJdIuYkGDq+gIXwIoDBO/6yE4mT+tqsL3Quno5xZe cDXzH5rRNtzI9CEmGGBrgUVjMah45ucQ/YCQpToEtjyc8JOemXJLfhBTJ1qzy+mvD5Cl YheUu+0e0OXOAj1j3VrrOgaAYMLHEs3+h/n7NUh+dohKknR5ffVDHKJHSIgJn+pLVTmY G0rEV+iO43pYeBttubInvWQB2Fft/HwRz/zhiZ/2EmsewjoeBogFV0mzDTsoAEHJ7D+Q 5/Tw== X-Gm-Message-State: AOAM531/fpoR1Fmh4+CtYZBRG5JenzFDyx5hGoe0oRZIbkVXCVUoR1VT VG9G4B25ggGY5j4ia5hlx8hTUsZRV5ERlw== X-Google-Smtp-Source: ABdhPJzFoEqAounMh+dt3fTh3aF+mhbLhp5YVHbK++TiYSU/k/wrserqg6pRYA+IUeiJpbES7Sn7BA== X-Received: by 2002:a05:620a:2a0f:: with SMTP id o15mr40739815qkp.295.1622048253649; Wed, 26 May 2021 09:57:33 -0700 (PDT) Received: from birita.. ([177.194.37.86]) by smtp.googlemail.com with ESMTPSA id k125sm1859761qkf.53.2021.05.26.09.57.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 09:57:33 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 00/11] nptl: pthread cancellation refactor Date: Wed, 26 May 2021 13:57:17 -0300 Message-Id: <20210526165728.1772546-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@sourceware.org Sender: "Libc-alpha" This patchset refactor and simplifies the nptl cancellation code. The first 4 patches just add NFC changes and a new test. The 5th patch fixes an memory leak issue when pthread_create fails to setup either the scheduling or affinity parameter. The asynchronous cancellation is removed in favor of using a member to indicate the setup has failed and letting the created thread to deallocate the memory (similar on how detached threads do). The 6h patch move the signal handler setup to pthread_cancel, now that asynchronous cancellation is not used anymore on thread creation. The 7th remove the CANCELING_BITMASK bit, since it is mainly used to signal that a syscall that has returned should be cancelled (which is a wrong assumption, since syscall with side-effects should *not* be cancelled as per BZ#12683). The 8th and 9th patches move both the cancel state and cancel type out of 'cancelhandling' variable, since with CANCELING_BITMASK and pthread_cancel change in previous patch they are not accessed in a concurrent manner. The 10th patch consolidates the raise as 'pthread_kill(pthread_self())'. Finally, the 11th patch uses pthread_kill on pthread_cancel. Adhemerval Zanella (11): nptl: Move Linux createthread to nptl nptl: Move createthread to pthread_create support: Add xpthread_attr_setaffinity_np wrapper nptl: Add pthread_attr_setaffinity_np failure test nptl: Deallocate the thread stack on setup failure (BZ #19511) nptl: Install cancellation handler on pthread_cancel nptl: Remove CANCELING_BITMASK nptl: Move cancel state out of cancelhandling nptl: Move cancel type out of cancelhandling nptl: Implement raise in terms of pthread_kill nptl: Use pthread_kill on pthread_cancel include/pthread.h | 5 + manual/pattern.texi | 1 - manual/process.texi | 3 +- nptl/Makefile | 1 + nptl/Versions | 3 +- nptl/allocatestack.c | 3 + nptl/cancellation.c | 62 ++-------- nptl/cleanup_defer.c | 46 +------- nptl/createthread.c | 45 -------- nptl/descr.h | 32 ++---- nptl/libc-cleanup.c | 46 +------- nptl/pthreadP.h | 24 +--- nptl/pthread_cancel.c | 145 ++++++++--------------- nptl/pthread_create.c | 151 ++++++++++++++++++------ nptl/pthread_join_common.c | 7 +- nptl/pthread_kill.c | 52 ++++++--- nptl/pthread_self.c | 4 +- nptl/pthread_setcancelstate.c | 36 +----- nptl/pthread_setcanceltype.c | 41 +------ nptl/pthread_testcancel.c | 11 +- nptl/tst-pthread-attr-affinity-fail.c | 54 +++++++++ support/Makefile | 1 + support/xpthread_attr_setaffinity_np.c | 28 +++++ support/xthread.h | 3 + sysdeps/htl/pthreadP.h | 2 - sysdeps/posix/raise.c | 11 +- sysdeps/unix/sysv/linux/createthread.c | 153 ------------------------- sysdeps/unix/sysv/linux/raise.c | 52 --------- 28 files changed, 369 insertions(+), 653 deletions(-) delete mode 100644 nptl/createthread.c create mode 100644 nptl/tst-pthread-attr-affinity-fail.c create mode 100644 support/xpthread_attr_setaffinity_np.c delete mode 100644 sysdeps/unix/sysv/linux/createthread.c delete mode 100644 sysdeps/unix/sysv/linux/raise.c