Re: [PATCH RFC bpf-next v2 01/18] bpf: Register rhash map

Mykyta Yatsenko
2026-04-13T08:10:36Z

On 4/10/26 11:31 PM, Emil Tsalapatis wrote:
> On Wed Apr 8, 2026 at 11:10 AM EDT, Mykyta Yatsenko wrote:
>> From: Mykyta Yatsenko <yatsenko@meta.com>
>>
>> Add resizable hash map into enums where it is needed.
>>
>
> These changes in isolation are difficult to reason about,
> can we roll this into subsequent patches? Right now this
> adds a the BPF_MAP_TYPE_RHASH without there being a way
> to create one.
>

Thanks for taking a look, makes sense, I can squash it into the latter
commits.

>> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
>> ---
>> include/uapi/linux/bpf.h | 1 +
>> kernel/bpf/map_iter.c | 3 ++-
>> kernel/bpf/syscall.c | 3 +++
>> kernel/bpf/verifier.c | 1 +
>> tools/include/uapi/linux/bpf.h | 1 +
>> 5 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>> index 552bc5d9afbd..822582c04f22 100644
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -1046,6 +1046,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
>> };
>>
>> diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c
>> index 261a03ea73d3..4a2aafbe28b4 100644
>> --- a/kernel/bpf/map_iter.c
>> +++ b/kernel/bpf/map_iter.c
>> @@ -119,7 +119,8 @@ static int bpf_iter_attach_map(struct bpf_prog *prog,
>> is_percpu = true;
>> else if (map->map_type != BPF_MAP_TYPE_HASH &&
>> map->map_type != BPF_MAP_TYPE_LRU_HASH &&
>> - map->map_type != BPF_MAP_TYPE_ARRAY)
>> + map->map_type != BPF_MAP_TYPE_ARRAY &&
>> + map->map_type != BPF_MAP_TYPE_RHASH)
>> goto put_map;
>>
>> key_acc_size = prog->aux->max_rdonly_access;
>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>> index 51ade3cde8bb..0a5ec417638d 100644
>> --- a/kernel/bpf/syscall.c
>> +++ b/kernel/bpf/syscall.c
>> @@ -1287,6 +1287,7 @@ static int map_check_btf(struct bpf_map *map, struct bpf_token *token,
>> case BPF_SPIN_LOCK:
>> case BPF_RES_SPIN_LOCK:
>> if (map->map_type != BPF_MAP_TYPE_HASH &&
>> + map->map_type != BPF_MAP_TYPE_RHASH &&
>> map->map_type != BPF_MAP_TYPE_ARRAY &&
>> map->map_type != BPF_MAP_TYPE_CGROUP_STORAGE &&
>> map->map_type != BPF_MAP_TYPE_SK_STORAGE &&
>> @@ -1464,6 +1465,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
>> case BPF_MAP_TYPE_CGROUP_ARRAY:
>> case BPF_MAP_TYPE_ARRAY_OF_MAPS:
>> case BPF_MAP_TYPE_HASH:
>> + case BPF_MAP_TYPE_RHASH:
>> case BPF_MAP_TYPE_PERCPU_HASH:
>> case BPF_MAP_TYPE_HASH_OF_MAPS:
>> case BPF_MAP_TYPE_RINGBUF:
>> @@ -2199,6 +2201,7 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr)
>> map->map_type == BPF_MAP_TYPE_PERCPU_HASH ||
>> map->map_type == BPF_MAP_TYPE_LRU_HASH ||
>> map->map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH ||
>> + map->map_type == BPF_MAP_TYPE_RHASH ||
>> map->map_type == BPF_MAP_TYPE_STACK_TRACE) {
>> if (!bpf_map_is_offloaded(map)) {
>> bpf_disable_instrumentation();
>> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>> index 8c1cf2eb6cbb..53523ab953c2 100644
>> --- a/kernel/bpf/verifier.c
>> +++ b/kernel/bpf/verifier.c
>> @@ -21816,6 +21816,7 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env,
>> if (prog->sleepable)
>> switch (map->map_type) {
>> case BPF_MAP_TYPE_HASH:
>> + case BPF_MAP_TYPE_RHASH:
>> case BPF_MAP_TYPE_LRU_HASH:
>> case BPF_MAP_TYPE_ARRAY:
>> case BPF_MAP_TYPE_PERCPU_HASH:
>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>> index 677be9a47347..9d7df174770a 100644
>> --- a/tools/include/uapi/linux/bpf.h
>> +++ b/tools/include/uapi/linux/bpf.h
>> @@ -1046,6 +1046,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
>> };
>>
>