seccomp: JIT compile seccomp filter
authorAlexei Starovoitov <ast@plumgrid.com>
Wed, 14 May 2014 02:50:47 +0000 (19:50 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 15 May 2014 20:31:30 +0000 (16:31 -0400)
commit8f577cadf7181243d336be9aba40c1bcc02c4c54
tree67daf2164c9c5b633160489d637b8ecc84b62881
parent622582786c9e041d0bd52bde201787adeab249f8
seccomp: JIT compile seccomp filter

Take advantage of internal BPF JIT

05-sim-long_jumps.c of libseccomp was used as micro-benchmark:

 seccomp_rule_add_exact(ctx,...
 seccomp_rule_add_exact(ctx,...

 rc = seccomp_load(ctx);

 for (i = 0; i < 10000000; i++)
    syscall(...);

$ sudo sysctl net.core.bpf_jit_enable=1
$ time ./bench
real 0m2.769s
user 0m1.136s
sys 0m1.624s

$ sudo sysctl net.core.bpf_jit_enable=0
$ time ./bench
real 0m5.825s
user 0m1.268s
sys 0m4.548s

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/seccomp.c