From 8a3973e46941b6a8c88a49594364a04ee4b1d84e Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 16 Jul 2025 20:48:35 -0400 Subject: kernel: accnt: Keep track of per-cpu stats Signed-off-by: Ian Moffett --- sys/kern/kern_accnt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sys/kern/kern_accnt.c') diff --git a/sys/kern/kern_accnt.c b/sys/kern/kern_accnt.c index 3b90d9f..cd15863 100644 --- a/sys/kern/kern_accnt.c +++ b/sys/kern/kern_accnt.c @@ -66,9 +66,23 @@ ctl_stat_read(struct ctlfs_dev *cdp, struct sio_txn *sio) void sched_stat(struct sched_stat *statp) { + struct sched_cpu *cpustat; + statp->nproc = atomic_load_64(&g_nthreads); statp->ncpu = cpu_count(); statp->quantum_usec = DEFAULT_TIMESLICE_USEC; + + /* + * Setup the per-cpu info/statistics + */ + for (int i = 0; i < CPU_MAX; ++i) { + cpustat = cpu_get_stat(i); + if (cpustat == NULL) { + break; + } + + statp->cpus[i] = *cpustat; + } } void -- cgit v1.2.3