path: root/sys/sys/proc.h
diff options
authorKonstantin Belousov <kib@FreeBSD.org>2020-02-09 11:53:12 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-02-09 11:53:12 +0000
commit146fc63fce9b46ab77ba7959cf69429d9bd88d2a (patch)
tree60bf028ed76a80978fe5182e20b87c86b098bae3 /sys/sys/proc.h
parent850e0825a2238d2180e36e7ffe5f769be13aec91 (diff)
Add a way to manage thread signal mask using shared word, instead of syscall.
A new syscall sigfastblock(2) is added which registers a uint32_t variable as containing the count of blocks for signal delivery. Its content is read by kernel on each syscall entry and on AST processing, non-zero count of blocks is interpreted same as the signal mask blocking all signals. The biggest downside of the feature that I see is that memory corruption that affects the registered fast sigblock location, would cause quite strange application misbehavior. For instance, the process would be immune to ^C (but killable by SIGKILL). With consumers (rtld and libthr added), benchmarks do not show a slow-down of the syscalls in micro-measurements, and macro benchmarks like buildworld do not demonstrate a difference. Part of the reason is that buildworld time is dominated by compiler, and clang already links to libthr. On the other hand, small utilities typically used by shell scripts have the total number of syscalls cut by half. The syscall is not exported from the stable libc version namespace on purpose. It is intended to be used only by our C runtime implementation internals. Tested by: pho Disscussed with: cem, emaste, jilles Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D12773
Notes: svn path=/head/; revision=357693
Diffstat (limited to 'sys/sys/proc.h')
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 2a85b035a7b4..f657a4cc7af5 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -322,6 +322,9 @@ struct thread {
uintptr_t td_rb_inact; /* (k) Current in-action mutex loc. */
struct syscall_args td_sa; /* (kx) Syscall parameters. Copied on
fork for child tracing. */
+ void *td_sigblock_ptr; /* (k) uptr for fast sigblock. */
+ uint32_t td_sigblock_val; /* (k) fast sigblock value read at
+ td_sigblock_ptr on kern entry */
#define td_endcopy td_pcb
@@ -486,7 +489,7 @@ do { \
#define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */
#define TDP_DEADLKTREAT 0x00000040 /* Lock acquisition - deadlock treatment. */
#define TDP_NOFAULTING 0x00000080 /* Do not handle page faults. */
-#define TDP_UNUSED9 0x00000100 /* --available-- */
+#define TDP_SIGFASTBLOCK 0x00000100 /* Fast sigblock active */
#define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */
#define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */
#define TDP_SYNCIO 0x00000800 /* Local override, disable async i/o. */
@@ -509,6 +512,7 @@ do { \
#define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */
#define TDP_FORKING 0x20000000 /* Thread is being created through fork() */
#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */
+#define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */
* Reasons that the current thread can not be run yet.