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)