On Fri, Jan 8, 2016 at 6:35 AM, Martin KaFai Lau [off-list ref] wrote:
This patch adds BPFMAP_TYPE_PERCPU_HASH map type and its
htab_map_ops implementation.
Signed-off-by: Martin KaFai Lau <redacted>
---
include/uapi/linux/bpf.h | 1 +
kernel/bpf/hashtab.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 201 insertions(+), 1 deletion(-)
...
+
+/* Called from syscall or eBPF program */
+static void *htab_percpu_map_lookup_elem(struct bpf_map *map, void *key)
+{
+ struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
+ struct htab_elem_common *l;
+
+ l = __htab_map_lookup_elem(htab, key);
+ if (l) {
+ void *value = per_cpu_ptr(htab_percpu_elem(l)->value,
+ smp_processor_id());
Then it isn't possible to retrieve the value of one key from all CPUs in eBPF
prog, and that is definitely not flexible because update/delete element can
be run from eBPF prog.
And that is not a thing if using real_key and cpu_id, isn't it?
Thanks,