From patchwork Fri Dec 28 01:02:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154580 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504469ljp; Thu, 27 Dec 2018 17:03:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN7GraVpWAmW5yK5mqdmPBxkW6Eq7O26gpAmAGKnZ0Bjd57qd6lv6IDEcirxK60JL4F1A9tN X-Received: by 2002:a63:3287:: with SMTP id y129mr24679022pgy.337.1545959021972; Thu, 27 Dec 2018 17:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959021; cv=none; d=google.com; s=arc-20160816; b=RWQU4pBE/998zUtKdnUtRAO2GRFWyST0BuFAO/j0rZv4Qz8Fb5Irf8q1BEwHS2jDnB l1jkrDSdx9VtznIIV72bKOtTlsnj89GhGwoZ1DfQ0+buKKjW5uD1BoT8WjYme095hFDZ 1Q05b6LTfiqBe3nnpmVCbHiD62rBZuPHg2EDCxcPrUtdjLifwKrb0bgkOBlYmUFz0+4u VS0goUiqaNCr9tlXEbYti85pcFM2FhJPbTeU2/CM39x/KH9nLNnGlCYMLVt77vV5dtJI SZX01CTcORjWU1NYhXzOFdJ5fk7Qy1I+0iwq0SnD5k4EXSNAfYJvV5F1bvpRnWVvkgQv H1mA== 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; bh=FXRzUX9dKtQTYwgDmugjESgCjGECdZqtjVyN7ht9gsw=; b=0PIiniLON3PIb13/fKN7ebmQQJBSictU0WlppHdTbdDcIPdLKPntivOpkNiPpHUVqb xvtk+F/UMtTwMhMbW+xvJa5YB/IinLQPWUgS04JPILvuOK4/Ao/r3BhMpKDQlxU2o87v BTfa/lkkSH9F0AQ0Rb3VJJnzAVgEw2b04kJ4dSql25Na5pIYtKAvacWl5dmZcoJHf2Fw 5wz2/Y5w0d896dc3+TjJAQNJuXxe8kFUyO0w/eB9wQa+3JaCnWeXO9wtpm3iB4/tmUwI 13Yg/sZYvGjKTzM07mJE5XZPGOQUaef09eJz/hFPc6Jrlgfbo4/AgYjvzTrXVJSi5Dn7 kXcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H2toCi+L; dkim=pass header.i=@linaro.org header.s=google header.b=LUDXJIdW; spf=pass (google.com: domain of libc-alpha-return-98816-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98816-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 i13si37102560pgj.199.2018.12.27.17.03.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:03:41 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98816-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=H2toCi+L; dkim=pass header.i=@linaro.org header.s=google header.b=LUDXJIdW; spf=pass (google.com: domain of libc-alpha-return-98816-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98816-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=Slajk5MM3+GO9qFh+a6rKcsSE+gOe2m ELMNssIcwCmOHqWPHmNhVptI19lUFiFfEW8PnjfcrPYC3Z+ag6ugBX7sX9Xf/xSs cYO+Rd4bg/JlRmwJ/KzeidA6o5lCn5CZH9D1LrUvUfH/H3vyjZwjhcZqB+J6EDu2 wFP9b9Jb/kbc= 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=xqjav+FI6PwS2XXXtkchKbRa8ZE=; b=H2toC i+LIYcx4fwdUwaUeTTxq8ox2gilAZB+ZlsI+bzvg0/oCQKbBrhyVcQgGJMYiU/mv gH0YbFxai2XLuIbChwZKuCQ8Bc2umAPZDdrIMICzjj+SsHQU6SM3RR3X1njFFPDC 7BVCfjVjk1sNiZW8R3eznBlamPi4tq27EOs6z0= Received: (qmail 35390 invoked by alias); 28 Dec 2018 01:03: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 35273 invoked by uid 89); 28 Dec 2018 01:03:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=strip, select, Nothing, upcoming X-HELO: mail-qt1-f194.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=FXRzUX9dKtQTYwgDmugjESgCjGECdZqtjVyN7ht9gsw=; b=LUDXJIdWv956dyto7QMq2SDoPK2cI0EMd62pH/yJoP/+6O1ZmlxDai8KPB1uk7hKzn rw8dC8ClR9/TviHizS6cftH8G+x0EUJS9GErVdJhWJGn9PfUj2okANyhursr9nQHlHB5 lWnhVItJJDX1/rlWAg7NvCOM+Bft5C3TDrrPA= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 1/6] nptl: Remove tst-cancel-wrappers test and related macros Date: Thu, 27 Dec 2018 23:02:50 -0200 Message-Id: <20181228010255.21406-2-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-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 | 21 ++++++ 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, 23 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 b01f2b0626..c50fe81ad9 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -465,8 +465,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 @@ -669,8 +668,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))) @@ -681,18 +679,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 7f16ba9800..36acb234ae 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -325,27 +325,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 Fri Dec 28 01:02:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154578 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504233ljp; Thu, 27 Dec 2018 17:03:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/UgawR1YqkI14315t38rFZqV/LNfepj0mRJ0cX5opOwUyVFgifoFZzf3pq+bWoPPTt2IYel X-Received: by 2002:a62:d885:: with SMTP id e127mr25911075pfg.197.1545959002671; Thu, 27 Dec 2018 17:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959002; cv=none; d=google.com; s=arc-20160816; b=es1OU4GISqZEpsHZ9xs5Btu8ewPV4d8EjWbELXSxywW1lMWpO2G1sdfEgnA0g7k35U f3Eo9Um7MidcvIdc5HPtJ9c/KczDD+r2+sa+IJIgtxD991t++DoA9GGGwxiCJl7/557e 4gs7wt0Ab4egcm9bH2lxHlgVRqnQINAKdzyzP4cBQKt/D3H4IG5FM5RyOSKuw08EYTJV ioA/mmW/KsQwd7PuJ+0aZxEUVxMxKu6QuX3/qicam45bdvt/aGEX9dLOvSqoJ2fuoyPv Mf0Mtm8c1IMAgzGGVFDuKijJuvIqOE3kzAJvK4lX61Ke6gqgE0VVe/Zetp33wGzYI84V vZSg== 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; bh=sHwaooOHDVgMVCIgf5T3xOkXrhPOlcRRg5pvWasicX4=; b=x5OSJmKwEvNcBQwPh0cw/PLAEnCFXYIKkr+ro4WfbgHBTg1nFXWRAyKbuPsdOpAOru YaqwLNmLXp4cmTBppqlPRbmxfPgkrUjjnJ4I4ASGa8XFMgatq1ELs9VAT/X5GIBrIo28 Do4vbxcVQrQLmkNpb8YKlXKDBgMlcZRMKw50eoXRNANTFI1Tsln5aBb13OvtVQiDNF12 HkE6Fuc5osUgU9dEQPL5Yfa/1bKyYP49/i9fNd7YfJs6vbjNDZMDuCHVSA0LNBt1dLSk bIGKIt/zckbNdjCDyJXogGf0Yodkm2R4bil+G7qAxhlNhpkWoPwsKlBeKFBeQESgDo9q SpnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=c98SYSEL; dkim=pass header.i=@linaro.org header.s=google header.b=bvzZOaxZ; spf=pass (google.com: domain of libc-alpha-return-98814-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98814-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 o12si36462616pgn.145.2018.12.27.17.03.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:03:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98814-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=c98SYSEL; dkim=pass header.i=@linaro.org header.s=google header.b=bvzZOaxZ; spf=pass (google.com: domain of libc-alpha-return-98814-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98814-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=tNWyqfO9d/31Jw1TcieuU6tYQx05YeZ P7La/deL/JF/uiHOSpTlAG/x9EFnCFqxzEuKR5rDZJRLjMRUftZivoIfMx70YZHK 2gP0vdfMFuN7DKIHXxXTTQZ/qPG9tl8JwSmY95KeOLtYrWEgHffuIfKgRUwT7OUs 3SwdsPPC4OEA= 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=c98SY SELBYGSPzD2lo+KntCxt5W9PXphzm/qEtVuNleQMsFG6CuvSP1MkcvsVanCKLoFI dUGT6b/IOX3wpLWc8+FRiAcJ7+ahbNlXcye52vRYsyRHkVk0lZJ+NXzwmqWopbCs 11JEdEZDQmDGDKQooCejXL4827b2HSvfDyXY1o= Received: (qmail 35047 invoked by alias); 28 Dec 2018 01:03:07 -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 34956 invoked by uid 89); 28 Dec 2018 01:03:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=upcoming, 56, act X-HELO: mail-qt1-f193.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=bvzZOaxZoht1gVMkz8THmFsttkhI3Wwk9NWv5/0t16sGhVoxjYeU6G9lHv+KbHjHFR wuHKCV8IR1Nnl8q9g9w06TjrKhWYclgRwjQvfj+y1MX+bE1M/cKUjgrBPmDCLDLXyh/U l5T+15hlOnrtFU7+xnu4siyV1ZEVJPgJ5vJOI= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH v2 2/6] nptl: Fix testcases for new pthread cancellation mechanism Date: Thu, 27 Dec 2018 23:02:51 -0200 Message-Id: <20181228010255.21406-3-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-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 Fri Dec 28 01:02:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154579 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504352ljp; Thu, 27 Dec 2018 17:03:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXSrQ5TBj6P5n2yXN0RxJjwtK29MwkFM6oUrMAPsZwC1O4b45EPj0G7ArGa8Vl3K5u+Uyg X-Received: by 2002:a62:6303:: with SMTP id x3mr26912552pfb.110.1545959011844; Thu, 27 Dec 2018 17:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959011; cv=none; d=google.com; s=arc-20160816; b=KWjxONvT1SoHqFnV4G356uTGN655kIf360BFpKipKhcHRUNtnVCgZ2mR2tW9YJkv6C 37HK47vcpN4ZMX8FjaxlC99kFaFZjk4NrCqIj1BdZbffsBMcd2/kxfnmgpO+9nQb8Krs eHbt59rFObq1cyUXjn33a5MgPZF9YhBeUQg5pOlUro9tqDyHAnir2Cz54gzsaDoyZy8T yQS2hODFBQ4hMmxvPbRrpS6v6Qo++fBnZn5Du8PTEik8jMH11m+pCXfmpaxLkiT2mDEV hxja8aGNxX5UfDP9ETdwj+Z/l9dpm0iE1G5ToEEKCMlbMSX0EQDlLa+Zo0g49ChvtY5T y6Ow== 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; bh=gzhUnGrl2CIILyE/qLsnzPtwIrjHGrO0EU8entvzrpg=; b=WKzXi8xPl2Y8ytQxENU42vG+5qBjWwCO60yoT73/mMIIeej98Cbe75+v8OWjsBFXy2 5C4MY4DvbT/r8P375rpV/FUw9Je4Wp7amtAvB9wtFInO3XUqiLucApu0ggEtvPTnFdqZ 8qd7XdKNM9Z4dZvsDZcrfK21W6rV9TKp7fSQFhMelo//HiKghxdqMdpyVBrJNMVYXNay 6to7E2xP4mEAcBOEB6M3nk+FXvaioGWDMmZ2lNuWkBYsoO9TIQiuzOlcsI1EzORITWXA IGOhmkCHKds1JyodCSUjR/WaLhFtexowm/Q7xy8u1+8hw6ONunm/ic/EjGFSdoK6D5dr Rseg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TqjQLyYi; dkim=pass header.i=@linaro.org header.s=google header.b="JDNYY/OS"; spf=pass (google.com: domain of libc-alpha-return-98815-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98815-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 q70si36578932pgq.526.2018.12.27.17.03.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98815-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=TqjQLyYi; dkim=pass header.i=@linaro.org header.s=google header.b="JDNYY/OS"; spf=pass (google.com: domain of libc-alpha-return-98815-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98815-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=JzgtW3BgVv8vZsaW8odaQGxWucaF0OU zBy5i02Ne6coGY55Ij706r1KuptROiyq1efqjh5t5201W+3XqSFSEFGKzQ046Xwq YJDritT54wUzwMkh+jsxoTFxgSo3/7kDv4naNVlJRE0X+mDU+9glZJldo/BfxJzo XzmXpAHXiuQk= 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=TqjQL yYi8v0k8y6tv+SrDZ4UeTx9ucRuNd0YIaEIUkijYICXoaYG8wpG7DN0UwwG8x8w4 O3T/GhkN0aDRxBhEa9XGOB531adOdzDuv8h79PjvTMw2qej7SX7IE/1X7Jhkvgka hJlHstR3gYS4Nxbsa+kYaSh3Qx5IkCGbVG+KGM= Received: (qmail 35341 invoked by alias); 28 Dec 2018 01:03:08 -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 35236 invoked by uid 89); 28 Dec 2018 01:03:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=exchange, lock, optimize, indicated 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=JDNYY/OSU/GrdDeA5zPTk7hbiblSZQ4p6Y3JNfp1C2/loxggj75fZ49QLJAAWwM1QD X3tEUKBo71W2zRKEknJMlVeW7hNst5vlY6gyhVCIahFFRfV9bwkcDJk2p0F1ebejeoLy F6npfn9FjaP9gjyYpTi9qJhb3onxdmNG4ZjgI= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 3/6] x86: Remove wrong THREAD_ATOMIC_* macros Date: Thu, 27 Dec 2018 23:02:52 -0200 Message-Id: <20181228010255.21406-4-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-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 Fri Dec 28 01:02:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154581 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504626ljp; Thu, 27 Dec 2018 17:03:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN4tRiDM8ODT6eWSj88kwXbovDjCxOA6y3zQqhVdFTPlZobnhJ16LfQ3CriM3l6fdBFon5jD X-Received: by 2002:a63:960a:: with SMTP id c10mr24351737pge.106.1545959030365; Thu, 27 Dec 2018 17:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959030; cv=none; d=google.com; s=arc-20160816; b=aXCWJYMV6+G/JUtnKxIlQES3qAXl34WHfvxNOLmBpq4YAP+L8N6XFEWclxOcBL3N/b wyREAQmvH3Mc0nTSrIy2dg12fPbOzrNOAQrm7VQ8WjrNPDhKyMokqf6NXIkoxmy0f2Ka pyp8+psMTDXRuVgsy1tLLPIh++WE+NG68JNN87mTR/JqqLNFqVM4Z68sYuM2tnTxw5cU BkcKQM0QBlWSr6IP9hF/ErgJcpduEotKaLf8bt7/uAC0EktvwSuNJ2vFVCmMRNBl7RfR DzOc9CUXumG7i6pjJs19uzS9mJ4pLi1bE8V6rls3QU/N4DF1640EZf9xTVHipE1Uzdjl 5kIg== 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; bh=qhYe6UrU7SVOJ3qWYli9JzPtOcdsQDWefh1Yi6BmuIA=; b=v6H00ppLd1qKqKomYs8UsVWxqrhxwODgjcndY1V/C74hDcRbxU0gBTtL0uECR+dusj qiLZElBs4b6KybYhQcU845CDOb8QYu96B25wwxYbuQFKntMGG5NlISNACitmgpBIxucs zDr5+wN6JNeV4CNZvVAF8P8QrwGJNhE3roLna0axWQZh02TrKVaNjHVGrH3eXE1M1t5X BOtLzC5zZDcJnboVMXVd2SU976QhP7xqlN9BTzkIY3/WL+x6IoxOyX1FeR1KT3gEo5hI XUGA+2GUz3cbZ4RywUpW8o0rIdBQq6j2oy0Jo/e63bsdbkzho3MYUSvtvk5kKiFdutLc Y5gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=foohsmZd; dkim=pass header.i=@linaro.org header.s=google header.b=OeH4p5Oy; spf=pass (google.com: domain of libc-alpha-return-98817-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98817-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 n34si26598437pld.381.2018.12.27.17.03.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:03:50 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98817-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=foohsmZd; dkim=pass header.i=@linaro.org header.s=google header.b=OeH4p5Oy; spf=pass (google.com: domain of libc-alpha-return-98817-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98817-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=d5+h8+b02QnQGYEwVg6p1NpESCux+AH DuY5EgqP+M5pBmyRk4BcJyU//frmZpL6/1zX4eGE40RHBG+TBzmkI+GmDucG/Enk n9A75vNXP7UXwYohWGQaske/yTS6aay6Z9qzJRmD744eYQ3rUQgN+5QxihQSsyN8 S02OZGQ4EPIg= 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=foohs mZdXxO5AbsBITvVe2Efq8S3RAsgVfuhWOxTO6iN3hP0rKwctQnoT8/4Fte6RJMJu IC5leVx9IxszBTUiahiDNpS7sXnXdkEjonSog/Uow726GA/2ay+aEOQqvBh3a2jO 36R9y4/WcfdvRGi+BzUG+bjrdfBLmeFM0PK40o= Received: (qmail 35444 invoked by alias); 28 Dec 2018 01:03: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 35318 invoked by uid 89); 28 Dec 2018 01:03:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=exchange, optimize, indicated X-HELO: mail-qt1-f193.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=OeH4p5Oy7Zy+fjR5NYBYq6SknoDF10gzZZUuqhWyhIKqtJAghxvoG395pxVPpFYtcE u+bL12rR88yeM2jphF/xpNLSuwE45PGJlg9LtGvhzo24KvC7Kmt758l/TMePNdAj9DjH TBBagtd75/FaMl7JzZw4GO7RcOWDlHDt5gXuU= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 4/6] i386: Remove bogus THREAD_ATOMIC_* macros Date: Thu, 27 Dec 2018 23:02:53 -0200 Message-Id: <20181228010255.21406-5-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-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 Fri Dec 28 01:02:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154583 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504922ljp; Thu, 27 Dec 2018 17:04:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN7eapDfjvf3ML+309XFFrUgQ5qz0qgX/Pq11NfFQL1GUPKu9Gatj2NRD7+ENOspbaORc+51 X-Received: by 2002:a65:500c:: with SMTP id f12mr24287614pgo.226.1545959051809; Thu, 27 Dec 2018 17:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959051; cv=none; d=google.com; s=arc-20160816; b=dtrP0Qe6PtbQL1rIeQlaA3WsNCgngInYroohL7m8gMFmrDG3qVlWLWb27grcYu9jkF sU0UOhKjqHpSUmxRLv5TVoVaTcdGYK13kjC7AfC1l4ADO5+XMeExCbVkkrccnAGJGwgJ gqFNY4sK0hJaicjEBinZDkvn/rmEZQ0h1NbGt7vikWQEIISDqheaVhWKkYB79vZgPm1/ U+50qXijlguPEhFUGM1lY6ZIq0fCgiqvmpaP8FjXpEkKs/p6RzzLJkEavhhqCvTvalYp 07zi1OUdafzwdPc0wUm7y81Udl1bY7OYmuskOfrjlTlYC+7zHTa1f57Tmzy6qV3BWVfs wDPg== 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; bh=Xp68K0uJH2vK+msXPR4/hCf468AbtDpJx2jTi6Aq/m0=; b=ekkNdIDi4gaTl6H+ZiefQVU+2ogLBva8V2/3o63JGOCUei81Z1xnAIg4YE9FgoVE3x eiyoLID5zRlqzxZw1bbEkUK+U1Gg3Qv00GMkVrCbWOAqnHpOf2gPnzBGbBbPcLd2fAz3 Jm36shpA0/1EkF4PNHkRoKYbLr4lKssv6DAPbTwhhyR++hTON3Qq4lK3QgrQ7fZ+3qaY FvK+NY8g6HCMSPLVYn6S3MWwiiiNZ+kFtDDDLA/frjFEZamjJUul3MZxntHIp3I/8Nu8 5vSIlUK8zYp08w3F13E/joMHwMl0IpvFIpVU4SkRC6HOF13Si6VyafbMHjHeZjIc+QDA bMiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GITbvezZ; dkim=pass header.i=@linaro.org header.s=google header.b=Cn4Aslyl; spf=pass (google.com: domain of libc-alpha-return-98819-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98819-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 e129si18077722pgc.333.2018.12.27.17.04.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:04:11 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98819-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=GITbvezZ; dkim=pass header.i=@linaro.org header.s=google header.b=Cn4Aslyl; spf=pass (google.com: domain of libc-alpha-return-98819-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98819-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=quCttUmtm0W1gl5z4dloWLNYaFg1shj JJg7TtDZ4WML+ALGBcK6/cQApRXl3UspxSCm6lj1ZniSCTPpQ5N3xcNw36fPEJLD 3NwP2jreh8BkG3ZR4COe06V/8sEEr5GX1Tf6/e8EUi9AFq7e4wVThPtddT1E+oMM vALqim+kg50Q= 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=W26QwQD7BMNKGR9N/kUDd158oIM=; b=GITbv ezZ5WCW45DXppUuRsJdRg+4elKS4lIVpEKKn/Pc4k7XH+dd2xzsLIQFJeiIp5v7n /Ny+jsP4w3vk88sZcg09UyB+jomxr+Oi9nlqmF0KD5P0eIMmlJCxbMk1AxP2CeL4 GEjJF+ArU+VwUsBT0K1EAcFamBCGaSYqmrmN0o= Received: (qmail 36700 invoked by alias); 28 Dec 2018 01:03:19 -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 36603 invoked by uid 89); 28 Dec 2018 01:03:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=interrupted X-HELO: mail-qk1-f194.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=Xp68K0uJH2vK+msXPR4/hCf468AbtDpJx2jTi6Aq/m0=; b=Cn4AslylzYsi/OV0NSCWLV5Htom9VIT47a1dqulTYAO//hUYjHjlXMe68syH5EZ14w aCsZDRY9Zo6LehY9WV4VZ79SZCyICNuzKHqR7sZJ/2z4E1UBSMEVCwEZXC0ffv7rxnnw DxmbPJrfY20Yeq23eWUje2MNnefhH9dhtKB5o= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 5/6] nptl: Cleanup cancellation macros Date: Thu, 27 Dec 2018 23:02:54 -0200 Message-Id: <20181228010255.21406-6-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-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 | 20 +++------ 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, 146 insertions(+), 164 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..2803d2a0c5 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_sigitid (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..c91663acfd 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -28,26 +28,16 @@ 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); } 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 Fri Dec 28 01:02:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154582 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504788ljp; Thu, 27 Dec 2018 17:04:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN79vd3YUGeiKyA7grvp99Ur7GShbM5h0If7AwcZE/cMlsGLvBFD7AH5tCkzlM5U8cU3FH8c X-Received: by 2002:a17:902:f64:: with SMTP id 91mr25561389ply.132.1545959041859; Thu, 27 Dec 2018 17:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959041; cv=none; d=google.com; s=arc-20160816; b=OtpG1NGz+Bl53d+O4fODR4VeNbClW7jIhQk9cziM0dTj9WPhvIE/ggkIjfrQwh5N/W 2GKUw2SrUt0JHK+2KEhrGml2wjYytjbeJyJNNXrAoAx4K+YgNnUHJMo5GtNZR2gF7vKo lmhBXuMXevsSwIS2312clqjVaRTcRHQINUUKETvQKOZp8pHoiSCXeiCfOVaxjomjp5/M secVs/zdH1HxfMDkc6fQHgOo0kxfe1Of186mRqPEGGNApvkYbh7KaNa8qUfwydIAsNiR qZPT+CAKH6nVwnspzffMiMWDiOYn+c/BmT6rTzeKjVUWJw246lcNd4ijmOA73EIYSK58 3gAQ== 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; bh=bxs/cCFaaa3Slef0teDbyMzbHGu/wTrwX15T5IT4OMk=; b=ujorO2uBYIgZj/7QftbNr65Cai+K22e0lSyAz0bytFcJzOPqjfA2VlleVI4IXlyEkX bOKoy1IKhQVG0iY2cNH/j8TQHUVBMrHkViG5QGHELdNdPeAhGBjiJWQfPLf4uPSNBR9j wvDniWoeM3BByEK/BVPk0kmKiSX+IlgeYpS+IsWAyqMSnq/WI2lfUCV3CUbNcZbTbcdY BIJp2EJ5X6pxUWuYRJgp2k2BUSXz9WBB8CFmbQU1SIwXCKJqYYfdp0H8rumex3giBlTG 5Ps4kzSM+kBYZ5pJHIgTa3kOggrUOOcQ7Lz4Pgk0aONSmhCnU+I/2RrxlfXllkbUqLRt wZKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AiZWBFKU; dkim=pass header.i=@linaro.org header.s=google header.b=YF4c2vBS; spf=pass (google.com: domain of libc-alpha-return-98818-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98818-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 g21si36550815pgl.114.2018.12.27.17.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98818-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=AiZWBFKU; dkim=pass header.i=@linaro.org header.s=google header.b=YF4c2vBS; spf=pass (google.com: domain of libc-alpha-return-98818-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98818-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=TspcN/bepsqzyrh7K4iSRqubed8ttkm t/CKOaftrmToK4BlxZkyJS9XieOtz18uo1Ow2gR6hU2zejtxoEs+/E8N1sN633C5 Ivm77OYnyr82P/E7MjjP4H5o3TeOah0gShcZvxDtKcABa5P1H7hOTZAVM/9xywo9 aR3uoJfIn4NA= 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=AiZWB FKUBt6w66CciaMKfEq72oAWK3TTpq1gRib3t6fkCfSakIPhXxhTLhyiF3KT+oifO wT0zHFd82IB/BuLXK9gXI/xYcVJyZL2oHK66dXmYjHlTBj4R24CJoSaTx838yBiz ++0KiZISdN/hmbAuhEPfvg2gTYxD2NzG7Q7A9o= Received: (qmail 35808 invoked by alias); 28 Dec 2018 01:03: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 35738 invoked by uid 89); 28 Dec 2018 01:03:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt1-f181.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=YF4c2vBS9ZHc9wB39R7znhG300wEi2Ue5wBa8Yf/4F8kggtp+Pky4atnp8RPvNjhwW sgLyLAxMJl99jncocI2Kse50AVddjOpEoWyqXq8iH8mvfcSAX41Su0+Z3bNDJ50/e28x Kq6VWEYkNJTTQUTjYO6B5hfvx+jSfxtw5J+Tg= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 6/6] support: Add support_create_temp_fifo Date: Thu, 27 Dec 2018 23:02:55 -0200 Message-Id: <20181228010255.21406-7-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-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. */