From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 dcvr.yhbt.net (Postfix) with ESMTPS id D2CE81F8C6 for ; Mon, 13 Sep 2021 13:51:56 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D33543857436 for ; Mon, 13 Sep 2021 13:51:55 +0000 (GMT) Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [216.12.86.13]) by sourceware.org (Postfix) with ESMTPS id DB9C33858C60 for ; Mon, 13 Sep 2021 13:51:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB9C33858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=libc.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=libc.org Date: Mon, 13 Sep 2021 09:51:42 -0400 From: Rich Felker To: Vincent Chen Subject: Re: [RFC patch 4/5] RISC-V: Extend MINSIGSTKSZ and SIGSTKSZ to backup RVV registers Message-ID: <20210913135142.GK13220@brightrain.aerifal.cx> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> <1631497278-29829-5-git-send-email-vincent.chen@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1631497278-29829-5-git-send-email-vincent.chen@sifive.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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: libc-alpha@sourceware.org, andrew@sifive.com Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On Mon, Sep 13, 2021 at 09:41:17AM +0800, Vincent Chen wrote: > As using RVV extension, the original MINSIGSTKSZ is not enough to > back up all RVV registers for the normal case. Therefore, the MINSIGSTKSZ > is expanded to about 5K and the SIGSTKSZ is expanded to about 16K. This > space is enough for the case that the VLENB of a vector register is 128 > bytes. For the case that VLENB > 128 bytes, users can use > sysconf (_SC_MINSIGSTKSZ) and sysconf (_SC_SIGSTKSZ) to get the > appropriate signal stack size. > --- > sysdeps/unix/sysv/linux/riscv/bits/sigstack.h | 32 +++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigstack.h > > diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h > new file mode 100644 > index 0000000..c18512f > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h > @@ -0,0 +1,32 @@ > +/* sigstack, sigaltstack definitions. > + 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 > + . */ > + > +#ifndef _BITS_SIGSTACK_H > +#define _BITS_SIGSTACK_H 1 > + > +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H > +# error "Never include this file directly. Use instead" > +#endif > + > +/* Minimum stack size (5k+256 bytes) for a signal handler. */ > +#define MINSIGSTKSZ 5376 > + > +/* System default stack size. */ > +#define SIGSTKSZ 16384 > + > +#endif /* bits/sigstack.h */ > -- > 2.7.4 Strictly speaking this is also an ABI change (and what the kernel is doing is too). If possible I think there should be an effort to get the riscv folks to rethink this. Aside from being breakage, large state that has the be saved/restored at context switch time is an anti-feature. Any reasonable amount of vector state fits in the existing size. If it is to be changed, I suspect 5376 is too small. IIRC other archs that have large (4k or so?) register files used something like 6k as the min (1-2k margin for actual execution space). Rich