diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2015-03-01 06:31:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-01 14:05:19 -0500 |
commit | 24701ecea76b0b93bd9667486934ec310825f558 (patch) | |
tree | 7f658077fea363e89643d95fc808236d748b8431 /kernel/bpf/syscall.c | |
parent | 96be4325f443dbbfeb37d2a157675ac0736531a1 (diff) |
ebpf: move read-only fields to bpf_prog and shrink bpf_prog_aux
is_gpl_compatible and prog_type should be moved directly into bpf_prog
as they stay immutable during bpf_prog's lifetime, are core attributes
and they can be locked as read-only later on via bpf_prog_select_runtime().
With a bit of rearranging, this also allows us to shrink bpf_prog_aux
to exactly 1 cacheline.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 536edc2be307..0d69449acbd0 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -354,10 +354,11 @@ static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) | |||
354 | list_for_each_entry(tl, &bpf_prog_types, list_node) { | 354 | list_for_each_entry(tl, &bpf_prog_types, list_node) { |
355 | if (tl->type == type) { | 355 | if (tl->type == type) { |
356 | prog->aux->ops = tl->ops; | 356 | prog->aux->ops = tl->ops; |
357 | prog->aux->prog_type = type; | 357 | prog->type = type; |
358 | return 0; | 358 | return 0; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | |||
361 | return -EINVAL; | 362 | return -EINVAL; |
362 | } | 363 | } |
363 | 364 | ||
@@ -508,7 +509,7 @@ static int bpf_prog_load(union bpf_attr *attr) | |||
508 | prog->jited = false; | 509 | prog->jited = false; |
509 | 510 | ||
510 | atomic_set(&prog->aux->refcnt, 1); | 511 | atomic_set(&prog->aux->refcnt, 1); |
511 | prog->aux->is_gpl_compatible = is_gpl; | 512 | prog->gpl_compatible = is_gpl; |
512 | 513 | ||
513 | /* find program type: socket_filter vs tracing_filter */ | 514 | /* find program type: socket_filter vs tracing_filter */ |
514 | err = find_prog_type(type, prog); | 515 | err = find_prog_type(type, prog); |
@@ -517,7 +518,6 @@ static int bpf_prog_load(union bpf_attr *attr) | |||
517 | 518 | ||
518 | /* run eBPF verifier */ | 519 | /* run eBPF verifier */ |
519 | err = bpf_check(prog, attr); | 520 | err = bpf_check(prog, attr); |
520 | |||
521 | if (err < 0) | 521 | if (err < 0) |
522 | goto free_used_maps; | 522 | goto free_used_maps; |
523 | 523 | ||
@@ -528,7 +528,6 @@ static int bpf_prog_load(union bpf_attr *attr) | |||
528 | bpf_prog_select_runtime(prog); | 528 | bpf_prog_select_runtime(prog); |
529 | 529 | ||
530 | err = anon_inode_getfd("bpf-prog", &bpf_prog_fops, prog, O_RDWR | O_CLOEXEC); | 530 | err = anon_inode_getfd("bpf-prog", &bpf_prog_fops, prog, O_RDWR | O_CLOEXEC); |
531 | |||
532 | if (err < 0) | 531 | if (err < 0) |
533 | /* failed to allocate fd */ | 532 | /* failed to allocate fd */ |
534 | goto free_used_maps; | 533 | goto free_used_maps; |