git: dfe172484d0e - main - sigtd(): prefer non-stopped thread as a target for signal queue
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Jul 2023 15:22:07 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=dfe172484d0e1de0bb32bcab8775eb83e15031c0 commit dfe172484d0e1de0bb32bcab8775eb83e15031c0 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-07-21 09:41:39 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-07-26 15:12:55 +0000 sigtd(): prefer non-stopped thread as a target for signal queue This should improve signal delivery latency and better expose the process state to the executing threads. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41128 --- sys/kern/kern_sig.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index de42255017d8..5876e2e93920 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2157,14 +2157,18 @@ sigtd(struct proc *p, int sig, bool fast_sigblock) if (curproc == p && !SIGISMEMBER(curthread->td_sigmask, sig) && (!fast_sigblock || curthread->td_sigblock_val == 0)) return (curthread); + + /* Find a non-stopped thread that does not mask the signal. */ signal_td = NULL; FOREACH_THREAD_IN_PROC(p, td) { if (!SIGISMEMBER(td->td_sigmask, sig) && (!fast_sigblock || - td != curthread || td->td_sigblock_val == 0)) { + td != curthread || td->td_sigblock_val == 0) && + (td->td_flags & TDF_BOUNDARY) == 0) { signal_td = td; break; } } + /* Select random (first) thread if no better match was found. */ if (signal_td == NULL) signal_td = FIRST_THREAD_IN_PROC(p); return (signal_td);