Thread (17 messages) flat view 17 messages, 3 authors, 2016-01-12

Re: [PATCH net-next 2/4] bpf: bpf_htab: Add BPF_MAP_TYPE_PERCPU_HASH

From: Ming Lei <tom.leiming@gmail.com>
Date: 2016-01-09 10:33:04
Also in: lkml

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,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help