]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add a way to manage thread signal mask using shared word, instead of syscall.
authorkib <kib@FreeBSD.org>
Sun, 9 Feb 2020 11:53:12 +0000 (11:53 +0000)
committerkib <kib@FreeBSD.org>
Sun, 9 Feb 2020 11:53:12 +0000 (11:53 +0000)
commitc3e1a2bd2c4c568d00c4d31dbeb3fdbd2456198b
tree60bf028ed76a80978fe5182e20b87c86b098bae3
parentd3642b2b3681877bdf9bbd98f87f2ee9ae995955
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
14 files changed:
lib/libc/sys/Makefile.inc
lib/libc/sys/Symbol.map
lib/libc/sys/sigfastblock.2 [new file with mode: 0644]
sys/compat/freebsd32/syscalls.master
sys/kern/capabilities.conf
sys/kern/kern_exec.c
sys/kern/kern_fork.c
sys/kern/kern_sig.c
sys/kern/kern_thread.c
sys/kern/subr_syscall.c
sys/kern/subr_trap.c
sys/kern/syscalls.master
sys/sys/proc.h
sys/sys/signalvar.h