diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2005-06-08 22:33:28 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2005-06-08 22:33:28 +0000 |
commit | 09fc260787b747e5484efa3b2527d23b187115f3 (patch) | |
tree | 4f3aa38cf2b01df0f299b5373c641be01e986bc6 /sys/kern/kern_sysctl.c | |
parent | b62d080d93fd196c6ee64318594dec0d6c6a764a (diff) |
Add KERN_CPTIME2 on systems where __HAVE_CPUINFO is defined, exposes
spc_cp_time member of struct schedstate_percpu (per-cpu stats).
From art@ during the hackathon.
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index f8219b49762..ac0e8d7dad5 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.126 2005/06/04 05:10:40 tedu Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.127 2005/06/08 22:33:27 millert Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -101,6 +101,7 @@ int sysctl_proc_args(int *, u_int, void *, size_t *, struct proc *); int sysctl_intrcnt(int *, u_int, void *, size_t *); int sysctl_sensors(int *, u_int, void *, size_t *, void *, size_t); int sysctl_emul(int *, u_int, void *, size_t *, void *, size_t); +int sysctl_cptime2(int *, u_int, void *, size_t *, void *, size_t); int (*cpu_cpuspeed)(int *); int (*cpu_setperf)(int); @@ -288,6 +289,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) #ifdef __HAVE_TIMECOUNTER case KERN_TIMECOUNTER: #endif + case KERN_CPTIME2: break; default: return (ENOTDIR); /* overloaded */ @@ -550,6 +552,11 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) #endif case KERN_MAXLOCKSPERUID: return (sysctl_int(oldp, oldlenp, newp, newlen, &maxlocksperuid)); +#ifdef __HAVE_CPUINFO + case KERN_CPTIME2: + return (sysctl_cptime2(name + 1, namelen -1, oldp, oldlenp, + newp, newlen)); +#endif default: return (EOPNOTSUPP); } @@ -1870,3 +1877,30 @@ sysctl_emul(int *name, u_int namelen, void *oldp, size_t *oldlenp, } #endif /* SMALL_KERNEL */ + +#ifdef __HAVE_CPUINFO +int +sysctl_cptime2(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + CPU_INFO_ITERATOR cii; + struct cpu_info *ci; + int i; + + if (namelen != 1) + return (ENOTDIR); + + i = name[0]; + + for (CPU_INFO_FOREACH(cii, ci)) { + if (i-- == 0) + break; + } + if (i > 0) + return (ENOENT); + + return (sysctl_rdstruct(oldp, oldlenp, newp, + &ci->ci_schedstate.spc_cp_time, + sizeof(ci->ci_schedstate.spc_cp_time))); +} +#endif |