linux/tools/bpf/bpftool
Quentin Monnet 8302b9bd31 tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps
The limit for memory locked in the kernel by a process is usually set to
64 kbytes by default. This can be an issue when creating large BPF maps
and/or loading many programs. A workaround is to raise this limit for
the current process before trying to create a new BPF map. Changing the
hard limit requires the CAP_SYS_RESOURCE and can usually only be done by
root user (for non-root users, a call to setrlimit fails (and sets
errno) and the program simply goes on with its rlimit unchanged).

There is no API to get the current amount of memory locked for a user,
therefore we cannot raise the limit only when required. One solution,
used by bcc, is to try to create the map, and on getting a EPERM error,
raising the limit to infinity before giving another try. Another
approach, used in iproute2, is to raise the limit in all cases, before
trying to create the map.

Here we do the same as in iproute2: the rlimit is raised to infinity
before trying to load programs or to create maps with bpftool.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-11-07 22:22:21 +01:00
..
bash-completion tools: bpftool: fix completion for "bpftool map update" 2018-10-21 20:45:14 +02:00
Documentation tools: bpftool: document restriction on '.' in names to pin in bpffs 2018-10-21 20:45:14 +02:00
.gitignore tools/bpftool: ignore build products 2018-07-26 02:50:26 +02:00
btf_dumper.c bpf: btf: add btf print functionality 2018-07-14 13:00:40 +02:00
cfg.c
cfg.h
cgroup.c bpftool: introduce cgroup tree command 2018-07-07 01:38:38 +02:00
common.c tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps 2018-11-07 22:22:21 +01:00
jit_disasm.c tools: bpftool: use 4 context mode for the NFP disasm 2018-10-18 22:16:02 +02:00
json_writer.c
json_writer.h
main.c tools: bpftool: print nb of cmds to stdout (not stderr) for batch mode 2018-10-21 20:45:14 +02:00
main.h tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps 2018-11-07 22:22:21 +01:00
Makefile bpftool: Allow add linker flags via EXTRA_LDFLAGS variable 2018-10-11 10:24:53 +02:00
map.c tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps 2018-11-07 22:22:21 +01:00
map_perf_ring.c bpf, libbpf: simplify and cleanup perf ring buffer walk 2018-10-20 23:13:32 -07:00
net.c libbpf: Consistent prefixes for interfaces in nlattr.h. 2018-10-04 16:04:16 +02:00
netlink_dumper.c libbpf: Consistent prefixes for interfaces in nlattr.h. 2018-10-04 16:04:16 +02:00
netlink_dumper.h bpftool: Fix bpftool net output 2018-09-27 21:07:44 +02:00
perf.c tools/bpftool: fix a bug in bpftool perf 2018-06-13 02:03:17 +02:00
prog.c tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps 2018-11-07 22:22:21 +01:00
xlated_dumper.c tools: bpf: make use of reallocarray 2018-07-11 22:13:34 +02:00
xlated_dumper.h tools: bpftool: add delimiters to multi-function JITed dumps 2018-05-24 09:20:50 +02:00