diff mbox series

[bpf-next,v2,21/35] bpf: eliminate rlimit-based memory accounting for reuseport_array maps

Message ID 20200727184506.2279656-22-guro@fb.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series bpf: switch to memcg-based memory accounting | expand

Commit Message

Roman Gushchin July 27, 2020, 6:44 p.m. UTC
Do not use rlimit-based memory accounting for reuseport_array maps.
It has been replaced with the memcg-based memory accounting.

Signed-off-by: Roman Gushchin <guro@fb.com>
---
 kernel/bpf/reuseport_array.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

Song Liu July 28, 2020, 5:36 a.m. UTC | #1
On Mon, Jul 27, 2020 at 12:23 PM Roman Gushchin <guro@fb.com> wrote:
>
> Do not use rlimit-based memory accounting for reuseport_array maps.
> It has been replaced with the memcg-based memory accounting.
>
> Signed-off-by: Roman Gushchin <guro@fb.com>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  kernel/bpf/reuseport_array.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/bpf/reuseport_array.c b/kernel/bpf/reuseport_array.c
> index 90b29c5b1da7..9d0161fdfec7 100644
> --- a/kernel/bpf/reuseport_array.c
> +++ b/kernel/bpf/reuseport_array.c
> @@ -150,9 +150,8 @@ static void reuseport_array_free(struct bpf_map *map)
>
>  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 bpf_map_memory mem;
>         u64 array_size;
>
>         if (!bpf_capable())
> @@ -161,20 +160,13 @@ static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr)
>         array_size = sizeof(*array);
>         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 */
>         array = bpf_map_area_alloc(array_size, numa_node);
> -       if (!array) {
> -               bpf_map_charge_finish(&mem);
> +       if (!array)
>                 return ERR_PTR(-ENOMEM);
> -       }
>
>         /* copy mandatory map attributes */
>         bpf_map_init_from_attr(&array->map, attr);
> -       bpf_map_charge_move(&array->map.memory, &mem);
>
>         return &array->map;
>  }
> --
> 2.26.2
>
diff mbox series

Patch

diff --git a/kernel/bpf/reuseport_array.c b/kernel/bpf/reuseport_array.c
index 90b29c5b1da7..9d0161fdfec7 100644
--- a/kernel/bpf/reuseport_array.c
+++ b/kernel/bpf/reuseport_array.c
@@ -150,9 +150,8 @@  static void reuseport_array_free(struct bpf_map *map)
 
 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 bpf_map_memory mem;
 	u64 array_size;
 
 	if (!bpf_capable())
@@ -161,20 +160,13 @@  static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr)
 	array_size = sizeof(*array);
 	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 */
 	array = bpf_map_area_alloc(array_size, numa_node);
-	if (!array) {
-		bpf_map_charge_finish(&mem);
+	if (!array)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	/* copy mandatory map attributes */
 	bpf_map_init_from_attr(&array->map, attr);
-	bpf_map_charge_move(&array->map.memory, &mem);
 
 	return &array->map;
 }