unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Vincent Chen <vincent.chen@sifive.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Andrew Waterman <andrew@sifive.com>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [RFC 5/5] RISC-V: Expand PTHREAD_STACK_MIN to support RVV environment
Date: Thu, 16 Sep 2021 18:21:04 +0800	[thread overview]
Message-ID: <CABvJ_xi0PUVjJwNQ8DyLOvhFFEj8zPMGSv=7Z9Lp5YTNmzN28g@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOrHtTjt-DQbFOnunqdbjvP8-jDKoBz5b6qwkMdxEd_TEQ@mail.gmail.com>

On Wed, Sep 15, 2021 at 10:31 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Sep 15, 2021 at 3:42 AM Florian Weimer via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
> >
> > * Joseph Myers:
> >
> > > On Mon, 13 Sep 2021, Vincent Chen wrote:
> > >
> > >> 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.
> > >
> > > A change to PTHREAD_STACK_MIN has been considered an ABI change in the
> > > past, requiring new symbol versions for pthread_attr_setstack and
> > > pthread_attr_setstacksize to ensure that binaries built with the old
> > > PTHREAD_STACK_MIN definition continue to work rather than failing because
> > > the old size is too small.  You may need symbol versioning updates for
> > > those functions in RISC-V if you make such a change.  (All the existing
> > > versioning support for this in architecture-independent files assumes the
> > > change in value was done before libpthread was merged into libc, so there
> > > will be some extra work involved in being the first architecture to
> > > increase PTHREAD_STACK_MIN after that merge.)
> >
Hi Joseph,
I understood. I will add symbol versioning to pthread_attr_setstack
and pthread_attr_setstacksize functions if I decide to change the
PTHREAD_STACK_MIN definition. Thank you.

> > Instead it may make sense to leave PTHREAD_STACK_MIN as is and switch to
> > the dynamic version (same for the SIGSTKSZ constants).
> >
>
> I don't know what problem RISC-V ran into.   It should be fixed with:
>

Hi Florian and H.J. Lu,
The dynamic version works for RISC-V. However, I am afraid that some
existing programs, such as nptl/tst-minstack-cancel, do not define
_DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE. In this case, the original
PTHREAD_STACK_MIN definition is too small to support V extension.
Therefore, I finally decided to extend PTHREAD_STACK_MIN to 20K for
normal use cases.

> commit 5d98a7dae955bafa6740c26eaba9c86060ae0344
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Mon Jun 21 12:42:56 2021 -0700
>
>     Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
>
>     The constant PTHREAD_STACK_MIN may be too small for some processors.
>     Rename _SC_SIGSTKSZ_SOURCE to _DYNAMIC_STACK_SIZE_SOURCE.  When
>     _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, define
>     PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) which is changed
>     to MIN (PTHREAD_STACK_MIN, sysconf(_SC_MINSIGSTKSZ)).
>
>     Consolidate <bits/local_lim.h> with <bits/pthread_stack_min.h> to
>     provide a constant target specific PTHREAD_STACK_MIN value.
>
>     Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>
For this patch, I really appreciate H.J. Lu for providing this feature
in glibc. It's really helpful. But, I have a little question. If
possible, could H.J. Lu help me clarify it?

In __get_pthread_stack_min(), when GLRO(dl_minsigstacksize) !=0 and
GLRO(dl_minsigstacksize) > PTHREAD_STACK_MIN, the pthread_stack_min
will be set to GLRO(dl_minsigstacksize). However, If my understanding
is correct, the size of GLRO(dl_minsigstacksize) approximately equals
the size of the signal context. In this case, the remaining free stack
seems not enough for GCC to execute unwind if this pthread is
terminated by pthread_cancel, such as the case in
tst-minstack-cancel.c. Therefore, my question is that the
PTHREAD_STACK_MIN does not need to reserve the space for GCC to
execute unwind? Thank you in advance.

Regards,
Vincent

  reply	other threads:[~2021-09-16 10:21 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13  1:41 [RFC patch 0/5] RISC-V: Add vector ISA support Vincent Chen
2021-09-13  1:41 ` [RFC patch 1/5] RISC-V: Remove riscv-specific sigcontext.h Vincent Chen
2021-09-13  1:41 ` [RFC patch 2/5] RISC-V: Reserve about 5K space in mcontext_t to support future ISA expansion Vincent Chen
2021-09-13 13:44   ` Florian Weimer via Libc-alpha
2021-09-13 13:52     ` Rich Felker
2021-09-16  8:02       ` Vincent Chen
2021-09-16  8:14         ` Florian Weimer via Libc-alpha
2021-09-18  3:04           ` Vincent Chen
2022-12-09  3:39             ` RISCV kernel struct sigcontext expansion for V regs and potential glibc ABI break (was Re: [RFC patch 2/5] RISC-V: Reserve about 5K space in mcontext_t to support future ISA expansion.) Vineet Gupta
2022-12-09  4:03               ` Vineet Gupta
2022-12-20 20:05               ` Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break Vineet Gupta
2022-12-21 15:53                 ` Vincent Chen
2022-12-21 19:45                   ` Vineet Gupta
2022-12-21 19:52                     ` Vineet Gupta
2022-12-22  3:37                       ` Vincent Chen
2022-12-22 19:25                         ` Vineet Gupta
2022-12-23  2:27                           ` Vincent Chen
2022-12-23 19:42                             ` Vineet Gupta
2022-12-22  5:32                       ` Richard Henderson via Libc-alpha
2022-12-22 18:33                         ` Andy Chiu
2022-12-22 20:27                           ` Vineet Gupta
2022-12-28 10:53                             ` Andy Chiu
2023-01-03 19:17                               ` Vineet Gupta
2023-01-04 16:34                                 ` Andy Chiu
2023-01-04 20:46                                   ` Vineet Gupta
2023-01-04 21:29                                     ` Philipp Tomsich
2023-01-04 21:37                                       ` Andrew Waterman
2023-01-04 22:43                                       ` Vineet Gupta
2023-01-09 13:33                                         ` Kito Cheng
2023-01-09 19:16                                           ` Vineet Gupta
2023-01-10 13:21                                             ` Kito Cheng
2023-01-10 18:07                                               ` Auto-enabling V unit and/or use of elf attributes (was Re: Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break) Vineet Gupta
2023-01-11  1:22                                                 ` Richard Henderson via Libc-alpha
2023-01-11  4:28                                                   ` Jeff Law
2023-01-11  4:57                                                     ` Richard Henderson via Libc-alpha
2023-01-11  5:07                                                       ` Jeff Law
2023-01-11  6:00                                                         ` Andy Chiu
2023-01-11  6:20                                                           ` Jeff Law
2023-01-11  9:28                                                             ` Andy Chiu
2023-01-11 12:13                                                               ` Andy Chiu
2023-01-23 12:17                                                                 ` Conor Dooley via Libc-alpha
2023-01-23 13:29                                                                   ` Andy Chiu
2023-01-11  5:05                                                   ` Anup Patel
2023-01-11  5:23                                                   ` Richard Henderson via Libc-alpha
2022-12-22 22:33                           ` Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break Richard Henderson via Libc-alpha
2022-12-22 23:47                           ` Conor Dooley via Libc-alpha
2022-12-22 23:58                             ` Vineet Gupta
2022-12-22 20:30                         ` Vineet Gupta
2022-12-22 21:38                           ` Andrew Waterman
2022-12-22  1:50                     ` Vincent Chen
2022-12-22  5:34                     ` Richard Henderson via Libc-alpha
2021-09-16 23:56         ` [RFC patch 2/5] RISC-V: Reserve about 5K space in mcontext_t to support future ISA expansion Ben Woodard via Libc-alpha
2021-09-18  3:15           ` Vincent Chen
2021-09-20 16:41             ` DJ Delorie via Libc-alpha
2021-09-20 17:10               ` Florian Weimer via Libc-alpha
2021-10-01  1:43                 ` Vincent Chen
2021-10-01 12:08                   ` Adhemerval Zanella via Libc-alpha
2021-09-17 17:03         ` Rich Felker
2021-09-18  3:19           ` Vincent Chen
2021-09-13  1:41 ` [RFC patch 3/5] RISC-V: Save and restore VCSR when doing user context switch Vincent Chen
2021-09-14 23:48   ` Joseph Myers
2021-09-15  0:13     ` Andrew Waterman
2021-09-16  9:20       ` Vincent Chen
2021-10-01 13:04   ` Adhemerval Zanella via Libc-alpha
2021-09-13  1:41 ` [RFC patch 4/5] RISC-V: Extend MINSIGSTKSZ and SIGSTKSZ to backup RVV registers Vincent Chen
2021-09-13 13:51   ` Rich Felker
2021-09-16  9:25     ` Vincent Chen
2021-09-13  1:41 ` [RFC 5/5] RISC-V: Expand PTHREAD_STACK_MIN to support RVV environment Vincent Chen
2021-09-14 23:43   ` Joseph Myers
2021-09-15 10:42     ` Florian Weimer via Libc-alpha
2021-09-15 14:31       ` H.J. Lu via Libc-alpha
2021-09-16 10:21         ` Vincent Chen [this message]
2021-09-13 19:11 ` [RFC patch 0/5] RISC-V: Add vector ISA support Vineet Gupta via Libc-alpha
2021-09-15 19:37   ` Jim Wilson
2021-11-09 19:21 ` Darius Rad
2021-11-09 19:30   ` Andrew Waterman
2021-11-09 22:03     ` Darius Rad
2021-11-09 22:18       ` Andrew Waterman
2021-11-10 11:39         ` Darius Rad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABvJ_xi0PUVjJwNQ8DyLOvhFFEj8zPMGSv=7Z9Lp5YTNmzN28g@mail.gmail.com' \
    --to=vincent.chen@sifive.com \
    --cc=andrew@sifive.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).