From patchwork Tue Aug 16 09:07:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 659557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sD62J15k3z9t2H for ; Tue, 16 Aug 2016 19:07:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=nyQGUe01; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= pe62H7t1bpNlI8E9Yfbc5jIKo52PdBbDwkplITrAUyjm2YNU1gFvQFSJlYkZvSXo 0vrZqGuiYHoM6sc0pJfFNcCDFSgfaN9gfQyMjO7R7wzgI0XFTPdUPWxplRoIig2j wV4mwQUuQhYyFjiqfbuNSPchga5WPsDyxlJJhxOPuRc= 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:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=QYLZau Csty9TuH36eYTNiqOqISU=; b=nyQGUe01a0HxCfKcp0i9C2u7HMqGkTZCaRN2LP JRkIj/rtWvB0ox984ckJk0ZH0oiS4SjYSBO968DMARIirGZpgVug8YzyEeNTtZSD tnYqhvPz9MVu77ZbZmZ3J5hmf8HV/sYj2cK+aTTX4L03EV8JwYWY5FxafqrKQ8vP P74ZY= Received: (qmail 40381 invoked by alias); 16 Aug 2016 09:07:29 -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 40367 invoked by uid 89); 16 Aug 2016 09:07:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1911, mmanh, mman.h, 19, 11 X-HELO: mx1.redhat.com Date: Tue, 16 Aug 2016 11:07:24 +0200 To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] nptl/tst-tls3-malloc: Force freeing of thread stacks User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20160816090724.F29274019E232@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) It turns out that due to the reduced stack size in tst-tls3 and the (fixed) default stack cache size, allocated TLS variables are never freed, so the test coverage for tst-tls3-malloc is less than complete. This change increases the thread stack size for tst-tls3-malloc only, to make sure thread stacks and TLS variables are freed. 2016-08-16 Florian Weimer * nptl/tst-tls3.c (default_stack_size_in_mb, stack_size_in_mb): New. (do_test): Apply default_stack_size_in_mb if not set. * nptl/tst-tls3-malloc.c (stack_size_in_mb): Override default. diff --git a/nptl/tst-tls3-malloc.c b/nptl/tst-tls3-malloc.c index 5eab3cd..8a580fa 100644 --- a/nptl/tst-tls3-malloc.c +++ b/nptl/tst-tls3-malloc.c @@ -19,6 +19,11 @@ /* Reuse the test. */ #include "tst-tls3.c" +/* Increase the thread stack size to 10 MiB, so that some thread + stacks are actually freed. (The stack cache size is currently + hard-wired to 40 MiB in allocatestack.c.) */ +static long stack_size_in_mb = 10; + #include /* Interpose a minimal malloc implementation. This implementation diff --git a/nptl/tst-tls3.c b/nptl/tst-tls3.c index 982c1fd..649cb8f 100644 --- a/nptl/tst-tls3.c +++ b/nptl/tst-tls3.c @@ -29,6 +29,11 @@ #define THE_SIG SIGUSR1 +/* The stack size can be overriden. With a sufficiently large stack + size, thread stacks for terminated threads are freed, but this does + not happen with the default size of 1 MiB. */ +enum { default_stack_size_in_mb = 1 }; +static long stack_size_in_mb; #define N 10 static pthread_t th[N]; @@ -72,6 +77,9 @@ int nsigs; int do_test (void) { + if (stack_size_in_mb == 0) + stack_size_in_mb = default_stack_size_in_mb; + if ((uintptr_t) pthread_self () & (TCB_ALIGNMENT - 1)) { puts ("initial thread's struct pthread not aligned enough"); @@ -127,7 +135,7 @@ do_test (void) exit (1); } - if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0) + if (pthread_attr_setstacksize (&a, stack_size_in_mb * 1024 * 1024) != 0) { puts ("attr_setstacksize failed"); return 1;