1
0
Fork 0
alistair23-linux/kernel/bpf
Alexei Starovoitov a6ed3ea65d bpf: restore behavior of bpf_map_update_elem
The introduction of pre-allocated hash elements inadvertently broke
the behavior of bpf hash maps where users expected to call
bpf_map_update_elem() without considering that the map can be full.
Some programs do:
old_value = bpf_map_lookup_elem(map, key);
if (old_value) {
  ... prepare new_value on stack ...
  bpf_map_update_elem(map, key, new_value);
}
Before pre-alloc the update() for existing element would work even
in 'map full' condition. Restore this behavior.

The above program could have updated old_value in place instead of
update() which would be faster and most programs use that approach,
but sometimes the values are large and the programs use update()
helper to do atomic replacement of the element.
Note we cannot simply update element's value in-place like percpu
hash map does and have to allocate extra num_possible_cpu elements
and use this extra reserve when the map is full.

Fixes: 6c90598174 ("bpf: pre-allocate hash map elements")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-08-06 20:49:19 -04:00
..
Makefile bpf: introduce percpu_freelist 2016-03-08 15:28:31 -05:00
arraymap.c bpf: bpf_event_entry_gen's alloc needs to be in atomic context 2016-07-16 22:03:39 -07:00
core.c bpf: avoid stack copy and use skb ctx for event output 2016-07-15 14:23:56 -07:00
hashtab.c bpf: restore behavior of bpf_map_update_elem 2016-08-06 20:49:19 -04:00
helpers.c bpf: don't use raw processor id in generic helper 2016-06-30 05:54:40 -04:00
inode.c bpf: make inode code explicitly non-modular 2016-07-11 13:52:43 -07:00
percpu_freelist.c bpf: introduce percpu_freelist 2016-03-08 15:28:31 -05:00
percpu_freelist.h bpf: introduce percpu_freelist 2016-03-08 15:28:31 -05:00
stackmap.c Merge branch 'linus' into perf/core, to refresh the branch 2016-06-08 09:26:46 +02:00
syscall.c bpf: add bpf_prog_add api for bulk prog refcnt 2016-07-19 21:46:31 -07:00
verifier.c bpf: fix method of PTR_TO_PACKET reg id generation 2016-08-03 11:53:33 -07:00