bpf: group memory related fields in struct bpf_map_memory
Group "user" and "pages" fields of bpf_map into the bpf_map_memory structure. Later it can be extended with "memcg" and other related information. The main reason for a such change (beside cosmetics) is to pass bpf_map_memory structure to charging functions before the actual allocation of bpf_map. Signed-off-by: Roman Gushchin <guro@fb.com> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committed by
Alexei Starovoitov

parent
d50836cda6
commit
3539b96e04
@@ -111,10 +111,10 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
|
||||
if (cost >= U32_MAX - PAGE_SIZE)
|
||||
goto free_dtab;
|
||||
|
||||
dtab->map.pages = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT;
|
||||
dtab->map.memory.pages = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT;
|
||||
|
||||
/* if map size is larger than memlock limit, reject it early */
|
||||
err = bpf_map_precharge_memlock(dtab->map.pages);
|
||||
err = bpf_map_precharge_memlock(dtab->map.memory.pages);
|
||||
if (err)
|
||||
goto free_dtab;
|
||||
|
||||
|
Reference in New Issue
Block a user