git: bff02948ed87 - main - sched_4bsd: use the same switch flags as ULE

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 09 Feb 2023 16:02:45 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=bff02948ed87a9e791fa901557a88ae545bf3df7

commit bff02948ed87a9e791fa901557a88ae545bf3df7
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-02-09 15:39:12 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-02-09 16:01:32 +0000

    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);
 	}
 }