bpf: Refine memcg-based memory accounting for arraymap maps
authorRoman Gushchin <guro@fb.com>
Tue, 1 Dec 2020 21:58:34 +0000 (13:58 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 3 Dec 2020 02:32:45 +0000 (18:32 -0800)
Include percpu arrays and auxiliary data into the memcg-based memory
accounting.

Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201201215900.3569844-9-guro@fb.com
kernel/bpf/arraymap.c

index c6c81ec..d837e06 100644 (file)
@@ -34,8 +34,8 @@ static int bpf_array_alloc_percpu(struct bpf_array *array)
        int i;
 
        for (i = 0; i < array->map.max_entries; i++) {
-               ptr = __alloc_percpu_gfp(array->elem_size, 8,
-                                        GFP_USER | __GFP_NOWARN);
+               ptr = bpf_map_alloc_percpu(&array->map, array->elem_size, 8,
+                                          GFP_USER | __GFP_NOWARN);
                if (!ptr) {
                        bpf_array_free_percpu(array);
                        return -ENOMEM;
@@ -1018,7 +1018,7 @@ static struct bpf_map *prog_array_map_alloc(union bpf_attr *attr)
        struct bpf_array_aux *aux;
        struct bpf_map *map;
 
-       aux = kzalloc(sizeof(*aux), GFP_KERNEL);
+       aux = kzalloc(sizeof(*aux), GFP_KERNEL_ACCOUNT);
        if (!aux)
                return ERR_PTR(-ENOMEM);