summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-07-03 18:19:48 +0000
committerkib <kib@FreeBSD.org>2016-07-03 18:19:48 +0000
commit2ff8e9c6364b43e59db4e7bcb2dafb66980c2024 (patch)
tree785f4b49e87051d06f5552e5a6a06145dc697b2e /sys/kern/kern_thread.c
parentc861dc4640ad24f8906c4337047e41a1ce3bd6ea (diff)
downloadFreeBSD-src-2ff8e9c6364b43e59db4e7bcb2dafb66980c2024.zip
FreeBSD-src-2ff8e9c6364b43e59db4e7bcb2dafb66980c2024.tar.gz
Provide helper macros to detect 'non-silent SBDRY' state and to
calculate appropriate return value for stops. Simplify the code by using them. Fix typo in sig_suspend_threads(). The thread which sleep must be aborted is td2. (*) In issignal(), when handling stopping signal for thread in TD_SBDRY_INTR state, do not stop, this is wrong and fires assert. This is yet another place where execution should be forced out of SBDRY-protected region. For such case, return -1 from issignal() and translate it to corresponding error code in sleepq_catch_signals(). Assert that other consumers of cursig() are not affected by the new return value. (*) Micro-optimize, mostly VFS and VOP methods, by avoiding calling the functions when SIGDEFERSTOP_NOP non-change is requested. (**) Reported and tested by: pho (*) Requested by: bde (**) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb)
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r--sys/kern/kern_thread.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 5a2d392..89eb7db 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -894,7 +894,7 @@ thread_suspend_check(int return_instead)
{
struct thread *td;
struct proc *p;
- int wakeup_swapper, r;
+ int wakeup_swapper;
td = curthread;
p = td->td_proc;
@@ -927,21 +927,10 @@ thread_suspend_check(int return_instead)
if ((td->td_flags & TDF_SBDRY) != 0) {
KASSERT(return_instead,
("TDF_SBDRY set for unsafe thread_suspend_check"));
- switch (td->td_flags & (TDF_SEINTR | TDF_SERESTART)) {
- case 0:
- r = 0;
- break;
- case TDF_SEINTR:
- r = EINTR;
- break;
- case TDF_SERESTART:
- r = ERESTART;
- break;
- default:
- panic("both TDF_SEINTR and TDF_SERESTART");
- break;
- }
- return (r);
+ KASSERT((td->td_flags & (TDF_SEINTR | TDF_SERESTART)) !=
+ (TDF_SEINTR | TDF_SERESTART),
+ ("both TDF_SEINTR and TDF_SERESTART"));
+ return (TD_SBDRY_INTR(td) ? TD_SBDRY_ERRNO(td) : 0);
}
/*
OpenPOWER on IntegriCloud