summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2018-11-17 23:10:09 +0000
committercheloha <cheloha@cvs.openbsd.org>2018-11-17 23:10:09 +0000
commitd6136e8d27d8e31ad8c702cddb7486fa7d975c9c (patch)
tree143e3f6ea14c3cb78d3bd6928e2df80f77f7133f /lib
parent660a8098742488fed8eaed56e3428d66271ab342 (diff)
Add new KERN_CPUSTATS sysctl(2) so we can identify offline CPUs.
Because of hw.smt we need a way to determine whether a given CPU is "online" or "offline" from userspace. KERN_CPTIME2 is an array, and so cannot be cleanly extended for this purpose, so add a new sysctl(2) KERN_CPUSTATS with an extensible struct. At the moment it's just KERN_CPTIME2 with a flags member, but it can grow as needed. KERN_CPUSTATS appears to have been defined by BSDi long ago, but there are few (if any) packages in the wild still using the symbol so breakage in ports should be near zero. No other system inherited the symbol from BSDi, either. Then, use the new sysctl(2) in systat(1) and top(1): - systat(1) draws placeholder marks ('-') instead of percentages for offline CPUs in the cpu view. - systat(1) omits offline CPU ticks when drawing the "big bar" in the vmstat view. The upshot is that the bar isn't half idle when half your logical CPUs are disabled. - top(1) does not draw lines for offline CPUs; if CPUs toggle on or offline in interactive mode we redraw the display to expand/reduce space for the new/missing CPUs. This is consistent with what some top(1) implementations do on Linux. - top(1) omits offline CPUs from the totals when CPU totals are combined into a single line (the '-1' flag). Originally prompted by deraadt@. Discussed endlessly with deraadt@, ketennis@, and sthen@. Tested by jmc@ and jca@. Earlier versions also discussed with jca@. Earlier versions tested by jmc@, tb@, and many others. docs ok jmc@, kernel bits ok ketennis@, everything ok sthen@, "Is your stuff in yet?" deraadt@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/sys/sysctl.213
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libc/sys/sysctl.2 b/lib/libc/sys/sysctl.2
index a26c4b269d5..e5e7ef07ef0 100644
--- a/lib/libc/sys/sysctl.2
+++ b/lib/libc/sys/sysctl.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sysctl.2,v 1.14 2018/11/06 13:16:54 otto Exp $
+.\" $OpenBSD: sysctl.2,v 1.15 2018/11/17 23:10:07 cheloha Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: November 6 2018 $
+.Dd $Mdocdate: November 17 2018 $
.Dt SYSCTL 2
.Os
.Sh NAME
@@ -429,6 +429,7 @@ information.
.It Dv KERN_CONSDEV Ta "dev_t" Ta "no"
.It Dv KERN_CPTIME Ta "long[CPUSTATES]" Ta "no"
.It Dv KERN_CPTIME2 Ta "u_int64_t[CPUSTATES]" Ta "no"
+.It Dv KERN_CPUSTATS Ta "struct cpustats" Ta "no"
.It Dv KERN_DNSJACKPORT Ta "integer" Ta "yes"
.It Dv KERN_DOMAINNAME Ta "string" Ta "yes"
.It Dv KERN_FILE Ta "struct kinfo_file" Ta "no"
@@ -561,6 +562,14 @@ Similar to
.Dv KERN_CPTIME ,
but obtains information from only the single CPU specified by the
third level name given.
+.It Dv KERN_CPUSTATS
+A
+.Li struct cpustats
+structure is returned.
+This structure contains the array described in
+.Dv KERN_CPTIME2
+and a bit mask indicating the status of the CPU specified by the
+third level name.
.It Dv KERN_DNSJACKPORT Pq Va kern.dnsjackport
When non-zero, the localhost port to which all DNS sockets should be
redirected.