static sched_mode_t
sched_multiq_initial_thread_sched_mode(task_t parent_task);
+static bool
+sched_multiq_thread_avoid_processor(processor_t processor, thread_t thread);
+
const struct sched_dispatch_table sched_multiq_dispatch = {
.sched_name = "multiq",
.init = sched_multiq_init,
.direct_dispatch_to_idle_processors = FALSE,
.multiple_psets_enabled = FALSE,
.sched_groups_enabled = TRUE,
+ .avoid_processor_enabled = TRUE,
+ .thread_avoid_processor = sched_multiq_thread_avoid_processor,
+ .processor_balance = sched_SMT_balance,
+
+ .rt_runq = sched_rtglobal_runq,
+ .rt_init = sched_rtglobal_init,
+ .rt_queue_shutdown = sched_rtglobal_queue_shutdown,
+ .rt_runq_scan = sched_rtglobal_runq_scan,
+ .rt_runq_count_sum = sched_rtglobal_runq_count_sum,
+
+ .qos_max_parallelism = sched_qos_max_parallelism,
+ .check_spill = sched_check_spill,
+ .ipi_policy = sched_ipi_policy,
+ .thread_should_yield = sched_thread_should_yield,
};
boolean_t has_higher;
int pri;
+ if (sched_multiq_thread_avoid_processor(processor, current_thread())) {
+ return (AST_PREEMPT | AST_URGENT);
+ }
+
entry_queue_t main_entryq = multiq_main_entryq(processor);
run_queue_t bound_runq = multiq_bound_runq(processor);
run_queue_t main_runq = multiq_main_entryq(processor);
run_queue_t bound_runq = multiq_bound_runq(processor);
- if (main_runq->count == 0 && bound_runq->count == 0)
- return FALSE;
-
int qpri = MAX(main_runq->highq, bound_runq->highq);
if (gte)
} while (restart_needed);
}
+extern int sched_allow_rt_smt;
+
+/* Return true if this thread should not continue running on this processor */
+static bool
+sched_multiq_thread_avoid_processor(processor_t processor, thread_t thread)
+{
+ if (processor->processor_primary != processor) {
+ /*
+ * This is a secondary SMT processor. If the primary is running
+ * a realtime thread, only allow realtime threads on the secondary.
+ */
+ if ((processor->processor_primary->current_pri >= BASEPRI_RTQUEUES) && ((thread->sched_pri < BASEPRI_RTQUEUES) || !sched_allow_rt_smt)) {
+ return true;
+ }
+ }
+ return false;
+}