From patchwork Wed Feb 1 18:34:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 93083 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2551104qgi; Wed, 1 Feb 2017 10:35:22 -0800 (PST) X-Received: by 10.84.170.195 with SMTP id j61mr6563446plb.26.1485974122682; Wed, 01 Feb 2017 10:35:22 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y74si19786580pff.233.2017.02.01.10.35.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 10:35:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-77129-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; spf=pass (google.com: domain of libc-alpha-return-77129-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-77129-patch=linaro.org@sourceware.org; dmarc=fail (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; q=dns; s= default; b=decvmmivxDFhNdg11lqN0B59yge5EE048orrnlhQpYzbkf4zMLJ+h cKhqCUpo+qgAz31JmG/Ej2rZiGk3RKkKpQAwuwDb7uSHr5uFFos4UNShTLAurEYm yHhkOHyfdLWeE9ltduwXly5PPcHPh7H75rJ+ZaP4YKVjE/lmfY31aQ= 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; s=default; bh=5YQFXTpvC3qDMidypLqIOkgQGxs=; b=A0oCG0GE2HIymtzfcC0rulI062vR l6+EfKP4r1akqFO8CLq11YibshY4C0kGi+ZaHHZl0toG1PzfO5p6fm4ex5jKoOon Il4hitpaTBhMXWc3vp+V3lmhw27Gl55esFTM90/+Lh6lCoB2w08/2G6FNp/ZfZ3y pNPXPRrz84fVzCM= Received: (qmail 11887 invoked by alias); 1 Feb 2017 18:35:01 -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 11592 invoked by uid 89); 1 Feb 2017 18:34:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-HELO: mail-qt0-f170.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=0CqAICnpUbs695/pUqxKbLs5EGx+XEPBahEN0auy4R8=; b=PxWehaUK311npGNS8gtu+Y5fcQBJlPGRlwTVgNhcf68OdHyYpj64CkCEtLAl1JmOqG t0S7sar3c9xQ7V/W+0wlx2tnz0w7WQqSC/VPX7nHxsk0qNxNjEO5eijEfNCr/J+UgEOv OgB5m0X3xqdC5lD4Nu6hxR4Bwzhbijn0OAIRzdKMNulOaRJyo+mV9xGm+xubFQ6fkBds EINzFYAR5XfEDQQm3s1U7SFl4MlMFiyKOpqaLOKrOp+z32q5GS+HZ5ybpAubKsbqVV/l xmA0D/9asVVOXYklG6xatr3in3BWNcZVNdUNiG4iERPZhFlc5LenTk+hYznEDTmliEtM gUOg== X-Gm-Message-State: AIkVDXJJOim8Uu3Dudgd/b7a+wMTd1DrWiBtSfLLGqxXQx8QgQ2rLQapFmJ3hU3fleGuYpnS X-Received: by 10.237.60.107 with SMTP id u40mr4139836qte.77.1485974086239; Wed, 01 Feb 2017 10:34:46 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/2] nptl: Remove COLORING_INCREMENT Date: Wed, 1 Feb 2017 16:34:37 -0200 Message-Id: <1485974078-12152-1-git-send-email-adhemerval.zanella@linaro.org> This patch removes the COLORING_INCREMENT define and usage on allocatestack.c. It has not been used since 564cd8b67ec487f (glibc-2.3.3) by any architecture. The idea is to simplify the code by removing obsolete code. * nptl/allocatestack.c [COLORING_INCREMENT] (nptl_ncreated): Remove. (allocate_stack): Remove COLORING_INCREMENT usage. * nptl/stack-aliasing.h (COLORING_INCREMENT). Likewise. * sysdeps/i386/i686/stack-aliasing.h (COLORING_INCREMENT): Likewise. --- ChangeLog | 7 +++++++ nptl/allocatestack.c | 40 ++------------------------------------ nptl/stack-aliasing.h | 6 ------ sysdeps/i386/i686/stack-aliasing.h | 5 ----- 4 files changed, 9 insertions(+), 49 deletions(-) -- 2.7.4 diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 6402ea4..e52c698 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -125,11 +125,6 @@ static uintptr_t in_flight_stack; list_t __stack_user __attribute__ ((nocommon)); hidden_data_def (__stack_user) -#if COLORING_INCREMENT != 0 -/* Number of threads created. */ -static unsigned int nptl_ncreated; -#endif - /* Check whether the stack is still used or not. */ #define FREE_P(descr) ((descr)->tid <= 0) @@ -467,14 +462,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, const int prot = (PROT_READ | PROT_WRITE | ((GL(dl_stack_flags) & PF_X) ? PROT_EXEC : 0)); -#if COLORING_INCREMENT != 0 - /* Add one more page for stack coloring. Don't do it for stacks - with 16 times pagesize or larger. This might just cause - unnecessary misalignment. */ - if (size <= 16 * pagesize_m1) - size += pagesize_m1 + 1; -#endif - /* Adjust the stack size for alignment. */ size &= ~__static_tls_align_m1; assert (size != 0); @@ -513,34 +500,11 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, So we can never get a null pointer back from mmap. */ assert (mem != NULL); -#if COLORING_INCREMENT != 0 - /* Atomically increment NCREATED. */ - unsigned int ncreated = atomic_increment_val (&nptl_ncreated); - - /* We chose the offset for coloring by incrementing it for - every new thread by a fixed amount. The offset used - module the page size. Even if coloring would be better - relative to higher alignment values it makes no sense to - do it since the mmap() interface does not allow us to - specify any alignment for the returned memory block. */ - size_t coloring = (ncreated * COLORING_INCREMENT) & pagesize_m1; - - /* Make sure the coloring offsets does not disturb the alignment - of the TCB and static TLS block. */ - if (__glibc_unlikely ((coloring & __static_tls_align_m1) != 0)) - coloring = (((coloring + __static_tls_align_m1) - & ~(__static_tls_align_m1)) - & ~pagesize_m1); -#else - /* Unless specified we do not make any adjustments. */ -# define coloring 0 -#endif - /* Place the thread descriptor at the end of the stack. */ #if TLS_TCB_AT_TP - pd = (struct pthread *) ((char *) mem + size - coloring) - 1; + pd = (struct pthread *) ((char *) mem + size) - 1; #elif TLS_DTV_AT_TP - pd = (struct pthread *) ((((uintptr_t) mem + size - coloring + pd = (struct pthread *) ((((uintptr_t) mem + size - __static_tls_size) & ~__static_tls_align_m1) - TLS_PRE_TCB_SIZE); diff --git a/nptl/stack-aliasing.h b/nptl/stack-aliasing.h index 4d6c013..73ee4de 100644 --- a/nptl/stack-aliasing.h +++ b/nptl/stack-aliasing.h @@ -16,12 +16,6 @@ License along with the GNU C Library; if not, see . */ -/* This is a number of bytes (less than a page) by which to "color" the - starting stack address of new threads. This number is multiplied by the - number of threads created so far and then truncated modulo page size, - to get a roughly even distribution of values for different threads. */ -#define COLORING_INCREMENT 0 - /* This is a number of bytes that is an alignment that should be avoided when choosing the exact size of a new thread's stack. If the size chosen is aligned to this, an extra page will be added to render the diff --git a/sysdeps/i386/i686/stack-aliasing.h b/sysdeps/i386/i686/stack-aliasing.h index 7872e47..9b5a1b0 100644 --- a/sysdeps/i386/i686/stack-aliasing.h +++ b/sysdeps/i386/i686/stack-aliasing.h @@ -16,11 +16,6 @@ License along with the GNU C Library; if not, see . */ -/* It turns out that stack coloring is in general not good on P4s. Some - applications will benefit. We will probably have a configuration option - at some point. To enable coloring, set this to 128. */ -#define COLORING_INCREMENT 0 - /* What is useful is to avoid the 64k aliasing problem which reliably happens if all stacks use sizes which are a multiple of 64k. Tell the stack allocator to disturb this by allocation one more page if