aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2024-01-16 09:42:11 +0000
committerOlivier Certner <olce@FreeBSD.org>2024-02-19 16:37:19 +0000
commit6a3c02bc52892eb09c3b766562b8ddb452c393a9 (patch)
tree41c09f63856e78059ae4ecdc9eea80b6dd2780bd
parent849599e28a8708b137be2c8ed2c7ca114d0caf1e (diff)
downloadsrc-6a3c02bc52892eb09c3b766562b8ddb452c393a9.tar.gz
src-6a3c02bc52892eb09c3b766562b8ddb452c393a9.zip
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
-rw-r--r--sys/kern/sched_4bsd.c5
-rw-r--r--sys/kern/sched_ule.c5
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 ebd7139fa612..c0d085fcf906 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))