PERFORCE change 134029 for review
John Birrell
jb at FreeBSD.org
Thu Jan 24 14:20:18 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=134029
Change 134029 by jb at 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);
More information about the p4-projects
mailing list