From patchwork Fri Apr 16 21:22:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 1467331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=LKHnc/IF; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FMTgj0SGfz9sWC for ; Sat, 17 Apr 2021 07:22:24 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 655AF10019; Fri, 16 Apr 2021 23:22:11 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by helium.openadk.org (Postfix) with ESMTPS id 9DFC61001D for ; Fri, 16 Apr 2021 23:22:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1618608124; bh=+0+wWmxPHg0X5WYmdZFbTUrcTOw4hSAA4fqUo6pAzvY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=LKHnc/IFSW/XywggSoBQVxhtyOv2vMLoEgDQ9hWSMBPExjX2dzOzyvu5Gi75YFWkR yli2UV89Yx2Esv+aPqP3wV4oT7UAS4RzEXmmn9ATtAEd1X7mO2V/4J7IloCxMZlxxy 02Si8yDFGnzTTffddN16+6qrSId/qtFDYkXkDv5A= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.fritz.box ([62.216.209.138]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N1OXZ-1le8QR2UV1-012luK; Fri, 16 Apr 2021 23:22:04 +0200 From: Peter Seiderer To: devel@uclibc-ng.org Date: Fri, 16 Apr 2021 23:22:04 +0200 Message-Id: <20210416212204.8758-1-ps.report@gmx.net> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:aO13pqpLrJsPDCVW9+J5E2xazUMWcSxNtCfxYi5t0Vrml7EtuJ6 N+NmnmESvwnp0vQSYCJOY1D9Q1hRMIEvwlJO2+T3Y/nx6dcnbD0iFaTlv2mp2ey5dPqVNVd DDS5PJH7+/d0pJsEYS5zMMJKJn1F+YbAD/20U/v5x54aQpFiDjprSL98+2/CYeymdZ9+s6w f8QMOdxPk+45lmYklF7Rw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:SKw1Eeh0EAM=:aF1ep9+OLuTsaoNwpGdjP4 hlraCOz+aWrZP3adJRdO7QlSZaS5HSYfdAjLFbplxbB83VvvPApSMTYeCRcOEzAUnexOkHrZA I7eOTnoE002F6tYRu2PLR41VILBfi2Ymbt8HjTbVmSeGDWhzKJSA2LCaicLHbzTkfC0WHC816 VrunZnKdreuPr/tyJCAtN3nUZMaSk/TW22c0rWUbOsuj4/IohERnb4jiBTjVrpBXc2+fiU/sw TZ7w6iYq1+WNvwD9QfpwlDSPQDZUhCNeDVK0iU2l8feNN3K1xp/BE7QGAl67FNIjCjixr+JpK lJI8GIPwZXiib+GsjiSAH6uXoW0+RpYxki2IHSBwsAn0MVz7cb1OqBmXJaSvJtLuNrNvINYkg QCBO1stjMlRPJGl1fmxGIspxyh2LEHDYnJRcj+r59FcSDtbdHY8ce5gJGQ+ajwZHL+HRwyc9/ eSl6yAQgEgIRI6nUKlYY1VYMSH+ZavVpl3XmpIbsUrfC2H/Sh0xzOdZYwFxH1fl0xq0tR6jWt Bw41YBg8XKWZDrQZ2H7Bk8ATQRNMXsYiTiXU8XveEhuSJEk0DIWAG8VJbeP07WGGW+soYlTaT osOg3+B1G79P0MzpMVUiLtn5bSKwfTT3w257586ukyQnFnOS+NGK4kLR0ttwCkukt/WM5rADG s5kgPyTxytDloQGanz99TjCEIcPvBSUUw0hthMbpNwinZ05FX3sen0v+Z1mgG/lzFdgZlgZ1U MXN5cky0Jyh6QDmao/zdckI2usNI02AFsrpWFHoMT+6aUfvS2ZMFu0PJp+00/uq3Ie3Ru9s2L JEuuzCFDsN857bFa/mDXLeGP9qHnWZRtAjRvlj/WzidjhAtwnHjhVCRPeN1uCKwHELDVW74ce sMTaHQZSywx0GJq55xciM5noTUbk4EvWQ2RnibH1zI5vELHUX8PwlLfU3coaGjkCgX4qzpf2a r0VeFlUsWyKhJtBq5T1bEnDHOUL02bQqN9SMjYnUfW04PsIBcHhuIgow08UHSrXQUEuhTeDva NO1pkyPuLwdrQBwRkyAq2M2W5I61xR62cEK6NDm31dw/Q92Wysw+NuFa55RiQSjFitva93mB7 NF/wbN49Nt0lXVpdyCI0ApG+gg5Ly7/qEkd06MuLng+RcjR57mtljys8xSH6HzZXvvDlifRdq G3qBnPH9o+PBuWLaG0dPUbIz5L94aBOI4t1VTRMm64G1omcoMmMWiALnSChSTYJq928cA= Subject: [uclibc-ng-devel] [PATCH] libpthread/nptl: create timer thread with sufficiant stack size (account for TLS) X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Waldemar Brodkorb Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" Create timer thread with sufficiant stack size (take into account allocated space for thread-local-storage), for this backport glibc commit 'Create internal threads with sufficient stack size' ([1], [2]) introducing __pthread_get_minstack() and use it in __start_helper_thread(). Fixes timer_create() in case of linking with library using large TLS area (e.g openblas, see [3]). [1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2c1094bd700e63a8d7f547b3f5495bedb55c0a08 [2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=630f4cc3aa019ede55976ea561f1a7af2f068639 [3] http://lists.busybox.net/pipermail/buildroot/2021-April/308281.html Signed-off-by: Peter Seiderer --- libpthread/nptl/init.c | 6 ++++++ libpthread/nptl/pthreadP.h | 1 + libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c index 4959d5ed8..5d25ded7d 100644 --- a/libpthread/nptl/init.c +++ b/libpthread/nptl/init.c @@ -337,3 +337,9 @@ __pthread_initialize_minimal_internal (void) } strong_alias (__pthread_initialize_minimal_internal, __pthread_initialize_minimal) + +size_t +__pthread_get_minstack (const pthread_attr_t *attr) +{ + return __static_tls_size + PTHREAD_STACK_MIN; +} diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h index 13205512a..c686a4ca5 100644 --- a/libpthread/nptl/pthreadP.h +++ b/libpthread/nptl/pthreadP.h @@ -377,6 +377,7 @@ weak_function; extern void __pthread_init_static_tls (struct link_map *) attribute_hidden; +extern size_t __pthread_get_minstack (const pthread_attr_t *attr); /* Namespace save aliases. */ extern int __pthread_getschedparam (pthread_t thread_id, int *policy, diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c index 514913317..60f2a724c 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c @@ -164,7 +164,7 @@ __start_helper_thread (void) and should go away automatically when canceled. */ pthread_attr_t attr; (void) pthread_attr_init (&attr); - (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); + (void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr)); /* Block all signals in the helper thread but SIGSETXID. To do this thoroughly we temporarily have to block all signals here. The