summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/include/sys/sched.h2
-rw-r--r--sys/kern/kern_accnt.c20
2 files changed, 22 insertions, 0 deletions
diff --git a/sys/include/sys/sched.h b/sys/include/sys/sched.h
index abc2718..7a859b2 100644
--- a/sys/include/sys/sched.h
+++ b/sys/include/sys/sched.h
@@ -49,11 +49,13 @@ struct sched_cpu {
*
* @nproc: Number processes running
* @ncpu: Number of CPU cores
+ * @nhlt: Number of halted CPU cores
* @quantum_usec: Scheduler quantum (microseconds)
*/
struct sched_stat {
size_t nproc;
uint16_t ncpu;
+ uint16_t nhlt;
uint32_t quantum_usec;
struct sched_cpu cpus[CPU_MAX];
};
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