From bff02948ed87a9e791fa901557a88ae545bf3df7 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Thu, 9 Feb 2023 11:39:12 -0400 Subject: [PATCH] sched_4bsd: use the same switch flags as ULE ULE uses the more specific SWT_REMOTEPREEMPT and SWT_REMOTEWAKEIDLE switch types, let's do that here as well. SWT_PREEMPT is somewhat redundant when we also have the SW_PREEMPT flag. This only has an effect for kernels built with SCHED_STATS. Reviewed by: kib, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38183 --- sys/kern/sched_4bsd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 8bd697a67e7e..f0da4f8d8496 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1542,13 +1542,17 @@ sched_choose(void) void sched_preempt(struct thread *td) { + int flags; SDT_PROBE2(sched, , , surrender, td, td->td_proc); if (td->td_critnest > 1) { td->td_owepreempt = 1; } else { thread_lock(td); - mi_switch(SW_INVOL | SW_PREEMPT | SWT_PREEMPT); + flags = SW_INVOL | SW_PREEMPT; + flags |= TD_IS_IDLETHREAD(td) ? SWT_REMOTEWAKEIDLE : + SWT_REMOTEPREEMPT; + mi_switch(flags); } }