svn commit: r214510 - in head: include lib/libc/gen sys/kern

David Xu davidxu at FreeBSD.org
Fri Oct 29 13:31:11 UTC 2010


Author: davidxu
Date: Fri Oct 29 13:31:10 2010
New Revision: 214510
URL: http://svn.freebsd.org/changeset/base/214510

Log:
  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

Modified:
  head/include/unistd.h
  head/lib/libc/gen/sysconf.c
  head/sys/kern/sched_ule.c

Modified: head/include/unistd.h
==============================================================================
--- head/include/unistd.h	Fri Oct 29 11:13:42 2010	(r214509)
+++ head/include/unistd.h	Fri Oct 29 13:31:10 2010	(r214510)
@@ -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. */

Modified: head/lib/libc/gen/sysconf.c
==============================================================================
--- head/lib/libc/gen/sysconf.c	Fri Oct 29 11:13:42 2010	(r214509)
+++ head/lib/libc/gen/sysconf.c	Fri Oct 29 13:31:10 2010	(r214510)
@@ -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);

Modified: head/sys/kern/sched_ule.c
==============================================================================
--- head/sys/kern/sched_ule.c	Fri Oct 29 11:13:42 2010	(r214509)
+++ head/sys/kern/sched_ule.c	Fri Oct 29 13:31:10 2010	(r214510)
@@ -2712,6 +2712,8 @@ sysctl_kern_sched_topology_spec(SYSCTL_H
 	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_
 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. */


More information about the svn-src-all mailing list