diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-10-29 13:31:10 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-10-29 13:31:10 +0000 |
commit | a5ea18413ed6beb09aa13011f52cb7f193b1614e (patch) | |
tree | 920bbfb3509bcf0a8c856da9edccd1bbd416b6da | |
parent | 192d172d5b1d8af52903ebccf1859dbd3a5385f3 (diff) | |
download | FreeBSD-src-a5ea18413ed6beb09aa13011f52cb7f193b1614e.zip FreeBSD-src-a5ea18413ed6beb09aa13011f52cb7f193b1614e.tar.gz |
Add sysctl kern.sched.cpusetsize to export the size of kernel cpuset,
also add sysconf() key _SC_CPUSET_SIZE to get sysctl value.
Submitted by: gcooper
-rw-r--r-- | include/unistd.h | 1 | ||||
-rw-r--r-- | lib/libc/gen/sysconf.c | 9 | ||||
-rw-r--r-- | sys/kern/sched_ule.c | 11 |
3 files changed, 21 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h index 4ae6917..34f187c 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -288,6 +288,7 @@ typedef __useconds_t useconds_t; #if __BSD_VISIBLE #define _SC_NPROCESSORS_CONF 57 #define _SC_NPROCESSORS_ONLN 58 +#define _SC_CPUSET_SIZE 122 #endif /* Extensions found in Solaris and Linux. */ diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 4618f32..7539d61 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -597,6 +597,15 @@ yesno: return (lvalue); #endif +#ifdef _SC_CPUSET_SIZE + case _SC_CPUSET_SIZE: + len = sizeof(lvalue); + if (sysctlbyname("kern.sched.cpusetsize", &lvalue, &len, NULL, + 0) == -1) + return (-1); + return (lvalue); +#endif + default: errno = EINVAL; return (-1); diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 4765c1c..641979d 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -2712,6 +2712,8 @@ sysctl_kern_sched_topology_spec(SYSCTL_HANDLER_ARGS) sbuf_delete(topo); return (err); } + +static size_t _kern_cpuset_size = sizeof(cpuset_t); #endif SYSCTL_NODE(_kern, OID_AUTO, sched, CTLFLAG_RW, 0, "Scheduler"); @@ -2748,6 +2750,15 @@ SYSCTL_INT(_kern_sched, OID_AUTO, steal_thresh, CTLFLAG_RW, &steal_thresh, 0, SYSCTL_PROC(_kern_sched, OID_AUTO, topology_spec, CTLTYPE_STRING | CTLFLAG_RD, NULL, 0, sysctl_kern_sched_topology_spec, "A", "XML dump of detected CPU topology"); + +/* + * Return the size of cpuset_t at the kernel level + * + * XXX (gcooper): replace ULONG with SIZE once CTLTYPE_SIZE is implemented. + */ +SYSCTL_ULONG(_kern_sched, OID_AUTO, cpusetsize, CTLFLAG_RD, + &_kern_cpuset_size, 0, "Kernel-level cpuset_t struct size"); + #endif /* ps compat. All cpu percentages from ULE are weighted. */ |