]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Do not read sigfastblock word on syscall entry.
authorkib <kib@FreeBSD.org>
Thu, 20 Feb 2020 15:34:02 +0000 (15:34 +0000)
committerkib <kib@FreeBSD.org>
Thu, 20 Feb 2020 15:34:02 +0000 (15:34 +0000)
commit58f9982a28509b6d9e9fd8eb0080ed4fd6508381
tree7c76fe7b827939ee71f52a69aea68ce979ceb894
parent2e23aacd7372a96f98adef9386f314e893053998
Do not read sigfastblock word on syscall entry.

On machines with SMAP, fueword executes two serializing instructions
which can be seen in microbenchmarks.

As a measure to restore microbenchmark numbers, only read the word on
the attempt to deliver signal in ast().  If the word is set, signal is
not delivered and word is kept, preventing interruption of
interruptible sleeps by signals until userspace calls
sigfastblock(UNBLOCK) which clears the word.

This way, the spurious EINTR that userspace can see while in critical
section is on first interruptible sleep, if a signal is pending, and
on signal posting.  It is believed that it is not important for rtld
and lbithr critical sections.  It might be visible for the application
code e.g. for the callback of dl_iterate_phdr(3), but again the belief
is that the non-compliance is acceptable.  Most important is that the
retry of the sleeping syscall does not interrupt unless additional
signal is posted.

For now I added the knob kern.sigfastblock_fetch_always to enable the
word read on syscall entry to be able to diagnose possible issues due
to spurious EINTR.

While there, do some code restructuting to have all sigfastblock()
handling located in kern_sig.c.

Reviewed by: jeff
Discussed with: mjg
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D23622
sys/kern/kern_exec.c
sys/kern/kern_sig.c
sys/kern/subr_syscall.c
sys/kern/subr_trap.c
sys/sys/signalvar.h