git: d5e9c642307c - main - sched_ule: tdq_runq_add(): Scope variables, delineate the different steps

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Mon, 19 Oct 2026 09:07:23 UTC
The branch main has been updated by olce:

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

commit d5e9c642307c13b8058609f421b63e2c72bab45f
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-10-09 09:19:58 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-10-19 09:06:49 +0000

    sched_ule: tdq_runq_add(): Scope variables, delineate the different steps
    
    For better readability.
    
    No functional change (intended).
    
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
---
 sys/kern/sched_ule.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 453e3958faf9..4c217279f28d 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -509,19 +509,21 @@ normalize_ts_off(int offset)
 static inline void
 tdq_runq_add(struct tdq *tdq, struct thread *td, int flags)
 {
-	struct td_sched *ts;
 	u_char pri, idx;
 
 	TDQ_LOCK_ASSERT(tdq, MA_OWNED);
 	THREAD_LOCK_BLOCKED_ASSERT(td, MA_OWNED);
 
-	pri = td->td_priority;
-	ts = td_get_sched(td);
 	TD_SET_RUNQ(td);
+
 	if (THREAD_CAN_MIGRATE(td)) {
+		struct td_sched *const ts = td_get_sched(td);
+
 		tdq->tdq_transferable++;
 		ts->ts_flags |= TSF_XFERABLE;
 	}
+
+	pri = td->td_priority;
 	if (PRI_MIN_BATCH <= pri && pri <= PRI_MAX_BATCH) {
 		/*
 		 * The queues allocated to the batch range are not used as