summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2015-12-05 20:54:35 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2015-12-05 20:54:35 +0000
commit689072f96d79c8dc9cfcf02d6a56ad3752547240 (patch)
tree74b85e2e957ea15d98f07ec07cd8d17a2d0cfe3e
parentef66c470838f9b41f8c9050cad8f69262a968e91 (diff)
Make sure we use the same cpu numbering for the kern.cptime2 sysctl as we
do for kern.proc. Fixes the issue in top(1) where a cpu would seem to be idle even though a thread was reported to be running on it. ok mpi@, tedu@, deraadt@
-rw-r--r--sys/kern/kern_sysctl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 222bf4d89f9..cda2922f9b8 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.298 2015/11/01 19:03:33 semarie Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.299 2015/12/05 20:54:34 kettenis Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -2375,18 +2375,18 @@ sysctl_cptime2(int *name, u_int namelen, void *oldp, size_t *oldlenp,
{
CPU_INFO_ITERATOR cii;
struct cpu_info *ci;
- int i;
+ int found = 0;
if (namelen != 1)
return (ENOTDIR);
- i = name[0];
-
CPU_INFO_FOREACH(cii, ci) {
- if (i-- == 0)
+ if (name[0] == CPU_INFO_UNIT(ci)) {
+ found = 1;
break;
+ }
}
- if (i > 0)
+ if (!found)
return (ENOENT);
return (sysctl_rdstruct(oldp, oldlenp, newp,