diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2021-09-15 20:11:09 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-09-16 01:04:17 +0200 |
commit | ed2f9aaf5e901e8561cca8d0370ff3bcb2b6482b (patch) | |
tree | 93a1647a14e192d0e8bc698d8d3e3d4f9c08d6d7 /sysdeps/mach | |
parent | 166bb3eac351b88191d440b0fe8d5d7b757eaed0 (diff) | |
download | glibc-ed2f9aaf5e901e8561cca8d0370ff3bcb2b6482b.zip glibc-ed2f9aaf5e901e8561cca8d0370ff3bcb2b6482b.tar.gz glibc-ed2f9aaf5e901e8561cca8d0370ff3bcb2b6482b.tar.bz2 |
htl: Reimplement GSCOPE
This is a new implementation of GSCOPE which largely mirrors its NPTL
counterpart. Same as in NPTL, instead of a global flag shared between
threads, there is now a per-thread GSCOPE flag stored in each thread's
TCB. This makes entering and exiting a GSCOPE faster at the expense of
making THREAD_GSCOPE_WAIT () slower.
The largest win is the elimination of many redundant gsync_wake () RPC
calls; previously, even simplest programs would make dozens of fully
redundant gsync_wake () calls.
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20210915171110.226187-3-bugaevc@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/hurd/i386/tls.h | 21 | ||||
-rw-r--r-- | sysdeps/mach/hurd/tls.h | 20 |
2 files changed, 21 insertions, 20 deletions
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index 057b261..2ac65df 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -369,6 +369,27 @@ _hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb) return err; } +/* Global scope switch support. */ +# define THREAD_GSCOPE_IN_TCB 1 + +# define THREAD_GSCOPE_FLAG_UNUSED 0 +# define THREAD_GSCOPE_FLAG_USED 1 +# define THREAD_GSCOPE_FLAG_WAIT 2 + +# define THREAD_GSCOPE_SET_FLAG() \ + THREAD_SETMEM (THREAD_SELF, gscope_flag, THREAD_GSCOPE_FLAG_USED) + +# define THREAD_GSCOPE_RESET_FLAG() \ + ({ \ + int __flag; \ + asm volatile ("xchgl %0, %%gs:%P1" \ + : "=r" (__flag) \ + : "i" (offsetof (tcbhead_t, gscope_flag)), \ + "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ + if (__flag == THREAD_GSCOPE_FLAG_WAIT) \ + lll_wake (THREAD_SELF->gscope_flag, LLL_PRIVATE); \ + }) + #endif /* !__ASSEMBLER__ */ #endif /* i386/tls.h */ diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h index f83956d..8e66d5f 100644 --- a/sysdeps/mach/hurd/tls.h +++ b/sysdeps/mach/hurd/tls.h @@ -52,26 +52,6 @@ # define GET_DTV(descr) \ (((tcbhead_t *) (descr))->dtv) -/* Global scope switch support. */ -#define THREAD_GSCOPE_IN_TCB 0 -#define THREAD_GSCOPE_GLOBAL -#define THREAD_GSCOPE_SET_FLAG() \ - atomic_exchange_and_add_acq (&GL(dl_thread_gscope_count), 1) -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - if (atomic_exchange_and_add_rel (&GL(dl_thread_gscope_count), -1) == 1) \ - lll_wake (GL(dl_thread_gscope_count), 0); \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - do \ - { \ - int count; \ - atomic_write_barrier (); \ - while ((count = GL(dl_thread_gscope_count))) \ - lll_wait (GL(dl_thread_gscope_count), count, 0); \ - } \ - while (0) - #endif /* !ASSEMBLER */ |