mirror of
https://github.com/netdata/libbpf.git
synced 2026-11-05 17:30:15 +08:00
bpf: Implement resizable hashmap basic functions
Use rhashtable_lookup_likely() for lookups, rhashtable_remove_fast() for deletes, and rhashtable_lookup_get_insert_fast() for inserts. Updates modify values in place under RCU rather than allocating a new element and swapping the pointer (as regular htab does). This trades read consistency for performance: concurrent readers may see partial updates. BPF_F_LOCK support and special-field handling (timers, kptrs, etc.) follow in a later commit. Initialize rhashtable with bpf_mem_alloc element cache. Require BPF_F_NO_PREALLOC. Limit max_entries to 2^31. Free elements via rhashtable_free_and_destroy(). Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Link: https://lore.kernel.org/r/20260605-rhash-v7-4-5b8e05f8630d@meta.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
1 parent
2dca79168a
commit
1369dc002d
1 file changed
+6
@@ -1047,6 +1047,7 @@ enum bpf_map_type {
|
||||
BPF_MAP_TYPE_CGRP_STORAGE,
|
||||
BPF_MAP_TYPE_ARENA,
|
||||
BPF_MAP_TYPE_INSN_ARRAY,
|
||||
BPF_MAP_TYPE_RHASH,
|
||||
__MAX_BPF_MAP_TYPE
|
||||
};
|
||||
|
||||
@@ -1545,6 +1546,11 @@ union bpf_attr {
|
||||
*
|
||||
* BPF_MAP_TYPE_ARENA - contains the address where user space
|
||||
* is going to mmap() the arena. It has to be page aligned.
|
||||
*
|
||||
* BPF_MAP_TYPE_RHASH - initial table size hint
|
||||
* (nelem_hint). 0 = use rhashtable default. Must be
|
||||
* <= min(max_entries, U16_MAX). Upper 32 bits reserved,
|
||||
* must be zero.
|
||||
*/
|
||||
__u64 map_extra;
|
||||
|
||||
|
||||
Reference in new issue
Block a user