From patchwork Tue Sep 4 20:45:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145961 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4124684ljw; Tue, 4 Sep 2018 13:46:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaE8EkJiLHmDgrV879qCYX2NvJeoRZp+x2QhklE2JaHEIbNx1nKq57Kb5rS+EnelhGVcQ9h X-Received: by 2002:a62:f208:: with SMTP id m8-v6mr36633443pfh.222.1536093983475; Tue, 04 Sep 2018 13:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536093983; cv=none; d=google.com; s=arc-20160816; b=odruintPTUjsSWZQgB0fRZkNgKdYCbcvHvibb+jTxcGxCyv4P7XlgbM8qEFCQK3dRM /aVrZkICJbWtLQjZ0MJXErRpfbVa1Is1GtafSe9NWa9Oy9gyuULTBWP4Ykk1LTHCGxaY QXh5HaYt0Q1c4tcrwhUfIkiwKwTdlqsbFFAPTgzTZKjVPXj50D4l8v/kjGgfoZIjvnpF Tp13FKUBq3Wb2L440tffN06p9/tgKnoIuqgLFrvZt8/kxM4KaJYDd+GISW90Cbu2uudE 9NQayQUeyRr6IjZx1oq2WMe64CNeeNnbZaHC8FzRJKnvzME+XPBWqpPaycVaRSLpcPC8 3VXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=z6syHtHCWrgj9RiLSJ+/9AtrA9cOzR6jFkjRK2P4H5U=; b=G08ar3ZwAsIgJap5GR3pZRUKiDBePnPENff3hBJxBy+W/U5zjUMvNIks3X1abk2BVC /Xx4/rmGvJzwqvFjd6gUiJzlcowVRKlecdFaWlxdj/9ECThUuyBBObwF16pz/DfbeorJ bVA5ODQwFQ5b5b8h6QPPfw7AseJPivb2FcFrHv3RxTfNgMUJcY+8YfT55hmjRuQTiagi Bg6GetEbg74rg9LvjmYZyok3uSs8zcv29KX34pkXQNft0X3JYj0gnsIQTLahpxDZL5+R 7xSeeK1PFxgX31Jh4rP/JM9ZJEaa/bEEV50sRShn0l2YMZV3cfcc7amQWHlpfKgU87mh GVZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NiPvVDgj; dkim=pass header.i=@linaro.org header.s=google header.b=MWmoso7P; spf=pass (google.com: domain of libc-alpha-return-95668-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95668-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j135-v6si25440213pfd.207.2018.09.04.13.46.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:46:23 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95668-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NiPvVDgj; dkim=pass header.i=@linaro.org header.s=google header.b=MWmoso7P; spf=pass (google.com: domain of libc-alpha-return-95668-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95668-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=tF7P8eoIN5EyPxLuxWIFNIKsEml7xXT iOvfgRKjguCcQNqTw4Dy4hftXrO+k8eL6rEWZZY/k6jqk37Sw77fL81C1neuRj97 aWb/uSn5u/XzMKqq4KfLp+ovJgdCykSk3tEanxSz/KDLxjZnid99V6h3hCmuYGSk QFjyHdpMLPlI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=iIarNJIJiCc4hX/hgCJjjgkMS/A=; b=NiPvV Dgj1MdSXhIrdFoZ8HqenF2wdFt9hg+RnWrQeH7kNI9yC8n+XNcHLkaJrS0oxzvrc P+4XBFMI/BlFvCgNlvP7OisR/8UuwkjYVRDsQ/BC+vQ/70P7G9+7lDobBx7qtPtk 7u0ANSWeon/lT8rmLiiN1tRGt0SAmKZqt+QqCM= Received: (qmail 33636 invoked by alias); 4 Sep 2018 20:46:05 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 33510 invoked by uid 89); 4 Sep 2018 20:46:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk1-f176.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=z6syHtHCWrgj9RiLSJ+/9AtrA9cOzR6jFkjRK2P4H5U=; b=MWmoso7PUO0bIPX78kX0/6U0giCD3c2upKVPzB6+8DzZ21vMgMDWZ/EEEQ+CjrFIG/ L7DaqyCumQipX1uGJzGfgm6PQ/3z20CZP/FEFHCFPb8aiQ9WQ3m807YzPfj/aYSOD5lt 4J890Et2GGGiYsueyKPaGuhXZ0GWUxP6Mpp2E= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/7] powerpc: Add CFI information on indirect syscall Date: Tue, 4 Sep 2018 17:45:47 -0300 Message-Id: <20180904204553.6971-2-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> This patch the required CFI information on powerpc indirect syscall so backtrace works correctly on signal handler. Checked on powerpc-linux-gnu and powerpc64le-linux-gnu. * sysdeps/unix/sysv/linux/powerpc/syscall.S (syscall): Add CFI information. --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/powerpc/syscall.S | 1 + 2 files changed, 6 insertions(+) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall.S b/sysdeps/unix/sysv/linux/powerpc/syscall.S index 2da91721be..e30f461a17 100644 --- a/sysdeps/unix/sysv/linux/powerpc/syscall.S +++ b/sysdeps/unix/sysv/linux/powerpc/syscall.S @@ -19,6 +19,7 @@ ENTRY (syscall) ABORT_TRANSACTION + cfi_def_cfa_offset (0) mr r0,r3 mr r3,r4 mr r4,r5 From patchwork Tue Sep 4 20:45:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145962 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4124806ljw; Tue, 4 Sep 2018 13:46:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaUNv7cZFXETKsbngS52lmRqQw3DLPet1O6IxIX2maj7wXW0H4w2z4ra+j4RHaQlXxvCBMT X-Received: by 2002:a63:4204:: with SMTP id p4-v6mr7319948pga.200.1536093992439; Tue, 04 Sep 2018 13:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536093992; cv=none; d=google.com; s=arc-20160816; b=1B82iPLqL7iKCXg+7CUeYdxKCaz6fVfXfJ1mEMaZ7bLxh9dnyr3WIt3UMBrTjY1KpE sE808ifFaPtfyIfBrmQSEEsXAeghGVmwPaQidWwRTXyxVbywSTvzQgn69uytV0Aqt0wE QLPWQWzKg6ZE2Jpu4zSr8IFgXUtZUS47Ur6Xzm817csmPLmWlH9opyEPFxSyTjfDNLoD nlaN2m2BdSwbecGyKgaNtEPmUkDhrJ9iKGunaQsbqt/+E5tmbKmCPWq1wb/18PemUuAQ RhRBcZ/4WsrrnaUpa5gkbidKxJbIoTRBTkyah8uySszmtGkmFFTe+3DkPb4Tdn+v/S/O xsOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=3WO08ksBBBLrI3JUtlQXlzoEhmvKHd5ulElkGo0j8H0=; b=zDZkApW0qOTK36jPf7AXoL4qrrRwzyV8S9oqDHI7Lqv1wQKmhaG2VDgj7dDCHCG9sI jO9UvJVLblWcX+DY1uYgybeEZrARV09D9bWRGIETMl0kDMmNNwKAIQuhzq+QNSGxC+2Y 19rup4i0w6FqeEf+mKBF4x5mh9erVDD40qwfESxt4JNBCWPGvwdX1iuxOMpbTe8+0+dM +NzzFZ9aAS8uhYrxEllGJ+0S1DwR7la0juVwdDC2uL6PhyoWfW0Io1e/SB4Ey0VWDgpZ OTN7zqkx6GHKyH2TE3psAuQoA03Qe/bQo/NR6RvoC4lWqqOZrCYgFnHWMB/LZ72aqs5W NGdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ccsK0l8v; dkim=pass header.i=@linaro.org header.s=google header.b="iDIK5Oi/"; spf=pass (google.com: domain of libc-alpha-return-95669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95669-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u70-v6si21162820pgd.296.2018.09.04.13.46.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:46:32 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ccsK0l8v; dkim=pass header.i=@linaro.org header.s=google header.b="iDIK5Oi/"; spf=pass (google.com: domain of libc-alpha-return-95669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95669-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=KtS+yIWC6gyqovWJk3CRgmpOMcJWG5m ATbrnjpg6uDmH72qfY+hmdTX8AAvB7cH9k9E3yp6tOHhduMfQOVu1oUaz6nkLD8v lyNNk+bEHJPOTRxCwyiWuc1fm1FEHZ/bQg/eogRYHeNr7K1SbKe7pkfM/iZ2FBqS qC7Vr5NbX2co= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=AuxFUO/98leykS9upv+EEP3j4n0=; b=ccsK0 l8vomczrLw2YyHDS9z2kOlEHoYC8fgaXawzd7BhfeJ2fF3948/ypybUD3HQ96PB9 auE6XxfQQHQQJQD6q2jeZxN6Z8TZV7wo3fAev7InoHyXoDcpwpTqRe+liIjI+fhl AAWIMPydZmdB2cY4e8aRXWVEIDUE2pZFZorcPk= Received: (qmail 34107 invoked by alias); 4 Sep 2018 20:46:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 33991 invoked by uid 89); 4 Sep 2018 20:46:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=53, so, H*r:sk:d4-v6so X-HELO: mail-qt0-f177.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=3WO08ksBBBLrI3JUtlQXlzoEhmvKHd5ulElkGo0j8H0=; b=iDIK5Oi/Q4da6rXIMpufy7T7eGysabnLp8+f0XUXvMx4FvJD3RF6VBDhONTqj659l0 9/NqPW08bbtMqsgf1XBv92evIe29IpehhXNYI7LLBzHRZw9bMmx8uJ6482D7Ze+Yb2Ry XH0ZKoKeDLTGpCG5QdfhhX9zCX1WshdC4qDZs= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/7] nptl: Remove tst-cancel-wrappers test and related macros Date: Tue, 4 Sep 2018 17:45:48 -0300 Message-Id: <20180904204553.6971-3-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> With upcoming BZ#12683 fix, syscall cancellation is not more handled by {libc,pthread,librt}_{enable,disable}_asynccancel symbols. This renders both LIBC_CANCEL_HANDLED and empty declaration and tst-cancel-wrappers.sh unrequired. This patch removes both the macro and the nptl test. Checked on x86_64-linux-gnu. * io/creat.c (LIBC_CANCEL_HANDLED): Remove macro. * io/ppoll.c (LIBC_CANCEL_HANDLED): Likewise. * misc/pselect.c (LIBC_CANCEL_HANDLED): Likewise. * nptl/pthreadP.h (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/generic/sysdep-cancel.h (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/mach/hurd/sysdep-cancel.h (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/posix/pause.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/posix/sigpause.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/creat.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/creat64.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/sigwait.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/sigwaitinfo.c (LIBC_CANCEL_HANDLED): Likewise. * nptl/Makefile [$(run-built-tests) = yes] (tests-special): Remove tst-cancel-wrappers.sh. (generated): Remove tst-cancel-wrappers.out. (tst-cancel-wrappers.out): Remove rule. * nptl/tst-cancel-wrappers.sh: Remove file. --- ChangeLog | 19 ++++++ io/creat.c | 3 - io/ppoll.c | 2 - misc/pselect.c | 2 - nptl/Makefile | 18 +----- nptl/pthreadP.h | 10 --- nptl/tst-cancel-wrappers.sh | 92 --------------------------- sysdeps/generic/sysdep-cancel.h | 1 - sysdeps/mach/hurd/sysdep-cancel.h | 1 - sysdeps/posix/pause.c | 2 - sysdeps/posix/sigpause.c | 3 - sysdeps/unix/sysv/linux/creat.c | 2 - sysdeps/unix/sysv/linux/creat64.c | 2 - sysdeps/unix/sysv/linux/sigwait.c | 3 - sysdeps/unix/sysv/linux/sigwaitinfo.c | 3 - 15 files changed, 21 insertions(+), 142 deletions(-) delete mode 100644 nptl/tst-cancel-wrappers.sh -- 2.17.1 diff --git a/io/creat.c b/io/creat.c index 21ee56ebc9..3d0afcab54 100644 --- a/io/creat.c +++ b/io/creat.c @@ -27,6 +27,3 @@ creat (const char *file, mode_t mode) { return __open (file, O_WRONLY|O_CREAT|O_TRUNC, mode); } - -/* __open handles cancellation. */ -LIBC_CANCEL_HANDLED (); diff --git a/io/ppoll.c b/io/ppoll.c index ec26b99fee..5ccfdb9fda 100644 --- a/io/ppoll.c +++ b/io/ppoll.c @@ -70,7 +70,5 @@ ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, } #ifndef ppoll -/* __poll handles cancellation. */ -LIBC_CANCEL_HANDLED (); libc_hidden_def (ppoll); #endif diff --git a/misc/pselect.c b/misc/pselect.c index 2c29230596..07d5ffcef0 100644 --- a/misc/pselect.c +++ b/misc/pselect.c @@ -73,6 +73,4 @@ __pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, } #ifndef __pselect weak_alias (__pselect, pselect) -/* __select handles cancellation. */ -LIBC_CANCEL_HANDLED (); #endif diff --git a/nptl/Makefile b/nptl/Makefile index be8066524c..27f28d4295 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -461,8 +461,7 @@ tests-reverse += tst-cancel5 tst-cancel23 tst-vfork1x tst-vfork2x ifeq ($(run-built-tests),yes) tests-special += $(objpfx)tst-stack3-mem.out $(objpfx)tst-oddstacklimit.out ifeq ($(build-shared),yes) -tests-special += $(objpfx)tst-tls6.out $(objpfx)tst-cleanup0-cmp.out \ - $(objpfx)tst-cancel-wrappers.out +tests-special += $(objpfx)tst-tls6.out $(objpfx)tst-cleanup0-cmp.out endif endif @@ -665,8 +664,7 @@ $(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)/ ln -f $< $@ endif -generated += multidir.mk tst-atfork2.mtrace tst-cancel-wrappers.out \ - tst-tls6.out +generated += multidir.mk tst-atfork2.mtrace tst-tls6.out generated += $(objpfx)tst-atfork2.mtrace \ $(addsuffix .so,$(strip $(modules-names))) @@ -677,18 +675,6 @@ LDFLAGS-pthread.so += -e __nptl_main $(objpfx)pt-interp.os: $(common-objpfx)runtime-linker.h endif -ifeq ($(run-built-tests),yes) -ifeq (yes,$(build-shared)) -$(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh - $(SHELL) $< '$(NM)' \ - $(common-objpfx)libc_pic.a \ - $(common-objpfx)libc.a \ - $(objpfx)libpthread_pic.a \ - $(objpfx)libpthread.a > $@; \ - $(evaluate-test) -endif -endif - tst-exec4-ARGS = $(host-test-program-cmd) $(objpfx)tst-execstack: $(libdl) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 13bdb11133..2d30555941 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -316,27 +316,17 @@ __do_cancel (void) /* Same as CANCEL_RESET, but for use in libc.so. */ # define LIBC_CANCEL_RESET(oldtype) \ __libc_disable_asynccancel (oldtype) -# define LIBC_CANCEL_HANDLED() \ - __asm (".globl " __SYMBOL_PREFIX "__libc_enable_asynccancel"); \ - __asm (".globl " __SYMBOL_PREFIX "__libc_disable_asynccancel") #elif IS_IN (libpthread) # define LIBC_CANCEL_ASYNC() CANCEL_ASYNC () # define LIBC_CANCEL_RESET(val) CANCEL_RESET (val) -# define LIBC_CANCEL_HANDLED() \ - __asm (".globl " __SYMBOL_PREFIX "__pthread_enable_asynccancel"); \ - __asm (".globl " __SYMBOL_PREFIX "__pthread_disable_asynccancel") #elif IS_IN (librt) # define LIBC_CANCEL_ASYNC() \ __librt_enable_asynccancel () # define LIBC_CANCEL_RESET(val) \ __librt_disable_asynccancel (val) -# define LIBC_CANCEL_HANDLED() \ - __asm (".globl " __SYMBOL_PREFIX "__librt_enable_asynccancel"); \ - __asm (".globl " __SYMBOL_PREFIX "__librt_disable_asynccancel") #else # define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ # define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ -# define LIBC_CANCEL_HANDLED() /* Nothing. */ #endif diff --git a/nptl/tst-cancel-wrappers.sh b/nptl/tst-cancel-wrappers.sh deleted file mode 100644 index 0c5b614287..0000000000 --- a/nptl/tst-cancel-wrappers.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# Test whether all cancelable functions are cancelable. -# Copyright (C) 2002-2018 Free Software Foundation, Inc. -# This file is part of the GNU C Library. -# Contributed by Jakub Jelinek , 2002. - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, see -# . - -NM="$1"; shift -while [ $# -gt 0 ]; do - ( $NM -P $1; echo 'end[end]:' ) | gawk ' BEGIN { -C["accept"]=1 -C["close"]=1 -C["connect"]=1 -C["creat"]=1 -C["fcntl"]=1 -C["fdatasync"]=1 -C["fsync"]=1 -C["msgrcv"]=1 -C["msgsnd"]=1 -C["msync"]=1 -C["nanosleep"]=1 -C["open"]=1 -C["open64"]=1 -C["pause"]=1 -C["poll"]=1 -C["pread"]=1 -C["pread64"]=1 -C["pselect"]=1 -C["pwrite"]=1 -C["pwrite64"]=1 -C["read"]=1 -C["readv"]=1 -C["recv"]=1 -C["recvfrom"]=1 -C["recvmsg"]=1 -C["select"]=1 -C["send"]=1 -C["sendmsg"]=1 -C["sendto"]=1 -C["sigpause"]=1 -C["sigsuspend"]=1 -C["sigwait"]=1 -C["sigwaitinfo"]=1 -C["tcdrain"]=1 -C["wait"]=1 -C["waitid"]=1 -C["waitpid"]=1 -C["write"]=1 -C["writev"]=1 -C["__xpg_sigpause"]=1 -} -/:$/ { - if (seen) - { - if (!seen_enable || !seen_disable) - { - printf "in '$1'(%s) %s'\''s cancellation missing\n", object, seen - ret = 1 - } - } - seen="" - seen_enable="" - seen_disable="" - object=gensub(/^.*\[(.*)\]:$/, "\\1", 1, $0) - next -} -{ - if (C[$1] && $2 ~ /^[TW]$/) - seen=$1 - else if ($1 ~ /^([.]|)__(libc|pthread)_enable_asynccancel$/ && $2 == "U") - seen_enable=1 - else if ($1 ~ /^([.]|)__(libc|pthread)_disable_asynccancel$/ && $2 == "U") - seen_disable=1 -} -END { - exit ret -}' || exit - shift -done diff --git a/sysdeps/generic/sysdep-cancel.h b/sysdeps/generic/sysdep-cancel.h index ba6a1e04ba..d22a786536 100644 --- a/sysdeps/generic/sysdep-cancel.h +++ b/sysdeps/generic/sysdep-cancel.h @@ -5,4 +5,3 @@ #define RTLD_SINGLE_THREAD_P (1) #define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ #define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ -#define LIBC_CANCEL_HANDLED() /* Nothing. */ diff --git a/sysdeps/mach/hurd/sysdep-cancel.h b/sysdeps/mach/hurd/sysdep-cancel.h index ec55c7330f..f686a39024 100644 --- a/sysdeps/mach/hurd/sysdep-cancel.h +++ b/sysdeps/mach/hurd/sysdep-cancel.h @@ -6,4 +6,3 @@ #define RTLD_SINGLE_THREAD_P (0) #define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ #define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ -#define LIBC_CANCEL_HANDLED() /* Nothing. */ diff --git a/sysdeps/posix/pause.c b/sysdeps/posix/pause.c index 2b9eca2192..879a8abd89 100644 --- a/sysdeps/posix/pause.c +++ b/sysdeps/posix/pause.c @@ -38,5 +38,3 @@ __libc_pause (void) return __sigsuspend (&set); } weak_alias (__libc_pause, pause) - -LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */ diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c index db9df8eb6e..9a17d1b5d6 100644 --- a/sysdeps/posix/sigpause.c +++ b/sysdeps/posix/sigpause.c @@ -70,6 +70,3 @@ __xpg_sigpause (int sig) return __sigpause (sig, 1); } strong_alias (__xpg_sigpause, __libc___xpg_sigpause) - -/* __sigsuspend handles cancellation. */ -LIBC_CANCEL_HANDLED (); diff --git a/sysdeps/unix/sysv/linux/creat.c b/sysdeps/unix/sysv/linux/creat.c index c996cbd3cc..089a8692f2 100644 --- a/sysdeps/unix/sysv/linux/creat.c +++ b/sysdeps/unix/sysv/linux/creat.c @@ -35,6 +35,4 @@ __creat (const char *file, mode_t mode) } weak_alias (__creat, creat) -LIBC_CANCEL_HANDLED (); - #endif diff --git a/sysdeps/unix/sysv/linux/creat64.c b/sysdeps/unix/sysv/linux/creat64.c index d3ada38c9c..c9eba2ec5e 100644 --- a/sysdeps/unix/sysv/linux/creat64.c +++ b/sysdeps/unix/sysv/linux/creat64.c @@ -37,5 +37,3 @@ weak_alias (__creat64, creat64) strong_alias (__creat64, __creat) weak_alias (__creat64, creat) #endif - -LIBC_CANCEL_HANDLED (); diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c index 920c924c9c..18ef2cf574 100644 --- a/sysdeps/unix/sysv/linux/sigwait.c +++ b/sysdeps/unix/sysv/linux/sigwait.c @@ -37,6 +37,3 @@ __sigwait (const sigset_t *set, int *sig) libc_hidden_def (__sigwait) weak_alias (__sigwait, sigwait) strong_alias (__sigwait, __libc_sigwait) - -/* __sigtimedwait handles cancellation. */ -LIBC_CANCEL_HANDLED (); diff --git a/sysdeps/unix/sysv/linux/sigwaitinfo.c b/sysdeps/unix/sysv/linux/sigwaitinfo.c index 55003fc516..71bdc943a0 100644 --- a/sysdeps/unix/sysv/linux/sigwaitinfo.c +++ b/sysdeps/unix/sysv/linux/sigwaitinfo.c @@ -28,6 +28,3 @@ __sigwaitinfo (const sigset_t *set, siginfo_t *info) libc_hidden_def (__sigwaitinfo) weak_alias (__sigwaitinfo, sigwaitinfo) strong_alias (__sigwaitinfo, __libc_sigwaitinfo) - -/* __sigtimedwait handles cancellation. */ -LIBC_CANCEL_HANDLED (); From patchwork Tue Sep 4 20:45:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145963 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4124914ljw; Tue, 4 Sep 2018 13:46:41 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2Okv8IjfUqzk2XYXj32YsGGQWJiJyF+V44aIyEY1BQxILjyBFGGkdRivTI2RbTNn7SkRK X-Received: by 2002:a17:902:6b83:: with SMTP id p3-v6mr35665424plk.133.1536094001573; Tue, 04 Sep 2018 13:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536094001; cv=none; d=google.com; s=arc-20160816; b=F+mgLhjy6sGFnKhrsSM3OO2SHZlXzHRh8QrL4pkSFYFJ1o+w3ypKtsz4YYJTtrUgxl fw490ps5le+FzoUt+MIuhE8iGXR30VBn2fLwLx0N1hm0zIFuhr5K+3Y3Z9FTJrgy8qnc JhRixg0R/HsbF9qjBNsoULmTpoPkXi4aOwdgiLMcg7zRU3OQahCe8ms8YBhOMWUX0BlN mX9alsnuXRvWg6UnalkNYuk03xb9KazbwkDEIDPW4+WrctHXdqBI8Rz+K0mz/+z5AGvq SXRs49ehMiuszf6ce1R1VQiyiSHYnOr041P1BrFL6W5/ZKC2HO5yqPQGseGrhSHWpvrm vxSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=sHwaooOHDVgMVCIgf5T3xOkXrhPOlcRRg5pvWasicX4=; b=hih+qyP6lH4M6MlHp2iFQF2ZJVUtGHDBD6mJKTEQNIpEA8OSs+Ec/tOvdByrWNR+0U MtejZaib7eK1pyzvIfL+2mZpY/T2vdyjn+6WdZRONEhKOICVxve7DStIHHaUEFseJdLt 6FDQ2LOsszy8O43mvvLAi2zRsew30p9Ju0aUtDAhNEJWonmknroCxTaC0lOFQbkG7ztq irgc8X3V2Tvw+YlYY/X0MmgcIRDrcglC6MAUyZcvLdHDnTg66IT+YW02kM3tAgpmnuun 1LGOhcP/3O13kBQuQ87rw3hVaWcKOiOnrZHCD58gx171dYdCzwJFEPa9tjGthO8XHjqu h3Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=szORMA4E; dkim=pass header.i=@linaro.org header.s=google header.b=QPRF5VID; spf=pass (google.com: domain of libc-alpha-return-95670-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95670-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m14-v6si22680135pgc.368.2018.09.04.13.46.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95670-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=szORMA4E; dkim=pass header.i=@linaro.org header.s=google header.b=QPRF5VID; spf=pass (google.com: domain of libc-alpha-return-95670-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95670-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=n55jTf1gjfFBesBZdhgqOQXQPG0/S1k XjbVS33qhfMUtfMMlyWnXpEJ9fZWun7dmZKSVByeWs4whfv5Rqnx5FYlA2xGB6Nv Vs1ez/UJSmvwZGexZdccAD6FA8xMYqFc6wskxTR6TEjbAHCgWfl6urBn0tsMgbbX UM9lyBh0/pxk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=FBJi2oDFWGZLoeXbyfd9w+be9v4=; b=szORM A4EqoVS/2xOkzG77A5XpFA95xnPPfXdm2YSlCD8604Sc4ez6ccFHpTBdBlgiuM5m 2ccD2gAh/9+YbColNxCUWYeoVYUv5FaMwpYpKnXnJyB8cHcBs9pXkHbignN9Bh2G PgP4gQeCqhwDRsDQbrKnkRmb4FAuSS20cVFfs4= Received: (qmail 34145 invoked by alias); 4 Sep 2018 20:46:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 33982 invoked by uid 89); 4 Sep 2018 20:46:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=blocked, cancelled, sk:arm-lin, sk:armlin X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sHwaooOHDVgMVCIgf5T3xOkXrhPOlcRRg5pvWasicX4=; b=QPRF5VIDNZarI86wpZEzd9B9aCSXwVVnEEai7F+Ko1HzCa3a0V/SkGAYLSZyeZKTpC DIP3EgUgBCULqrzU2ykyDXisTA3EIoHAtayXZn5SbwggfHeYOFSEqDzabS6mQ+++EQPU NG4E+uPPcz0kLk0f/XUjGjYaXG7im80NGBs+4= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH 3/7] nptl: Fix testcases for new pthread cancellation mechanism Date: Tue, 4 Sep 2018 17:45:49 -0300 Message-Id: <20180904204553.6971-4-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> From: Adhemerval Zanella With upcoming fix for BZ#12683, pthread cancellation does not act for: 1. If syscall is blocked but with some side effects already having taken place (e.g. a partial read or write). 2. After the syscall has returned. The main change is due the fact programs need to act in syscalls with side-effects (for instance, to avoid leak of allocated resources or handle partial read/write). This patch changes the NPTL testcase that assumes the old behavior and also changes the tst-backtrace{5,6} to ignore the cancellable wrappers. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc-linux-gnu, sparcv9-linux-gnu, and sparc64-linux-gnu. * debug/tst-backtrace5.c (handle_signal): Avoid cancellable wrappers in backtrace analysis. * nptl/tst-cancel4.c (tf_write): Handle cancelled syscall with side-effects. (tf_send): Likewise. --- ChangeLog | 6 ++++++ debug/tst-backtrace5.c | 19 ++++++++++--------- nptl/tst-cancel4.c | 8 ++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/debug/tst-backtrace5.c b/debug/tst-backtrace5.c index 0e6fb1a024..dad741e12a 100644 --- a/debug/tst-backtrace5.c +++ b/debug/tst-backtrace5.c @@ -69,17 +69,18 @@ handle_signal (int signum) FAIL (); return; } - /* Do not check name for signal trampoline. */ - i = 2; - if (!match (symbols[i++], "read")) + + /* Do not check name for signal trampoline or cancellable syscall + wrappers (__syscall_cancel*). */ + for (; i < n - 1; i++) + if (match (symbols[i], "read")) + break; + if (i == n - 1) { - /* Perhaps symbols[2] is __kernel_vsyscall? */ - if (!match (symbols[i++], "read")) - { - FAIL (); - return; - } + FAIL (); + return; } + for (; i < n - 1; i++) if (!match (symbols[i], "fn")) { diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 05325385b1..45b3d43c3b 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -166,6 +166,10 @@ tf_write (void *arg) char buf[WRITE_BUFFER_SIZE]; memset (buf, '\0', sizeof (buf)); s = write (fd, buf, sizeof (buf)); + /* The write can return a value higher than 0 (meaning partial write) + due to the SIGCANCEL, but the thread may still be pending + cancellation. */ + pthread_testcancel (); pthread_cleanup_pop (0); @@ -743,6 +747,10 @@ tf_send (void *arg) char mem[WRITE_BUFFER_SIZE]; send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0); + /* The send can return a value higher than 0 (meaning partial send) + due to the SIGCANCEL, but the thread may still be pending + cancellation. */ + pthread_testcancel (); pthread_cleanup_pop (0); From patchwork Tue Sep 4 20:45:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145964 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4125072ljw; Tue, 4 Sep 2018 13:46:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbVldUb2M0GBjV3mBq5kSmD3mB6skn1mdb+QrvUICavQE3BLHfELDURscW+nBVtlYEiLyKk X-Received: by 2002:a62:7088:: with SMTP id l130-v6mr28840759pfc.84.1536094012945; Tue, 04 Sep 2018 13:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536094012; cv=none; d=google.com; s=arc-20160816; b=WmDSPmr+I+dUxpd+YWtpbAWfegPQkDjZLaGjz5gANXFdY/lWS2XQ/2C5tXnymD/ZS7 nSej8l53r6E3h81z7AQlix+i4+XGb4dRw5c5gYQrKF/+CH20y9jA0dDVffO2iG/sRCeA WdiNzfsBiMwA4Ea3OrvDCKcZLDwqhCcyxaa/zhPbQXJTauxeG28WtxLjd2zwdL4RPYGw X+QUA5EtVFh3eQeNXEPbwbE+GDRtxDxpzKYhJkjHLRraxknBPgdnbpZcwD5ROPoJD7b0 igOYPXdKt5r6kgpG4vQ+jqMNOatDz3UZdJ/JXRuc99d5KkNAhycB6M6qJDfIEPOc5B+C SXoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=gzhUnGrl2CIILyE/qLsnzPtwIrjHGrO0EU8entvzrpg=; b=lxnQBqbyWombvaE0J8iRTZZgaxXyoe0lfgWGHGsF9P0KpqM466HHgGe3UD4Iqpd66l hPCWCog6SLDxARP0HCGw0HWszTH1LyYMahgChlbmSzSetodIGHj2s/AiU/l4fOFBvG9j CIS7zIn0GdVHJ4+anHJlYLZEo/T5Oh9RUkqwWP8q3Z7DAlgEIZdV84GaAN3G1QVmjdbr Mg871CWR6NUPhM0gQ7e1pTVsFnUxZWb4hMp7zA0njJgMAe7TBNpgbyt2/nT2DEpVWo7x mIcQUHiuTgn9XqsHSeZahkYO57aoTMYvgNYCBk/+xSpdRCQsISx+yZWV+6PAZDuO4R8M kKXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BuCzRW5c; dkim=pass header.i=@linaro.org header.s=google header.b=LSsIFyzO; spf=pass (google.com: domain of libc-alpha-return-95671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95671-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j23-v6si21833303pgn.139.2018.09.04.13.46.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BuCzRW5c; dkim=pass header.i=@linaro.org header.s=google header.b=LSsIFyzO; spf=pass (google.com: domain of libc-alpha-return-95671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95671-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=XqwLxg1P1ambzOAXSgD1T34KxFPm1Zk 4CWvQ4wocuBjHSf0jeVmf/ExB1SDKK5160liTyswoH6GokzCCsKJoOz0DEAX600i AZz6a3bBC38zEt23te/fpu3GHXB5hutU9nyrxK9zpRHsh/BhL0wGIofoj0QuxSlv OFTe8EcGe2+Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=J3wIIrY3fxfSAaeR/zeqglPu78M=; b=BuCzR W5cQWWlHWwsok4mZosN1Kgb3z8pl1DZxkTh1NCIkxG2FOE5ldtkVKd7k/QUYOnd1 4zaYi3hfmsWACIlc4a2r30xSnaaCDtu/cGZqb5kMsDOQUGuWdSc+Gb1KhEGG5YDB mWMbk8iAojo0Dlr1VsiX5PjixDbzsah7z73p9Q= Received: (qmail 34345 invoked by alias); 4 Sep 2018 20:46:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 34146 invoked by uid 89); 4 Sep 2018 20:46:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=proves, expects X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=gzhUnGrl2CIILyE/qLsnzPtwIrjHGrO0EU8entvzrpg=; b=LSsIFyzOtsD/rDSOKKw/n2Tv6wUkfXtOIaN68E4TgnhCgiX7JWecNNo2wi/IHj/sma N5xoI/IHmRAeyJmGSX/f1BEfT9+WXVtsbSMUI0Dn8Y095NJJqHEuiTURQdWeLrpvpZfS vql2A65P0zvHXLJVj/dubNyXE/WHoIemtx5uk= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 4/7] x86: Remove wrong THREAD_ATOMIC_* macros Date: Tue, 4 Sep 2018 17:45:50 -0300 Message-Id: <20180904204553.6971-5-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> The x86 defines optimized THREAD_ATOMIC_* macros where reference always the current thread instead of the one indicated by input 'descr' argument. It work as long the input is the self thread pointer, however it generates wrong code is the semantic is to set a bit atomicialy from another thread. This is not an issue for current GLIBC usage, however the new cancellation code expects that some synchronization code to atomically set bits from different threads. The generic code generates an additional load to reference to TLS segment, for instance the code: THREAD_ATOMIC_BIT_SET (THREAD_SELF, cancelhandling, CANCELED_BIT); Compiles to: lock;orl $4, %fs:776 Where with patch changes it now compiles to: mov %fs:16,%rax lock;orl $4, 776(%rax) If some usage indeed proves to be a hotspot we can add an extra macro with a more descriptive name (THREAD_ATOMIC_BIT_SET_SELF for instance) where x86_64 might optimize it. Checked on x86_64-linux-gnu. * sysdeps/x86_64/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL, THREAD_ATOMIC_AND, THREAD_ATOMIC_BIT_SET): Remove macros. --- ChangeLog | 3 +++ sysdeps/x86_64/nptl/tls.h | 37 ------------------------------------- 2 files changed, 3 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h index e88561c934..835a0d3deb 100644 --- a/sysdeps/x86_64/nptl/tls.h +++ b/sysdeps/x86_64/nptl/tls.h @@ -306,43 +306,6 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80, }}) -/* Atomic compare and exchange on TLS, returning old value. */ -# define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval) \ - ({ __typeof (descr->member) __ret; \ - __typeof (oldval) __old = (oldval); \ - if (sizeof (descr->member) == 4) \ - asm volatile (LOCK_PREFIX "cmpxchgl %2, %%fs:%P3" \ - : "=a" (__ret) \ - : "0" (__old), "r" (newval), \ - "i" (offsetof (struct pthread, member))); \ - else \ - /* Not necessary for other sizes in the moment. */ \ - abort (); \ - __ret; }) - - -/* Atomic logical and. */ -# define THREAD_ATOMIC_AND(descr, member, val) \ - (void) ({ if (sizeof ((descr)->member) == 4) \ - asm volatile (LOCK_PREFIX "andl %1, %%fs:%P0" \ - :: "i" (offsetof (struct pthread, member)), \ - "ir" (val)); \ - else \ - /* Not necessary for other sizes in the moment. */ \ - abort (); }) - - -/* Atomic set bit. */ -# define THREAD_ATOMIC_BIT_SET(descr, member, bit) \ - (void) ({ if (sizeof ((descr)->member) == 4) \ - asm volatile (LOCK_PREFIX "orl %1, %%fs:%P0" \ - :: "i" (offsetof (struct pthread, member)), \ - "ir" (1 << (bit))); \ - else \ - /* Not necessary for other sizes in the moment. */ \ - abort (); }) - - /* Set the stack guard field in TCB head. */ # define THREAD_SET_STACK_GUARD(value) \ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value) From patchwork Tue Sep 4 20:45:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145965 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4125179ljw; Tue, 4 Sep 2018 13:47:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYs0/5ws39M4tk4s8Q5QXmRuLruZBTZ6/5hN8LcOsAQpBI3Eu0imHVYYuVpwZuWbOOCSP1x X-Received: by 2002:a65:594b:: with SMTP id g11-v6mr32828906pgu.260.1536094022837; Tue, 04 Sep 2018 13:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536094022; cv=none; d=google.com; s=arc-20160816; b=dOD5MNg3sdSBmN3wvYqGFSrEA+zFeSq6An01Rtj24FSWOgHgX2RPIez/jg8lLabgy6 Ef7DhQfE/v1/03E653JFUku7wPg6AfmEHIpQPazaWGFYrtwGYDCghFjLJxDuxaPdKk1Y Y0pAgElYbsUKovqSAG+2hnwGo39C8iAUOSjR7KehQ47OkauNsO2/RLrPHIwgWJfAOePK XEvhKTOsuBUlaxcXZEVICdakZsHL1qpzDvMvnNdAr8EWaEbcmg/GUJ6of4/CJE88xplx x3kmQ+bDw0m9wmCnhg7l4XZAidbMusw60OGlKusf7AJOiDEoElPvKcg4bKzNFxPJhDLN aU1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=qhYe6UrU7SVOJ3qWYli9JzPtOcdsQDWefh1Yi6BmuIA=; b=bre0CYtGnrS1wyGnpdmk8HVLgHOayymlohZpHWfxbjDDC5isF7NKx1Mq6koJFjVf01 l/Xg0DcUmp26tc7RiGzTfMloBbXWb0e7QaAz/CW2QUJ8SFgID95fJqTPaqPph4SM7e8d MgUo/Gby5pQRkYrlPZDv2fDbUhmTvw15KrFykACe8ToYlJO426QmU4b24W3vPVDW5Bp4 OQTCMi5Lt2N6rOpieN/49kSm6n4SVNUEXdTSZZzp3p+ikJraeM7AAEwqeBAaj2ol3By2 DXyAhV9VIs9A8ImKLGUCaQAqC91599Y4rSQcfZGVaGnc28noyC55GphdAFutVY//Gnc3 wWlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pwHpJ4lS; dkim=pass header.i=@linaro.org header.s=google header.b=iAfrz1HE; spf=pass (google.com: domain of libc-alpha-return-95672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95672-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e68-v6si22069700plb.38.2018.09.04.13.47.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pwHpJ4lS; dkim=pass header.i=@linaro.org header.s=google header.b=iAfrz1HE; spf=pass (google.com: domain of libc-alpha-return-95672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95672-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=yiVwDm6Xg71xW6N4tyZJznBCNHc9NSj DtId/sQqSgxwe+yJs298usZ0qh5gCDLs5pI85ROtlwVHsrJ2ZmmeOOwYx3PxXaCc yfM0kL/q37ZHZr7Ah1z9iA1rXbMAb8l6mQ18mG5vpPSiKxWOYHmZtjctX35nEk9j 6AnZ3Z37FJhY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=c2X9oJGmZoB1k+zVLGIoO+KMXpY=; b=pwHpJ 4lSnfA0rxF35Ez4tbdHV8J4JEAK4ZonW00nKpHyisNsroIZmvLQNyh4dBe1Jk5iR bK1Ylvn/9VZeKDZhQqESsYCrs3AXls1UEwOf9vvxJhaUwVvVxUkHfHZjC/9XmHNq 9eeV3CqO00HyfAQ4amRXgY5OolFNkVhNLdXGMc= Received: (qmail 34534 invoked by alias); 4 Sep 2018 20:46:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 34394 invoked by uid 89); 4 Sep 2018 20:46:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=proves, Hx-languages-length:2502, expects X-HELO: mail-qk1-f170.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=qhYe6UrU7SVOJ3qWYli9JzPtOcdsQDWefh1Yi6BmuIA=; b=iAfrz1HEVERF7vPHpHHjmjxkRDj1ixMw5jE/kOV+WFKzB1KwbmFusaJ/zOcbOPLNvq 01GDBflMvN/erCs1sIG+zTl3Q9GF0yfxo/KwPzNt65zFh7Kgbo7Dwr4UqplSLAAKhkb4 E1v0YC/soL9L2KN5ZOuNH5GNN9e2zZPG/3BTg= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/7] i386: Remove bogus THREAD_ATOMIC_* macros Date: Tue, 4 Sep 2018 17:45:51 -0300 Message-Id: <20180904204553.6971-6-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> The x86 defines optimized THREAD_ATOMIC_* macros where reference always the current thread instead of the one indicated by input 'descr' argument. It work as long the input is the self thread pointer, however it generates wrong code is the semantic is to set a bit atomicialy from another thread. This is not an issue for current GLIBC usage, however the new cancellation code expects that some synchronization code to atomically set bits from different threads. If some usage indeed proves to be a hotspot we can add an extra macro with a more descriptive name (THREAD_ATOMIC_BIT_SET_SELF for instance) where i386 might optimize it. Checked on i686-linux-gnu. * sysdeps/i686/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL, THREAD_ATOMIC_AND, THREAD_ATOMIC_BIT_SET): Remove macros. --- ChangeLog | 3 +++ sysdeps/i386/nptl/tls.h | 37 ------------------------------------- 2 files changed, 3 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h index 12285d3217..22ebf3d741 100644 --- a/sysdeps/i386/nptl/tls.h +++ b/sysdeps/i386/nptl/tls.h @@ -362,43 +362,6 @@ tls_fill_user_desc (union user_desc_init *desc, }}) -/* Atomic compare and exchange on TLS, returning old value. */ -#define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval) \ - ({ __typeof (descr->member) __ret; \ - __typeof (oldval) __old = (oldval); \ - if (sizeof (descr->member) == 4) \ - asm volatile (LOCK_PREFIX "cmpxchgl %2, %%gs:%P3" \ - : "=a" (__ret) \ - : "0" (__old), "r" (newval), \ - "i" (offsetof (struct pthread, member))); \ - else \ - /* Not necessary for other sizes in the moment. */ \ - abort (); \ - __ret; }) - - -/* Atomic logical and. */ -#define THREAD_ATOMIC_AND(descr, member, val) \ - (void) ({ if (sizeof ((descr)->member) == 4) \ - asm volatile (LOCK_PREFIX "andl %1, %%gs:%P0" \ - :: "i" (offsetof (struct pthread, member)), \ - "ir" (val)); \ - else \ - /* Not necessary for other sizes in the moment. */ \ - abort (); }) - - -/* Atomic set bit. */ -#define THREAD_ATOMIC_BIT_SET(descr, member, bit) \ - (void) ({ if (sizeof ((descr)->member) == 4) \ - asm volatile (LOCK_PREFIX "orl %1, %%gs:%P0" \ - :: "i" (offsetof (struct pthread, member)), \ - "ir" (1 << (bit))); \ - else \ - /* Not necessary for other sizes in the moment. */ \ - abort (); }) - - /* Set the stack guard field in TCB head. */ #define THREAD_SET_STACK_GUARD(value) \ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value) From patchwork Tue Sep 4 20:45:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145967 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4125406ljw; Tue, 4 Sep 2018 13:47:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0za7bZBHfEVySwpMh5P7/dTWO16SuxrHNF+L95aIi6pDS0+7OM8sGQwCWlU9sumoklIY8 X-Received: by 2002:a62:6a01:: with SMTP id f1-v6mr4559983pfc.156.1536094042854; Tue, 04 Sep 2018 13:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536094042; cv=none; d=google.com; s=arc-20160816; b=Ar9kAKNnr5bHi4/F/wdRhPqOUvXdB1GtZgTmmTny1L4zMQ8vllOBOHs9OFvccC3wIL hVhiPjq25AGROwfj+GaHKL2bI4WUYkULg37J4WK+RzilxMWUm+bdsrh2c8NpLcZkBiV0 V2LjYnhf1eDA1zKpS9EU4eKsefcapFXGqWviW1NuaRiTNc6ac03EvQ5YBp/r9qqRB4Rv TMetKnN5EaHnGkp6wGgKi1RrF2MNXQ/u7ELRubofQ6du9AW6K6RYWf3TUWazc5Gd2/8A c+3EuiVcthp1N/FqEr7CuKEMebegWtv6wtZaVJL/G3mNdEf425uuenvHAfBvHbpYWExq H8Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=Jg5FMyulyTLN+Fb7rXtkjunYEzz3j7CB2Il4MgzQaMU=; b=v7aeYY4AoYYhUg7SYXudojof85/9iepUpXDS6x0wGZPfwT0ew/qr5FfpSrHVUs/uWu 2GeCxpwwNO2awGWk3hbd2uhHtR7lg5Nb29Fq8nolTNBw120kzI4FfQcN21NOdrRqB6Dw Iweb3dGUmU0wUToNZmOCaYg18tDCmj6Ng2fGAML0h0gq0FLPQyZvUXn3ItNiNkdQtzCU ps1InJ+nVgCrvYbMdPdTo/fVecIjusk1pUbHy+WhaYwCwi7JHreo0AAofd6cZ9tHRw59 shk6YfkQq1/ZTWMzMcjnG4RvMIFoJ8gll3Xh/DscCCshq1xPUiMESYALT3CWexRK8a0m 2DKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=SZn8qnIb; dkim=pass header.i=@linaro.org header.s=google header.b=XDxIDugF; spf=pass (google.com: domain of libc-alpha-return-95674-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95674-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u13-v6si22506390pgg.263.2018.09.04.13.47.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95674-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=SZn8qnIb; dkim=pass header.i=@linaro.org header.s=google header.b=XDxIDugF; spf=pass (google.com: domain of libc-alpha-return-95674-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95674-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=xwntBMxu0dIIw+AR4bAizak1e41T+NR 2Tq/khhDUtuCJmGW1tJnk+6BxSQ9DAr9F4b8LjlhingTWqS+LP9bFCzdZD5g8dYL 5TShlxuSJMgMNR+FKcfE9JvGcV5+VCilja4TQqzLCEsmM9IkKyEIylRqSJTaNolF TZkaEC9D1OAk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=2NRTH0NcSYTfGBxlGCA2fj3XZ6E=; b=SZn8q nIbOMyRMkokUEiur5Dbbh+aIlj7yLiDSqUQHZe8CMocJjyiEqXrGo80sIwgbxxB8 dEj0Uw98S35jF5UzdfN7GWaEc+OmmYtqSS9AQsGYsiG8duman6WP9bhrpxTSO5HY nGPPOGkxZpi8KwDiI6z/Mriz8KvcPfCA3uwMfw= Received: (qmail 35220 invoked by alias); 4 Sep 2018 20:46:16 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 35112 invoked by uid 89); 4 Sep 2018 20:46:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=acquire, HX-Received:sk:b1-v6mr, wakeup X-HELO: mail-qt0-f176.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Jg5FMyulyTLN+Fb7rXtkjunYEzz3j7CB2Il4MgzQaMU=; b=XDxIDugF0AJh3kQ0ZGDUus8CRDxkCKLR1l/r+hJFabZ0LbbZolGuGa/e78AW4Zuxjl pcBUxkUoo0l9NmkGOtEEv9ZA+kDEihWZXHC6fKrhrzM0NzqIlIkqbQgXcM4eDKEdqr1B DsjGR8zfwMcT+z3t9j+Z7Q6GNFdu4ueUsWJF0= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/7] nptl: Cleanup cancellation macros Date: Tue, 4 Sep 2018 17:45:52 -0300 Message-Id: <20180904204553.6971-7-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> This patch wraps all uses of *_{enable,disable}_asynccancel and and *_CANCEL_{ASYNC,RESET} in either already provided macros (lll_futex_timed_wait_cancel) or creates new ones if the functionality is not provided (SYSCALL_CANCEL_NCS, lll_futex_wait_cancel, and lll_futex_timed_wait_cancel). Also for some generic implementations, the direct call of the macros are removed since the underlying symbols are suppose to provide cancellation support. This is a priliminary patch intended to simplify the work required for BZ#12683 fix. It is a refactor change, no semantic changes are expected. Checked on x86_64-linux-gnu and i686-linux-gnu. * nptl/pthread_join_common.c (__pthread_timedjoin_ex): Use lll_wait_tid with timeout. * nptl/sem_wait.c (__old_sem_wait): Use lll_futex_wait_cancel. * sysdeps/nptl/aio_misc.h (AIO_MISC_WAIT): Use futex_reltimed_wait_cancelable for cancelabla mode. * sysdeps/nptl/gai_misc.h (GAI_MISC_WAIT): Likewise. * sysdeps/posix/open64.c (__libc_open64): Do not call cancelation macros. * sysdeps/posix/sigwait.c (__sigwait): Likewise. * sysdeps/posix/waitid.c (__sigwait): Likewise. * sysdeps/unix/sysdep.h (__SYSCALL_CANCEL_CALL, SYSCALL_CANCEL_NCS): New macro. * sysdeps/nptl/lowlevellock.h (lll_wait_tid): Add timeout argument. (lll_timedwait_tid): Remove macro. * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_wait_tid): Likewise. (lll_timedwait_tid): Likewise. * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (lll_wait_tid): Likewise. (lll_timedwait_tid): Likewise. * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_wait_tid): Likewise. (lll_timedwait_tid): Likewise. * sysdeps/unix/sysv/linux/clock_nanosleep.c (__clock_nanosleep): Use INTERNAL_SYSCALL_CANCEL. * sysdeps/unix/sysv/linux/futex-internal.h (futex_reltimed_wait_cancelable): Use LIBC_CANCEL_{ASYNC,RESET} instead of __pthread_{enable,disable}_asynccancel. * sysdeps/unix/sysv/linux/lowlevellock-futex.h (lll_futex_wait_cancel): New macro. --- ChangeLog | 31 ++++++++++++++ nptl/pthread_join_common.c | 9 +--- nptl/sem_wait.c | 8 +--- sysdeps/nptl/aio_misc.h | 15 +++---- sysdeps/nptl/gai_misc.h | 15 +++---- sysdeps/nptl/lowlevellock.h | 40 ++++++++---------- sysdeps/posix/open64.c | 12 +----- sysdeps/posix/sigwait.c | 12 +----- sysdeps/posix/waitid.c | 12 +----- sysdeps/unix/sysv/linux/clock_nanosleep.c | 23 ++++------ sysdeps/unix/sysv/linux/futex-internal.h | 4 +- sysdeps/unix/sysv/linux/i386/lowlevellock.h | 42 +++++++++---------- sysdeps/unix/sysv/linux/lowlevellock-futex.h | 11 +++++ sysdeps/unix/sysv/linux/sparc/lowlevellock.h | 39 ++++++++--------- sysdeps/unix/sysv/linux/x86_64/lowlevellock.h | 40 +++++++++--------- 15 files changed, 148 insertions(+), 165 deletions(-) -- 2.17.1 diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c index 702fcd1545..63d693210d 100644 --- a/nptl/pthread_join_common.c +++ b/nptl/pthread_join_common.c @@ -81,14 +81,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return, un-wait-ed for again. */ pthread_cleanup_push (cleanup, &pd->joinid); - int oldtype = CANCEL_ASYNC (); - - if (abstime != NULL) - result = lll_timedwait_tid (pd->tid, abstime); - else - lll_wait_tid (pd->tid); - - CANCEL_RESET (oldtype); + result = lll_wait_tid (pd->tid, abstime); pthread_cleanup_pop (0); } diff --git a/nptl/sem_wait.c b/nptl/sem_wait.c index e7d910613f..e057b05dd6 100644 --- a/nptl/sem_wait.c +++ b/nptl/sem_wait.c @@ -56,14 +56,8 @@ __old_sem_wait (sem_t *sem) if (atomic_decrement_if_positive (futex) > 0) return 0; - /* Enable asynchronous cancellation. Required by the standard. */ - int oldtype = __pthread_enable_asynccancel (); - /* Always assume the semaphore is shared. */ - err = lll_futex_wait (futex, 0, LLL_SHARED); - - /* Disable asynchronous cancellation. */ - __pthread_disable_asynccancel (oldtype); + err = lll_futex_wait_cancel (futex, 0, LLL_SHARED); } while (err == 0 || err == -EWOULDBLOCK); diff --git a/sysdeps/nptl/aio_misc.h b/sysdeps/nptl/aio_misc.h index 206d8e193d..70f1e057b5 100644 --- a/sysdeps/nptl/aio_misc.h +++ b/sysdeps/nptl/aio_misc.h @@ -41,15 +41,15 @@ { \ pthread_mutex_unlock (&__aio_requests_mutex); \ \ - int oldtype; \ - if (cancel) \ - oldtype = LIBC_CANCEL_ASYNC (); \ - \ int status; \ do \ { \ - status = futex_reltimed_wait ((unsigned int *) futexaddr, oldval, \ - timeout, FUTEX_PRIVATE); \ + if (cancel) \ + status = futex_reltimed_wait_cancelable ( \ + (unsigned int *) futexaddr, oldval, timeout, FUTEX_PRIVATE); \ + else \ + status = futex_reltimed_wait ((unsigned int *) futexaddr, \ + oldval, timeout, FUTEX_PRIVATE); \ if (status != EAGAIN) \ break; \ \ @@ -57,9 +57,6 @@ } \ while (oldval != 0); \ \ - if (cancel) \ - LIBC_CANCEL_RESET (oldtype); \ - \ if (status == EINTR) \ result = EINTR; \ else if (status == ETIMEDOUT) \ diff --git a/sysdeps/nptl/gai_misc.h b/sysdeps/nptl/gai_misc.h index 815e6c0dc6..831b43a479 100644 --- a/sysdeps/nptl/gai_misc.h +++ b/sysdeps/nptl/gai_misc.h @@ -42,15 +42,15 @@ { \ pthread_mutex_unlock (&__gai_requests_mutex); \ \ - int oldtype; \ - if (cancel) \ - oldtype = LIBC_CANCEL_ASYNC (); \ - \ int status; \ do \ { \ - status = futex_reltimed_wait ((unsigned int *) futexaddr, oldval, \ - timeout, FUTEX_PRIVATE); \ + if (cancel) \ + status = futex_reltimed_wait_cancelable ( \ + (unsigned int *) futexaddr, oldval, timeout, FUTEX_PRIVATE); \ + else \ + status = futex_reltimed_wait ((unsigned int *) futexaddr, \ + oldval, timeout, FUTEX_PRIVATE); \ if (status != EAGAIN) \ break; \ \ @@ -58,9 +58,6 @@ } \ while (oldval != 0); \ \ - if (cancel) \ - LIBC_CANCEL_RESET (oldtype); \ - \ if (status == EINTR) \ result = EINTR; \ else if (status == ETIMEDOUT) \ diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h index bfbda99940..d7837be5d4 100644 --- a/sysdeps/nptl/lowlevellock.h +++ b/sysdeps/nptl/lowlevellock.h @@ -175,33 +175,29 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *, #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) +extern int __lll_timedwait_tid (int *, const struct timespec *) + attribute_hidden; /* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex wake-up when the clone terminates. The memory location contains the thread ID while the clone is running and is reset to zero by the kernel afterwards. The kernel up to version 3.16.3 does not use the private futex - operations for futex wake-up when the clone terminates. */ -#define lll_wait_tid(tid) \ - do { \ - __typeof (tid) __tid; \ - /* We need acquire MO here so that we synchronize \ - with the kernel's store to 0 when the clone \ - terminates. (see above) */ \ - while ((__tid = atomic_load_acquire (&(tid))) != 0) \ - lll_futex_wait (&(tid), __tid, LLL_SHARED); \ - } while (0) - -extern int __lll_timedwait_tid (int *, const struct timespec *) - attribute_hidden; - -/* As lll_wait_tid, but with a timeout. If the timeout occurs then return - ETIMEDOUT. If ABSTIME is invalid, return EINVAL. */ -#define lll_timedwait_tid(tid, abstime) \ - ({ \ - int __res = 0; \ - if ((tid) != 0) \ - __res = __lll_timedwait_tid (&(tid), (abstime)); \ - __res; \ + operations for futex wake-up when the clone terminates. + If ABSTIME is not NULL, is used a timeout for futex call. If the timeout + occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL. + The futex operation are issues with cancellable versions. */ +#define lll_wait_tid(tid, abstime) \ + ({ \ + int __res = 0; \ + __typeof (tid) __tid; \ + if (abstime != NULL) \ + __res = __lll_timedwait_tid (&(tid), (abstime)); \ + else \ + /* We need acquire MO here so that we synchronize with the \ + kernel's store to 0 when the clone terminates. (see above) */ \ + while ((__tid = atomic_load_acquire (&(tid))) != 0) \ + lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \ + __res; \ }) diff --git a/sysdeps/posix/open64.c b/sysdeps/posix/open64.c index c4209c8cdb..e4ec5d1876 100644 --- a/sysdeps/posix/open64.c +++ b/sysdeps/posix/open64.c @@ -34,16 +34,8 @@ __libc_open64 (const char *file, int oflag, ...) va_end (arg); } - if (SINGLE_THREAD_P) - return __libc_open (file, oflag | O_LARGEFILE, mode); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = __libc_open (file, oflag | O_LARGEFILE, mode); - - LIBC_CANCEL_RESET (oldtype); - - return result; + /* __libc_open should be a cancellation point. */ + return __libc_open (file, oflag | O_LARGEFILE, mode); } weak_alias (__libc_open64, __open64) libc_hidden_weak (__open64) diff --git a/sysdeps/posix/sigwait.c b/sysdeps/posix/sigwait.c index 4ff9d847d4..acc82e1965 100644 --- a/sysdeps/posix/sigwait.c +++ b/sysdeps/posix/sigwait.c @@ -85,16 +85,8 @@ do_sigwait (const sigset_t *set, int *sig) int __sigwait (const sigset_t *set, int *sig) { - if (SINGLE_THREAD_P) - return do_sigwait (set, sig); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_sigwait (set, sig); - - LIBC_CANCEL_RESET (oldtype); - - return result; + /* __sigsuspend should be a cancellation point. */ + return do_waitid (idtype, id, infop, options); } libc_hidden_def (__sigwait) weak_alias (__sigwait, sigwait) diff --git a/sysdeps/posix/waitid.c b/sysdeps/posix/waitid.c index 3207c742c2..98f35d078e 100644 --- a/sysdeps/posix/waitid.c +++ b/sysdeps/posix/waitid.c @@ -151,16 +151,8 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options) int __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) { - if (SINGLE_THREAD_P) - return do_waitid (idtype, id, infop, options); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_waitid (idtype, id, infop, options); - - LIBC_CANCEL_RESET (oldtype); - - return result; + /* __waitpid should be a cancellation point. */ + return do_waitid (idtype, id, infop, options); } weak_alias (__waitid, waitid) strong_alias (__waitid, __libc_waitid) diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 93d5d6ef12..31229bbd85 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -28,27 +28,18 @@ int __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, struct timespec *rem) { - INTERNAL_SYSCALL_DECL (err); - int r; - if (clock_id == CLOCK_THREAD_CPUTIME_ID) return EINVAL; if (clock_id == CLOCK_PROCESS_CPUTIME_ID) clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED); - if (SINGLE_THREAD_P) - r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem); - else - { - int oldstate = LIBC_CANCEL_ASYNC (); - - r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, - rem); - - LIBC_CANCEL_RESET (oldstate); - } - + /* If the call is interrupted by a signal handler or encounters an error, + it returns a positive value similar to errno. */ + INTERNAL_SYSCALL_DECL (err); + int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags, + req, rem); return (INTERNAL_SYSCALL_ERROR_P (r, err) - ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); + ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); + } weak_alias (__clock_nanosleep, clock_nanosleep) diff --git a/sysdeps/unix/sysv/linux/futex-internal.h b/sysdeps/unix/sysv/linux/futex-internal.h index 96a07b05b9..d36235a925 100644 --- a/sysdeps/unix/sysv/linux/futex-internal.h +++ b/sysdeps/unix/sysv/linux/futex-internal.h @@ -138,9 +138,9 @@ futex_reltimed_wait_cancelable (unsigned int *futex_word, const struct timespec *reltime, int private) { int oldtype; - oldtype = __pthread_enable_asynccancel (); + oldtype = LIBC_CANCEL_ASYNC (); int err = lll_futex_timed_wait (futex_word, expected, reltime, private); - __pthread_disable_asynccancel (oldtype); + LIBC_CANCEL_RESET (oldtype); switch (err) { case 0: diff --git a/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/sysdeps/unix/sysv/linux/i386/lowlevellock.h index 38fbc2556f..c0b938bd9f 100644 --- a/sysdeps/unix/sysv/linux/i386/lowlevellock.h +++ b/sysdeps/unix/sysv/linux/i386/lowlevellock.h @@ -221,32 +221,30 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count, #define lll_islocked(futex) \ (futex != LLL_LOCK_INITIALIZER) +extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) + __attribute__ ((regparm (2))) attribute_hidden; + /* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex wake-up when the clone terminates. The memory location contains the thread ID while the clone is running and is reset to zero by the kernel afterwards. The kernel up to version 3.16.3 does not use the private futex - operations for futex wake-up when the clone terminates. */ -#define lll_wait_tid(tid) \ - do { \ - __typeof (tid) __tid; \ - while ((__tid = (tid)) != 0) \ - lll_futex_wait (&(tid), __tid, LLL_SHARED);\ - } while (0) - -extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) - __attribute__ ((regparm (2))) attribute_hidden; - -/* As lll_wait_tid, but with a timeout. If the timeout occurs then return - ETIMEDOUT. If ABSTIME is invalid, return EINVAL. - XXX Note that this differs from the generic version in that we do the - error checking here and not in __lll_timedwait_tid. */ -#define lll_timedwait_tid(tid, abstime) \ - ({ \ - int __result = 0; \ - if ((tid) != 0) \ - __result = __lll_timedwait_tid (&(tid), (abstime)); \ - __result; }) - + operations for futex wake-up when the clone terminates. + If ABSTIME is not NULL, is used a timeout for futex call. If the timeout + occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL. + The futex operation are issues with cancellable versions. */ +#define lll_wait_tid(tid, abstime) \ + ({ \ + int __res = 0; \ + __typeof (tid) __tid; \ + if (abstime != NULL) \ + __res = __lll_timedwait_tid (&(tid), (abstime)); \ + else \ + /* We need acquire MO here so that we synchronize with the \ + kernel's store to 0 when the clone terminates. (see above) */ \ + while ((__tid = atomic_load_acquire (&(tid))) != 0) \ + lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \ + __res; \ + }) extern int __lll_lock_elision (int *futex, short *adapt_count, int private) attribute_hidden; diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h index fc834ed16e..71420fea89 100644 --- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h +++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h @@ -125,6 +125,17 @@ private), \ nr_wake, nr_move, mutex, val) + +/* Cancellable futex macros. */ +#define lll_futex_wait_cancel(futexp, val, private) \ + ({ \ + int __oldtype = CANCEL_ASYNC (); \ + long int __err = lll_futex_wait (futexp, val, LLL_SHARED); \ + CANCEL_RESET (__oldtype); \ + __err; \ + }) + + #endif /* !__ASSEMBLER__ */ #endif /* lowlevellock-futex.h */ diff --git a/sysdeps/unix/sysv/linux/sparc/lowlevellock.h b/sysdeps/unix/sysv/linux/sparc/lowlevellock.h index e2c0b2abaa..28f368dbe7 100644 --- a/sysdeps/unix/sysv/linux/sparc/lowlevellock.h +++ b/sysdeps/unix/sysv/linux/sparc/lowlevellock.h @@ -108,28 +108,29 @@ __lll_timedlock (int *futex, const struct timespec *abstime, int private) #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) -/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex - wakeup when the clone terminates. The memory location contains the - thread ID while the clone is running and is reset to zero - afterwards. */ -#define lll_wait_tid(tid) \ - do \ - { \ - __typeof (tid) __tid; \ - while ((__tid = (tid)) != 0) \ - lll_futex_wait (&(tid), __tid, LLL_SHARED); \ - } \ - while (0) - extern int __lll_timedwait_tid (int *, const struct timespec *) attribute_hidden; -#define lll_timedwait_tid(tid, abstime) \ - ({ \ - int __res = 0; \ - if ((tid) != 0) \ - __res = __lll_timedwait_tid (&(tid), (abstime)); \ - __res; \ +/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex + wake-up when the clone terminates. The memory location contains the + thread ID while the clone is running and is reset to zero by the kernel + afterwards. The kernel up to version 3.16.3 does not use the private futex + operations for futex wake-up when the clone terminates. + If ABSTIME is not NULL, is used a timeout for futex call. If the timeout + occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL. + The futex operation are issues with cancellable versions. */ +#define lll_wait_tid(tid, abstime) \ + ({ \ + int __res = 0; \ + __typeof (tid) __tid; \ + if (abstime != NULL) \ + __res = __lll_timedwait_tid (&(tid), (abstime)); \ + else \ + /* We need acquire MO here so that we synchronize with the \ + kernel's store to 0 when the clone terminates. (see above) */ \ + while ((__tid = atomic_load_acquire (&(tid))) != 0) \ + lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \ + __res; \ }) #endif /* lowlevellock.h */ diff --git a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h index eedb6fc990..3c5860d4cf 100644 --- a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h +++ b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h @@ -224,32 +224,30 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count, #define lll_islocked(futex) \ (futex != LLL_LOCK_INITIALIZER) +extern int __lll_timedwait_tid (int *, const struct timespec *) + attribute_hidden; /* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex wake-up when the clone terminates. The memory location contains the thread ID while the clone is running and is reset to zero by the kernel afterwards. The kernel up to version 3.16.3 does not use the private futex - operations for futex wake-up when the clone terminates. */ -#define lll_wait_tid(tid) \ - do { \ - __typeof (tid) __tid; \ - while ((__tid = (tid)) != 0) \ - lll_futex_wait (&(tid), __tid, LLL_SHARED);\ - } while (0) - -extern int __lll_timedwait_tid (int *, const struct timespec *) - attribute_hidden; - -/* As lll_wait_tid, but with a timeout. If the timeout occurs then return - ETIMEDOUT. If ABSTIME is invalid, return EINVAL. - XXX Note that this differs from the generic version in that we do the - error checking here and not in __lll_timedwait_tid. */ -#define lll_timedwait_tid(tid, abstime) \ - ({ \ - int __result = 0; \ - if ((tid) != 0) \ - __result = __lll_timedwait_tid (&(tid), (abstime)); \ - __result; }) + operations for futex wake-up when the clone terminates. + If ABSTIME is not NULL, is used a timeout for futex call. If the timeout + occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL. + The futex operation are issues with cancellable versions. */ +#define lll_wait_tid(tid, abstime) \ + ({ \ + int __res = 0; \ + __typeof (tid) __tid; \ + if (abstime != NULL) \ + __res = __lll_timedwait_tid (&(tid), (abstime)); \ + else \ + /* We need acquire MO here so that we synchronize with the \ + kernel's store to 0 when the clone terminates. (see above) */ \ + while ((__tid = atomic_load_acquire (&(tid))) != 0) \ + lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \ + __res; \ + }) extern int __lll_lock_elision (int *futex, short *adapt_count, int private) attribute_hidden; From patchwork Tue Sep 4 20:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 145966 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4125288ljw; Tue, 4 Sep 2018 13:47:12 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb4gk/Q6gZX+tBovaYn0r9GAEFJfg738ad2kyt5pYql5sFr+KuxtD8j7+zzWxU6u4iCjC8t X-Received: by 2002:a65:6110:: with SMTP id z16-v6mr33698132pgu.412.1536094032500; Tue, 04 Sep 2018 13:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536094032; cv=none; d=google.com; s=arc-20160816; b=tbG8zVJ3QPPaaBj0Pk/59gjmORlcfeNM7AwUalbOTzLJXDYqEDOENarklT0ect2MEH SvI2mr1BSq/thtUg/N8RVDhjHVnsKtnMwUQ/aUctLkn3JjzV9sENHSKLdofvMifF9il+ VspWf7/2DgCzI/P4rPglNEUWw5rXAcndWYaQRw8j81V2r4nlm81ofd4228JvyE/gNcmz LdkvOIrRUQDVbML7TycWpu6gK3US3purrT3om4BYWPU/Xn5IVRGUlUUprCbaLFfmHBlW x7lURTCqjT6vUw516h6eRKcAOBZNGMvC0daSlR0UeqUeBpYCXWhmv96nFpIHZx/zOtB0 M/Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=bxs/cCFaaa3Slef0teDbyMzbHGu/wTrwX15T5IT4OMk=; b=WfilKLZcQYXP1I2s6uhI0O5Yefh+u1Ieu7W1tNxE9kKEdIr93Wh3RRh8p2ijqkZbFY lem3CrBH2E669EBij/JPZqbHRgRYWJmj+ZAz+E98lmNJZzdgbiEPsAGyHhUzJkpbESdp XFOywC925FDJhc/WtMWMLD8fmLBkLlCtD4TiA3DYvMCgaYL/0X+GCBUzR3ckhkQvwuN+ XnzKWUumehTkq1W3Q548WNHpCg03CVyCmzPjgcz4nrh9kJDCnvnM0TWL/2VwjCGsKkx0 4M1gwdZ3pqY/5krc9cO1gqCuJHKeCCnblyzoOBn+PjPK8JT9ljq7RNO3/qJLJ/XqIeSE +/Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="JXmis/7I"; dkim=pass header.i=@linaro.org header.s=google header.b=Dh52eYGj; spf=pass (google.com: domain of libc-alpha-return-95673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95673-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t32-v6si22579560pgl.484.2018.09.04.13.47.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:47:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="JXmis/7I"; dkim=pass header.i=@linaro.org header.s=google header.b=Dh52eYGj; spf=pass (google.com: domain of libc-alpha-return-95673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95673-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=sLPrv6DN/Xd+1qOwZ9Udkv6a3Dj3BRK Feu6MGtcYmnnoQRd3UnkpWGR+kSB6D6OLhlWgn7uA/R6QbHmfJILb309UYowK043 meqL+vr0jmdJSOmxIzBxWD0iaKp97ymyO8L47BwC0y86DML2zGUbzgA07UzlAJct sPgLxCfqV/e4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=qHYKOlCwXNCugux0KDX57qEpw4E=; b=JXmis /7IuFYPOo0dIlR4HyOEgYbMqWD6n2MwYy/isZEDUZibIhXB8VNy974IoYa51AllL QWRN861zIxkijJhkD3aeCT1L90Sp/Po/xU0NaimiU3jUpicoCHwPfR6gAG4OPxhq BKT0OzCRBLx5D4He2O/ByoJ0uXCrCrcYxgOan0= Received: (qmail 34840 invoked by alias); 4 Sep 2018 20:46:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 34749 invoked by uid 89); 4 Sep 2018 20:46:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk1-f180.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=bxs/cCFaaa3Slef0teDbyMzbHGu/wTrwX15T5IT4OMk=; b=Dh52eYGjTduS9rSSc/2dbOmj3RyDC70Yc5hazvSG11bvxZRA2hLCCG7JRnCvVmR0ez 2gaJIYmW7ygV6VdWlbz/n5g+mYl6fANqKxxA8MS1UDihMpjQknfXvUlVKpQZ843BazTV GrA2Cq5l/LNTgmsAtWXrrUhjflVPagbIvPw2E= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 7/7] support: Add support_create_temp_fifo Date: Tue, 4 Sep 2018 17:45:53 -0300 Message-Id: <20180904204553.6971-8-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-1-adhemerval.zanella@linaro.org> Checked on x86_64-linux-gnu. * support/temp_file.c (support_create_temp_fifo): New function. * support/temp_file.h (support_create_temp_fifo): New prototype. --- ChangeLog | 3 +++ support/temp_file.c | 23 +++++++++++++++++++++++ support/temp_file.h | 6 ++++++ 3 files changed, 32 insertions(+) -- 2.17.1 diff --git a/support/temp_file.c b/support/temp_file.c index 0bbc7f9972..362ef171cc 100644 --- a/support/temp_file.c +++ b/support/temp_file.c @@ -86,6 +86,29 @@ create_temp_file (const char *base, char **filename) return fd; } +int +support_create_temp_fifo (const char *base, char **fifoname) +{ + char *fname = xasprintf ("%s/%sXXXXXX", test_dir, base); + mktemp (fname); + + int fd = mkfifo (fname, 0600); + if (fd == -1) + { + printf ("cannot open temporary fifo '%s': %m\n", fname); + free (fname); + return -1; + } + + add_temp_file (fname); + if (fifoname != NULL) + *fifoname = fname; + else + free (fname); + + return fd; +} + char * support_create_temp_directory (const char *base) { diff --git a/support/temp_file.h b/support/temp_file.h index c7795cc577..081b241b68 100644 --- a/support/temp_file.h +++ b/support/temp_file.h @@ -32,6 +32,12 @@ void add_temp_file (const char *name); *FILENAME. */ int create_temp_file (const char *base, char **filename); +/* Create a temporary fifo. Return the opened file descriptor on + success, or -1 on failure. Write the file name to *FILENAME if + FILENAME is not NULL. In this case, the caller is expected to free + *FILENAME. */ +int support_create_temp_fifo (const char *name, char **fifoname); + /* Create a temporary directory and schedule it for deletion. BASE is used as a prefix for the unique directory name, which the function returns. The caller should free this string. */