Commit db54330d authored by Roman Gushchin's avatar Roman Gushchin Committed by Alexei Starovoitov

bpf: Eliminate rlimit-based memory accounting for reuseport_array maps

Do not use rlimit-based memory accounting for reuseport_array maps.
It has been replaced with the memcg-based memory accounting.
Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20201201215900.3569844-27-guro@fb.com
parent a37fb7ef
...@@ -150,9 +150,8 @@ static void reuseport_array_free(struct bpf_map *map) ...@@ -150,9 +150,8 @@ static void reuseport_array_free(struct bpf_map *map)
static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr) static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr)
{ {
int err, numa_node = bpf_map_attr_numa_node(attr); int numa_node = bpf_map_attr_numa_node(attr);
struct reuseport_array *array; struct reuseport_array *array;
struct bpf_map_memory mem;
u64 array_size; u64 array_size;
if (!bpf_capable()) if (!bpf_capable())
...@@ -161,20 +160,13 @@ static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr) ...@@ -161,20 +160,13 @@ static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr)
array_size = sizeof(*array); array_size = sizeof(*array);
array_size += (u64)attr->max_entries * sizeof(struct sock *); array_size += (u64)attr->max_entries * sizeof(struct sock *);
err = bpf_map_charge_init(&mem, array_size);
if (err)
return ERR_PTR(err);
/* allocate all map elements and zero-initialize them */ /* allocate all map elements and zero-initialize them */
array = bpf_map_area_alloc(array_size, numa_node); array = bpf_map_area_alloc(array_size, numa_node);
if (!array) { if (!array)
bpf_map_charge_finish(&mem);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
}
/* copy mandatory map attributes */ /* copy mandatory map attributes */
bpf_map_init_from_attr(&array->map, attr); bpf_map_init_from_attr(&array->map, attr);
bpf_map_charge_move(&array->map.memory, &mem);
return &array->map; return &array->map;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment