From owner-p4-projects@FreeBSD.ORG Wed Apr 26 10:14:19 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2165E16A402; Wed, 26 Apr 2006 10:14:19 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7CC316A400 for ; Wed, 26 Apr 2006 10:14:18 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8BC8343D46 for ; Wed, 26 Apr 2006 10:14:18 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3QAEI96052249 for ; Wed, 26 Apr 2006 10:14:18 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3QAEHr5052234 for perforce@freebsd.org; Wed, 26 Apr 2006 10:14:17 GMT (envelope-from jb@freebsd.org) Date: Wed, 26 Apr 2006 10:14:17 GMT Message-Id: <200604261014.k3QAEHr5052234@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 96146 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Apr 2006 10:14:19 -0000 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 #if defined(sun) #include +#else +#include #endif #include @@ -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 /* we just need the limits */ #include #include +#include #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");