Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Apr 2006 10:14:17 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 96146 for review
Message-ID:  <200604261014.k3QAEHr5052234@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96146

Change 96146 by jb@jb_freebsd2 on 2006/04/26 10:13:20

	Add a sysctl for mp_maxid and corresponding sysconf(3) definitions to match
	the ones that Solaris uses.

Affected files ...

.. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c#8 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_consume.c#6 edit
.. //depot/projects/dtrace/src/include/unistd.h#2 edit
.. //depot/projects/dtrace/src/lib/libc/gen/sysconf.c#2 edit
.. //depot/projects/dtrace/src/sys/kern/subr_smp.c#2 edit

Differences ...

==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c#8 (text) ====

@@ -34,6 +34,8 @@
 #include <assert.h>
 #if defined(sun)
 #include <alloca.h>
+#else
+#include <sys/sysctl.h>
 #endif
 #include <limits.h>
 
@@ -979,14 +981,8 @@
 	assert(agp->dtat_ncpu == 0);
 	assert(agp->dtat_cpus == NULL);
 
-printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
-#ifdef DOODAD
 	agp->dtat_maxcpu = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
 	agp->dtat_ncpu = dt_sysconf(dtp, _SC_NPROCESSORS_MAX);
-#else
-	agp->dtat_maxcpu = 1;
-	agp->dtat_ncpu = 1;
-#endif
 	agp->dtat_cpus = malloc(agp->dtat_ncpu * sizeof (processorid_t));
 
 	if (agp->dtat_cpus == NULL)

==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_consume.c#6 (text) ====

@@ -1813,13 +1813,8 @@
 	if ((nbuf.dtbd_data = malloc(size)) == NULL)
 		return (dt_set_errno(dtp, EDT_NOMEM));
 
-printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
 	if (max_ncpus == 0)
-#ifdef DOODAD
 		max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
-else
-		max_ncpus = 1;
-#endif
 
 	for (i = 0; i < max_ncpus; i++) {
 		nbuf.dtbd_cpu = i;
@@ -1901,13 +1896,8 @@
 	if (!dtp->dt_active)
 		return (dt_set_errno(dtp, EINVAL));
 
-printf("%s:%s(%d): dt_sysconf _SC_CPUID_MAX\n",__FUNCTION__,__FILE__,__LINE__);
 	if (max_ncpus == 0)
-#ifdef DOODAD
 		max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
-#else
-		max_ncpus = 1;
-#endif
 
 	if (pf == NULL)
 		pf = (dtrace_consume_probe_f *)dt_nullprobe;
@@ -1972,7 +1962,7 @@
 #if defined(sun)
 	if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
 #else
-	if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
+	if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) {
 #endif
 		/*
 		 * This _really_ shouldn't fail, but it is strictly speaking

==== //depot/projects/dtrace/src/include/unistd.h#2 (text+ko) ====

@@ -292,6 +292,8 @@
 #if __BSD_VISIBLE
 #define	_SC_NPROCESSORS_CONF	57
 #define	_SC_NPROCESSORS_ONLN	58
+#define	_SC_NPROCESSORS_MAX	121
+#define	_SC_CPUID_MAX		122
 #endif
 
 /* Keys for the confstr(3) function. */

==== //depot/projects/dtrace/src/lib/libc/gen/sysconf.c#2 (text+ko) ====

@@ -52,6 +52,7 @@
 #include <pthread.h>		/* we just need the limits */
 #include <time.h>
 #include <unistd.h>
+#include <stdio.h>
 
 #include "../stdlib/atexit.h"
 #include "../stdtime/tzfile.h"
@@ -76,8 +77,11 @@
 {
 	struct rlimit rl;
 	size_t len;
+	int error = 0;
 	int mib[2], sverrno, value;
+	int n_mib = 2;
 	long defaultresult;
+	const char *p_name = NULL;
 	const char *path;
 
 	len = sizeof(value);
@@ -570,13 +574,25 @@
 
 	case _SC_NPROCESSORS_CONF:
 	case _SC_NPROCESSORS_ONLN:
+	case _SC_NPROCESSORS_MAX:
 		mib[0] = CTL_HW;
 		mib[1] = HW_NCPU;
 		break;
 
+	case _SC_CPUID_MAX:
+		p_name = "kern.smp.maxid";
+		break;
+
 	default:
+		n_mib = 0;
+	}
+	if (n_mib && p_name == NULL)
+		error = sysctl(mib, n_mib, &value, &len, NULL, 0);
+	else if (p_name != NULL)
+		error = sysctlbyname(p_name, &value, &len, NULL, 0);
+	else {
 		errno = EINVAL;
-		return (-1);
+		error = -1;
 	}
-	return (sysctl(mib, 2, &value, &len, NULL, 0) == -1 ? -1 : value);
+	return (error == -1 ? -1 : value);
 }

==== //depot/projects/dtrace/src/sys/kern/subr_smp.c#2 (text+ko) ====

@@ -76,6 +76,9 @@
 SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD, &mp_maxcpus, 0,
     "Max number of CPUs that the system was compiled for.");
 
+SYSCTL_INT(_kern_smp, OID_AUTO, maxid, CTLFLAG_RD, &mp_maxid, 0,
+    "Max CPU ID.");
+
 int smp_active = 0;	/* are the APs allowed to run? */
 SYSCTL_INT(_kern_smp, OID_AUTO, active, CTLFLAG_RW, &smp_active, 0,
     "Number of Auxillary Processors (APs) that were successfully started");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604261014.k3QAEHr5052234>