From 48587c836af7a008eff4964094e97aa1c94a34b0 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 25 Jul 2025 02:46:37 -0400 Subject: kernel: accnt: Report how many cores are halted Introduce reporting of the number of halted cores for the scheduler accounting logic. Signed-off-by: Ian Moffett --- sys/kern/kern_accnt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_accnt.c b/sys/kern/kern_accnt.c index cd15863..51905e7 100644 --- a/sys/kern/kern_accnt.c +++ b/sys/kern/kern_accnt.c @@ -58,6 +58,25 @@ ctl_stat_read(struct ctlfs_dev *cdp, struct sio_txn *sio) return sio->len; } +static uint16_t +cpu_nhlt(void) +{ + uint16_t nhlt = 0; + struct cpu_info *ci; + + for (size_t i = 0; i < CPU_MAX; ++i) { + ci = cpu_get(i); + if (ci == NULL) { + continue; + } + if (!ci->online) { + ++nhlt; + } + } + + return nhlt; +} + /* * Get scheduler accounting information * @@ -71,6 +90,7 @@ sched_stat(struct sched_stat *statp) statp->nproc = atomic_load_64(&g_nthreads); statp->ncpu = cpu_count(); statp->quantum_usec = DEFAULT_TIMESLICE_USEC; + statp->nhlt = cpu_nhlt(); /* * Setup the per-cpu info/statistics -- cgit v1.2.3