summaryrefslogtreecommitdiff
path: root/samples/bpf/test_verifier.c
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2014-10-29 01:11:41 +0300
committerDavid S. Miller <davem@davemloft.net>2014-10-30 22:44:37 +0300
commit9c3997601d51069ec08d7d06cf31a17884056cc2 (patch)
tree640f601a6df8b0cd19d33af5c47691e3294db143 /samples/bpf/test_verifier.c
parentd3627795d074d3877e0818ab533c86139ea31413 (diff)
downloadlinux-9c3997601d51069ec08d7d06cf31a17884056cc2.tar.xz
bpf: reduce verifier memory consumption
verifier keeps track of register state spilled to stack. registers are 8-byte wide and always aligned, so instead of tracking them in every byte-sized stack slot, use MAX_BPF_STACK / 8 array to track spilled register state. Though verifier runs in user context and its state freed immediately after verification, it makes sense to reduce its memory usage. This optimization reduces sizeof(struct verifier_state) from 12464 to 1712 on 64-bit and from 6232 to 1112 on 32-bit. Note, this patch doesn't change existing limits, which are there to bound time and memory during verification: 4k total number of insns in a program, 1k number of jumps (states to visit) and 32k number of processed insn (since an insn may be visited multiple times). Theoretical worst case memory during verification is 1712 * 1k = 17Mbyte. Out-of-memory situation triggers cleanup and rejects the program. Suggested-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/test_verifier.c')
0 files changed, 0 insertions, 0 deletions