summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amd64/amd64/proc_machdep.c12
-rw-r--r--sys/include/sys/sched.h2
-rw-r--r--sys/kern/kern_exit.c8
3 files changed, 22 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c
index 11b1901..82b4e4f 100644
--- a/sys/arch/amd64/amd64/proc_machdep.c
+++ b/sys/arch/amd64/amd64/proc_machdep.c
@@ -281,6 +281,18 @@ sched_preempt_set(bool enable)
ci->preempt = enable;
}
+bool
+sched_preemptable(void)
+{
+ struct cpu_info *ci = this_cpu();
+
+ if (ci == NULL) {
+ return false;
+ }
+
+ return ci->preempt;
+}
+
/*
* Perform a context switch.
*/
diff --git a/sys/include/sys/sched.h b/sys/include/sys/sched.h
index 8deef95..7bba9df 100644
--- a/sys/include/sys/sched.h
+++ b/sys/include/sys/sched.h
@@ -67,6 +67,8 @@ void sched_stat(struct sched_stat *statp);
void sched_init(void);
void sched_preempt_set(bool enable);
+bool sched_preemptable(void);
+
void sched_yield(void);
void sched_suspend(struct proc *td, const struct timeval *tv);
void sched_detach(struct proc *td);
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 9377eed..af697d7 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -190,6 +190,14 @@ exit1(struct proc *td, int flags)
* and do not return.
*/
if (target_pid == curpid) {
+ /*
+ * If the thread is exiting on a core that is not
+ * preemptable, something is not right.
+ */
+ if (__unlikely(!sched_preemptable())) {
+ panic("exit1: cpu %d not preemptable\n", ci->id);
+ }
+
ci->curtd = NULL;
if (parent->pid == 0)
sched_enter();