bpf: Eliminate rlimit-based memory accounting for bpf_struct_ops maps
authorRoman Gushchin <guro@fb.com>
Tue, 1 Dec 2020 21:58:45 +0000 (13:58 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 3 Dec 2020 02:32:46 +0000 (18:32 -0800)
Do not use rlimit-based memory accounting for bpf_struct_ops 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-20-guro@fb.com
kernel/bpf/bpf_struct_ops.c

index 4c3b543..1a666a9 100644 (file)
@@ -548,12 +548,10 @@ static int bpf_struct_ops_map_alloc_check(union bpf_attr *attr)
 static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
 {
        const struct bpf_struct_ops *st_ops;
-       size_t map_total_size, st_map_size;
+       size_t st_map_size;
        struct bpf_struct_ops_map *st_map;
        const struct btf_type *t, *vt;
-       struct bpf_map_memory mem;
        struct bpf_map *map;
-       int err;
 
        if (!bpf_capable())
                return ERR_PTR(-EPERM);
@@ -573,20 +571,11 @@ static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
                 * struct bpf_struct_ops_tcp_congestions_ops
                 */
                (vt->size - sizeof(struct bpf_struct_ops_value));
-       map_total_size = st_map_size +
-               /* uvalue */
-               sizeof(vt->size) +
-               /* struct bpf_progs **progs */
-                btf_type_vlen(t) * sizeof(struct bpf_prog *);
-       err = bpf_map_charge_init(&mem, map_total_size);
-       if (err < 0)
-               return ERR_PTR(err);
 
        st_map = bpf_map_area_alloc(st_map_size, NUMA_NO_NODE);
-       if (!st_map) {
-               bpf_map_charge_finish(&mem);
+       if (!st_map)
                return ERR_PTR(-ENOMEM);
-       }
+
        st_map->st_ops = st_ops;
        map = &st_map->map;
 
@@ -597,14 +586,12 @@ static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
        st_map->image = bpf_jit_alloc_exec(PAGE_SIZE);
        if (!st_map->uvalue || !st_map->progs || !st_map->image) {
                bpf_struct_ops_map_free(map);
-               bpf_map_charge_finish(&mem);
                return ERR_PTR(-ENOMEM);
        }
 
        mutex_init(&st_map->lock);
        set_vm_flush_reset_perms(st_map->image);
        bpf_map_init_from_attr(map, attr);
-       bpf_map_charge_move(&map->memory, &mem);
 
        return map;
 }