Skip to content

Commit

Permalink
bpf: Eliminate rlimit-based memory accounting for cpumap maps
Browse files Browse the repository at this point in the history
Do not use rlimit-based memory accounting for cpumap maps.
It has been replaced with the memcg-based memory accounting.

Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20201201215900.3569844-21-guro@fb.com
  • Loading branch information
rgushchin authored and Alexei Starovoitov committed Dec 3, 2020
1 parent f043733 commit 711caba
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions kernel/bpf/cpumap.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
u32 value_size = attr->value_size;
struct bpf_cpu_map *cmap;
int err = -ENOMEM;
u64 cost;
int ret;

if (!bpf_capable())
return ERR_PTR(-EPERM);
Expand All @@ -109,26 +107,14 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
goto free_cmap;
}

/* make sure page count doesn't overflow */
cost = (u64) cmap->map.max_entries * sizeof(struct bpf_cpu_map_entry *);

/* Notice returns -EPERM on if map size is larger than memlock limit */
ret = bpf_map_charge_init(&cmap->map.memory, cost);
if (ret) {
err = ret;
goto free_cmap;
}

/* Alloc array for possible remote "destination" CPUs */
cmap->cpu_map = bpf_map_area_alloc(cmap->map.max_entries *
sizeof(struct bpf_cpu_map_entry *),
cmap->map.numa_node);
if (!cmap->cpu_map)
goto free_charge;
goto free_cmap;

return &cmap->map;
free_charge:
bpf_map_charge_finish(&cmap->map.memory);
free_cmap:
kfree(cmap);
return ERR_PTR(err);
Expand Down

0 comments on commit 711caba

Please sign in to comment.