git: d3de30d0186b - stable/14 - sched: sched_switch(): Factorize sleepqueue flags

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Tue, 27 Feb 2024 10:38:30 UTC
The branch stable/14 has been updated by olce:

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

commit d3de30d0186b7ac984a272b4d874613c5fb59580
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-01-16 09:42:11 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2024-02-27 10:36:57 +0000

    sched: sched_switch(): Factorize sleepqueue flags
    
    Avoid duplicating common flags for the preempted and non-preempted
    cases, making it clear that they are the same without resorting to
    formatting.
    
    No functional change.
    
    Approved by:        markj (mentor)
    MFC after:          3 days
    Sponsored by:       The FreeBSD Foundation
    
    (cherry picked from commit 6a3c02bc52892eb09c3b766562b8ddb452c393a9)
    
    Approved by:        emaste (mentor)
---
 sys/kern/sched_4bsd.c | 5 ++---
 sys/kern/sched_ule.c  | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index efcd9b7cb250..f0fffeb08e2d 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -1041,9 +1041,8 @@ sched_switch(struct thread *td, int flags)
 	} else {
 		if (TD_IS_RUNNING(td)) {
 			/* Put us back on the run queue. */
-			sched_add(td, preempted ?
-			    SRQ_HOLDTD|SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED :
-			    SRQ_HOLDTD|SRQ_OURSELF|SRQ_YIELDING);
+			sched_add(td, SRQ_HOLDTD | SRQ_OURSELF | SRQ_YIELDING |
+			    (preempted ? SRQ_PREEMPTED : 0));
 		}
 	}
 
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 20515f4e430b..ee1e0ab0b955 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -2227,9 +2227,8 @@ sched_switch(struct thread *td, int flags)
 		TD_SET_CAN_RUN(td);
 	} else if (TD_IS_RUNNING(td)) {
 		MPASS(mtx == TDQ_LOCKPTR(tdq));
-		srqflag = preempted ?
-		    SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED :
-		    SRQ_OURSELF|SRQ_YIELDING;
+		srqflag = SRQ_OURSELF | SRQ_YIELDING |
+		    (preempted ? SRQ_PREEMPTED : 0);
 #ifdef SMP
 		if (THREAD_CAN_MIGRATE(td) && (!THREAD_CAN_SCHED(td, ts->ts_cpu)
 		    || pickcpu))