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
1047 BPF_MAP_TYPE_CGRP_STORAGE,1047 BPF_MAP_TYPE_CGRP_STORAGE,
1048 BPF_MAP_TYPE_ARENA,1048 BPF_MAP_TYPE_ARENA,
1049 BPF_MAP_TYPE_INSN_ARRAY,1049 BPF_MAP_TYPE_INSN_ARRAY,
1050 BPF_MAP_TYPE_RHASH,
1050 __MAX_BPF_MAP_TYPE1051 __MAX_BPF_MAP_TYPE
1051};1052};
1052 1053
@@ -1545,6 +1546,11 @@ union bpf_attr { · 492 unmodified lines
1545 *1546 *
1546 * BPF_MAP_TYPE_ARENA - contains the address where user space1547 * BPF_MAP_TYPE_ARENA - contains the address where user space
1547 * is going to mmap() the arena. It has to be page aligned.1548 * 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.
1548 */1554 */
1549 __u64 map_extra;1555 __u64 map_extra;
1550 1556

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