The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ff870b783f098cafd8b938379eada6b8cfe9a4fb
commit ff870b783f098cafd8b938379eada6b8cfe9a4fb Author: Konstantin Belousov <[email protected]> AuthorDate: 2026-01-23 15:15:43 +0000 Commit: Konstantin Belousov <[email protected]> CommitDate: 2026-01-29 18:11:56 +0000 sched_shim: restore kern.ccpu sysctl It is apparently should be considered part of the ABI, and is used by the base top(1). But do not declare the ccpu variable in headers, it is needed only by 4bsd. So put the variable definition into sched_shim.c to make the kernel buildable without SCHED_4BSD. Reviewed by: olce Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54831 --- sys/kern/sched_4bsd.c | 10 ++++++---- sys/kern/sched_shim.c | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 11baf9d2bdfa..4c24d98173f3 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -436,10 +436,7 @@ maybe_preempt(struct thread *td) #define loadfactor(loadav) (2 * (loadav)) #define decay_cpu(loadfac, cpu) (((loadfac) * (cpu)) / ((loadfac) + FSCALE)) -/* decay 95% of `ts_pctcpu' in 60 seconds; see CCPU_SHIFT before changing */ -static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ -SYSCTL_UINT(_kern_sched_4bsd, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, - "Decay factor used for updating %CPU"); +extern fixpt_t ccpu; /* * If `ccpu' is not equal to `exp(-1/20)' and you still want to use the @@ -638,6 +635,11 @@ resetpriority_thread(struct thread *td) static void sched_4bsd_setup(void) { + /* + * Decay 95% of `ts_pctcpu' in 60 seconds; see CCPU_SHIFT + * before changing. + */ + ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ setup_runqs(); diff --git a/sys/kern/sched_shim.c b/sys/kern/sched_shim.c index 816d0b44bb52..f6b1285830fd 100644 --- a/sys/kern/sched_shim.c +++ b/sys/kern/sched_shim.c @@ -199,3 +199,7 @@ SYSCTL_PROC(_kern_sched, OID_AUTO, available, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_sched_available, "A", "List of available schedulers"); + +fixpt_t ccpu; +SYSCTL_UINT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, + "Decay factor used for updating %CPU");
