History

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().

Mykyta Yatsenko committed 5 months ago

Commit 16b4d3e1 parent 46730ee6 files · +328 −0Browse files

Showing the changes to tools/include/uapi/linux (1 of 6 files). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+6−0
@@ -1047,6 +1047,7 @@ enum bpf_map_type { · 1046 unmodified lines
10471047 BPF_MAP_TYPE_CGRP_STORAGE,
10481048 BPF_MAP_TYPE_ARENA,
10491049 BPF_MAP_TYPE_INSN_ARRAY,
1050+ BPF_MAP_TYPE_RHASH,
10501051 __MAX_BPF_MAP_TYPE
10511052 };
10521053
@@ -1545,6 +1546,11 @@ union bpf_attr { · 492 unmodified lines
15451546 *
15461547 * BPF_MAP_TYPE_ARENA - contains the address where user space
15471548 * is going to mmap() the arena. It has to be page aligned.
1549+ *
1550+ * BPF_MAP_TYPE_RHASH - initial table size hint
1551+ * (nelem_hint). 0 = use rhashtable default. Must be
1552+ * <= min(max_entries, U16_MAX). Upper 32 bits reserved,
1553+ * must be zero.
15481554 */
15491555 __u64 map_extra;
15501556

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t