From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: libc-alpha@sourceware.org, palmer@dabbelt.com, andrew@sifive.com 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-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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: , X-List-Received-Date: Mon, 13 Sep 2021 13:51:45 -0000 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