aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2026-01-23 15:15:43 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2026-01-29 18:11:56 +0000
commitff870b783f098cafd8b938379eada6b8cfe9a4fb (patch)
treea1769343806299781c7f56f772b412b6a640898b
parent5a6e0e31bc2e8ed8f655be63fa5b8c41f3d60753 (diff)
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
-rw-r--r--sys/kern/sched_4bsd.c10
-rw-r--r--sys/kern/sched_shim.c4
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");