Date: Thu, 24 Jan 2008 22:20:18 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 134029 for review Message-ID: <200801242220.m0OMKIQK022554@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134029 Change 134029 by jb@jb_freebsd1 on 2008/01/24 22:19:58 Use the new kern.smp.maxid syscall to determine if the requested CPU is available. It's a bit crude, but we don't take CPUs offline anyway. Affected files ... .. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_subr.c#15 edit Differences ... ==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_subr.c#15 (text) ==== @@ -40,6 +40,8 @@ #include <ctype.h> #if defined(sun) #include <alloca.h> +#else +#include <sys/sysctl.h> #endif #include <assert.h> #include <libgen.h> @@ -499,12 +501,18 @@ { const dtrace_vector_t *v = dtp->dt_vector; - if (v == NULL) + if (v == NULL) { #if defined(sun) return (p_online(cpu, P_STATUS)); #else - return (cpu == 0 ? 1:-1); + int maxid = 0; + size_t len = sizeof(maxid); + if (sysctlbyname("kern.smp.maxid", &maxid, &len, NULL, 0) != 0) + return (cpu == 0 ? 1 : -1); + else + return (cpu <= maxid ? 1 : -1); #endif + } return (v->dtv_status(dtp->dt_varg, cpu)); } @@ -721,6 +729,11 @@ { void *data; + if (size > 16 * 1024 * 1024) { + (void) dt_set_errno(dtp, EDT_NOMEM); + return (NULL); + } + if ((data = malloc(size)) == NULL) (void) dt_set_errno(dtp, EDT_NOMEM); else @@ -734,6 +747,11 @@ { void *data; + if (size > 16 * 1024 * 1024) { + (void) dt_set_errno(dtp, EDT_NOMEM); + return (NULL); + } + if ((data = malloc(size)) == NULL) (void) dt_set_errno(dtp, EDT_NOMEM);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801242220.m0OMKIQK022554>