Date: Tue, 21 Jul 2026 02:26:55 +0000 From: Olivier Certner <olce@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Minsoo Choo <minsoo@minsoo.io> Subject: git: 26ef66653448 - main - sched_4bsd: Rename the global runqueue Message-ID: <6a5ed8ef.1fbc7.3173dc7f@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=26ef6665344823f405c7fafba5baaacd9baacf72 commit 26ef6665344823f405c7fafba5baaacd9baacf72 Author: Minsoo Choo <minsoo@minsoo.io> AuthorDate: 2026-07-20 02:34:13 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2026-07-21 02:24:18 +0000 sched_4bsd: Rename the global runqueue In an upcoming change whose purpose is to stop having 4BSD always allocate MAXCPU runqueues, wasting space on most machines, 'struct td_sched' will store the CPU ID to which a thread is bound/pinned instead of a pointer to the corresponding runqueue. As a consequence, existing functions manipulating a thread's runqueue will need to point to the inferred runqueue through a local variable. The name 'runq' is the ideal one for these local variables, but before this change it designated the global runqueue, also causing unnecessary ambiguity. Thus, rename the global runqueue to the more explicit 'runq_global'. Arguably, this should have been performed as part of commit e17c57b14ba9 ("- Implement cpu pinning and binding. (...)"). No functional change (intended). [olce: Massaged the commit message. Tested with source builds.] Suggested by: olce Reviewed by: olce Tested by: olce MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D58065 --- sys/kern/sched_4bsd.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 98c5cd8836a8..11dc2fbcec5b 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -110,7 +110,7 @@ struct td_sched { #define TSF_AFFINITY 0x0001 /* Has a non-"full" CPU set. */ #define SKE_RUNQ_PCPU(ts) \ - ((ts)->ts_runq != 0 && (ts)->ts_runq != &runq) + ((ts)->ts_runq != 0 && (ts)->ts_runq != &runq_global) #define THREAD_CAN_SCHED(td, cpu) \ CPU_ISSET((cpu), &(td)->td_cpuset->cs_mask) @@ -154,7 +154,7 @@ sched_4bsd_schedcpu(void) /* * Global run queue. */ -static struct runq runq; +static struct runq runq_global; #ifdef SMP /* @@ -182,7 +182,7 @@ setup_runqs(void) runq_init(&runq_pcpu[i]); #endif - runq_init(&runq); + runq_init(&runq_global); } static int @@ -682,10 +682,10 @@ static bool sched_4bsd_runnable(void) { #ifdef SMP - return (runq_not_empty(&runq) || + return (runq_not_empty(&runq_global) || runq_not_empty(&runq_pcpu[PCPU_GET(cpuid)])); #else - return (runq_not_empty(&runq)); + return (runq_not_empty(&runq_global)); #endif } @@ -1371,7 +1371,7 @@ sched_4bsd_add(struct thread *td, int flags) "sched_add: adding td_sched:%p (td:%p) to gbl runq", ts, td); cpu = NOCPU; - ts->ts_runq = &runq; + ts->ts_runq = &runq_global; } if ((td->td_flags & TDF_NOLOAD) == 0) @@ -1435,7 +1435,7 @@ sched_4bsd_add(struct thread *td, int flags) } TD_SET_RUNQ(td); CTR2(KTR_RUNQ, "sched_add: adding td_sched:%p (td:%p) to runq", ts, td); - ts->ts_runq = &runq; + ts->ts_runq = &runq_global; if ((td->td_flags & TDF_NOLOAD) == 0) sched_load_add(); @@ -1466,7 +1466,7 @@ sched_4bsd_rem(struct thread *td) if ((td->td_flags & TDF_NOLOAD) == 0) sched_load_rem(); #ifdef SMP - if (ts->ts_runq != &runq) + if (ts->ts_runq != &runq_global) runq_length[ts->ts_runq - runq_pcpu]--; #endif runq_remove(ts->ts_runq, td); @@ -1481,14 +1481,14 @@ static struct thread * sched_4bsd_choose(void) { struct thread *td; - struct runq *rq; + struct runq *runq; mtx_assert(&sched_lock, MA_OWNED); #ifdef SMP struct thread *tdcpu; - rq = &runq; - td = runq_choose_fuzz(&runq, runq_fuzz); + runq = &runq_global; + td = runq_choose_fuzz(&runq_global, runq_fuzz); tdcpu = runq_choose(&runq_pcpu[PCPU_GET(cpuid)]); if (td == NULL || @@ -1497,14 +1497,14 @@ sched_4bsd_choose(void) CTR2(KTR_RUNQ, "choosing td %p from pcpu runq %d", tdcpu, PCPU_GET(cpuid)); td = tdcpu; - rq = &runq_pcpu[PCPU_GET(cpuid)]; + runq = &runq_pcpu[PCPU_GET(cpuid)]; } else { CTR1(KTR_RUNQ, "choosing td_sched %p from main runq", td); } #else - rq = &runq; - td = runq_choose(&runq); + runq = &runq_global; + td = runq_choose(&runq_global); #endif if (td) { @@ -1512,7 +1512,7 @@ sched_4bsd_choose(void) if (td == tdcpu) runq_length[PCPU_GET(cpuid)]--; #endif - runq_remove(rq, td); + runq_remove(runq, td); td->td_flags |= TDF_DIDRUN; KASSERT(td->td_flags & TDF_INMEM, @@ -1794,7 +1794,7 @@ sched_4bsd_affinity(struct thread *td) * If we are on a per-CPU runqueue that is in the set, * then nothing needs to be done. */ - if (ts->ts_runq != &runq && + if (ts->ts_runq != &runq_global && THREAD_CAN_SCHED(td, ts->ts_runq - runq_pcpu)) return;home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a5ed8ef.1fbc7.3173dc7f>
