Commit 829aa484 authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #119 from iovisor/enforce-infinite-rlimit

enforce infinite rlimit to avoid problems when allocating maps
parents df4be920 8b1d0d1c
#include <iostream>
#include <signal.h>
#include <sys/resource.h>
#include "bpforc.h"
#include "bpftrace.h"
......@@ -34,6 +35,22 @@ void usage()
std::cerr << " count syscalls by process name" << std::endl;
}
static void enforce_infinite_rlimit() {
struct rlimit rl = {};
if (getrlimit(RLIMIT_MEMLOCK, &rl) != 0) {
std::cerr << "Warning: couldn't set RLIMIT for bpftrace. " <<
"If your program is not loading, you can try " <<
"\"ulimit -l 8192\" to fix the problem" << std::endl;
return;
}
rl.rlim_max = RLIM_INFINITY;
rl.rlim_cur = rl.rlim_max;
if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
std::cerr << "Warning: couldn't set RLIMIT for bpftrace. " <<
"If your program is not loading, you can try " <<
"\"ulimit -l 8192\" to fix the problem" << std::endl;
}
int main(int argc, char *argv[])
{
int err;
......@@ -118,6 +135,10 @@ int main(int argc, char *argv[])
if (err)
return err;
// FIXME (mmarchini): maybe we don't want to always enforce an infinite
// rlimit?
enforce_infinite_rlimit();
BPFtrace bpftrace;
// defaults
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment