map_attrs = attrs;
map_fds.assign(n, -1);
+ // XXX: PR24324 -- This overhead space calculation was too
+ // conservative and caused resource exhaustion errors, disabling it
+ // until we figure out how much space we need or if the
+ // RLIM_INFINITY solution below is adequate.
+#if 0
/* First, make room for the maps in this process' RLIMIT_MEMLOCK: */
size_t rlimit_increase = 0;
for (i = 0; i < n; ++i)
// TODO: Note that Certain Other Tools just give up on
// calculating and set rlimit to the maximum possible.
}
+#endif
struct rlimit curr_rlimit;
int rc;
rlim_t rlim_orig = curr_rlimit.rlim_cur;
rlim_t rlim_max_orig = curr_rlimit.rlim_max;
+#if 0
curr_rlimit.rlim_cur += rlimit_increase;
curr_rlimit.rlim_max += rlimit_increase;
if (curr_rlimit.rlim_cur < rlim_orig) // handle overflow
curr_rlimit.rlim_cur = rlim_orig;
if (curr_rlimit.rlim_max < rlim_max_orig) // handle overflow
curr_rlimit.rlim_max = rlim_max_orig;
+#endif
// TODOXXX: PR24324 -- EXPERIMENTAL fix for aggressive resource limits.
// Other Tools do something like this but it doesn't solve all our problems.
curr_rlimit.rlim_cur = RLIM_INFINITY;
// coming on/offline and adjust accordingly.
long ncpus_ = sysconf(_SC_NPROCESSORS_CONF);
unsigned ncpus = ncpus_ > 0 ? ncpus_ : 1;
+ if (ncpus_ < 0)
+ fprintf(stderr, "WARNING: could not get number of CPUs, falling back to 1: %s\n", strerror(errno));
+ else if (ncpus_ == 0)
+ fprintf(stderr, "WARNING: could not get number of CPUs, falling back to 1\n"); // XXX no errno
//unsigned ncpus = get_nprocs_conf();
- mark_active_cpus(ncpus);
+ mark_active_cpus((unsigned)ncpus);
attrs[i].max_entries = ncpus;
}
{
fprintf(stderr, "Error reading probe event id %zu: %s\n",
i, strerror(errno));
+ close(fd);
goto fail;
}
close(fd);