From patchwork Mon Sep 13 01:41:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 44933 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33F643857C6C for ; Mon, 13 Sep 2021 01:44:10 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 1B5DD3857C78 for ; Mon, 13 Sep 2021 01:41:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B5DD3857C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pj1-x102d.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so5442894pjr.1 for ; Sun, 12 Sep 2021 18:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HT0CAfZOacZqLmo5v6zuqKRZ58RHSCIarASqR3U5c/g=; b=GwxzxuF9qQQqJGkb6Tmy24+ef75JmClEvS0FK6KHe2U075860vYk1Rll1D2N6m7tbV sDlTBSdUg5BSDsEnBTNw9j76R0cy2oC/bIcSt+UQJBOIDdrQVbLwY3nMTpVrP1iHGsgP EBI7O7sIsF3CRZUSQ+BzjZRxHZjs6g0VQmRkclC0Xq5RgmyHZZkyYNP9poPlvHLxo3dT oZaGHttoPzgDPwqNt8xBeNJ2xCuPS5qrsYNdLOYZzZ5K1l/tzQF842TIdLFn+HNAQGbI TbyO06r/+wv8qeww1NL8Q7iL+3gtv9pQU0HeBtqXx1fymXen6bcmhJqLqfmzQQXI4XHL /9Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HT0CAfZOacZqLmo5v6zuqKRZ58RHSCIarASqR3U5c/g=; b=wS86C5dpgnqP2DdfLwCof6X5EI6sRc33OjKILGk5CUfC8BJiXb6Kfr4Ixcc1lIW7Fg pFZtw9KoWClXo1h/Trjy1WSZYLmCVIN9wwTxY0V/cuP8MrabT7emJM98bYj8Z+kR5WF4 F6onQftyJHMrm815nSLTMURl+NblvqVgCBPZy/nJpmw9wbi5YF1/vWdNBZ57ilOTYA4C TjizsP+F8BJz175bdqvaymiZAhrNGFjEx9oEotu737MJWlkrkR+Qy0JDtO4JuqWExn0S ljI6SJUFTP8h+j0Nrwj6tfzvDjX5ug/LeRxT60bomKEy7K0Rf7RwBIaKC8MdY0oM+aBU SnVQ== X-Gm-Message-State: AOAM532PRP4+lKSbqnxrNYrgkQrSX4Szo8mCS6vUULIShiigUhGVcViu iUlhUsm/KR9cfGQErmcWjzqGtuASRJ2xIA== X-Google-Smtp-Source: ABdhPJzacwRKtFb+hJHQ/goOLpBfq9lgeKg4RyTezVR/6g/NvsrpLr1gQ97GxgIGh/HUlMxn4MB+gQ== X-Received: by 2002:a17:90a:c485:: with SMTP id j5mr10184059pjt.109.1631497306972; Sun, 12 Sep 2021 18:41:46 -0700 (PDT) Received: from localhost.localdomain (36-227-141-62.dynamic-ip.hinet.net. [36.227.141.62]) by smtp.gmail.com with ESMTPSA id i10sm5052173pfk.87.2021.09.12.18.41.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Sep 2021 18:41:46 -0700 (PDT) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com Subject: [RFC 5/5] RISC-V: Expand PTHREAD_STACK_MIN to support RVV environment Date: Mon, 13 Sep 2021 09:41:18 +0800 Message-Id: <1631497278-29829-6-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@sifive.com, Vincent Chen Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" In order to support all pthread operations in the RVV environment, here PTHREAD_STACK_MIN is set to 4 times GLRO(dl_minsigstacksize), and the default PTHREAD_STACK_MIN is expanded to 20K bytes. --- .../unix/sysv/linux/riscv/bits/pthread_stack_min.h | 21 ++++++++++++ .../sysv/linux/riscv/sysconf-pthread_stack_min.h | 39 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h create mode 100644 sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h diff --git a/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h new file mode 100644 index 0000000..83585b3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h @@ -0,0 +1,21 @@ +/* Definition of PTHREAD_STACK_MIN. Linux/riscv version. + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + 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 + . */ + +/* Minimum size for a thread. We are free to choose a reasonable value. */ +#define PTHREAD_STACK_MIN 20480 diff --git a/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h new file mode 100644 index 0000000..53ba6a1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h @@ -0,0 +1,39 @@ +/* __get_pthread_stack_min (). Linux version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +/* Return sysconf (_SC_THREAD_STACK_MIN). */ + +static inline long int +__get_pthread_stack_min (void) +{ + /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */ + long int pthread_stack_min = GLRO(dl_minsigstacksize) * 4; + assert (pthread_stack_min != 0); + _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN), + "PTHREAD_STACK_MIN is constant"); + /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */ + if (pthread_stack_min < PTHREAD_STACK_MIN) + pthread_stack_min = PTHREAD_STACK_MIN; + /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE + which returns a larger size that includes the required TLS variable + space which has been determined at startup. For sysconf here we are + conservative and don't include the space required for TLS access. + Eventually the TLS variable space will not be part of the stack + (Bug 11787). */ + return pthread_stack_min; +}