Do not use rlimit-based memory accounting for stackmap maps.
It has been replaced with the memcg-based memory accounting.
Signed-off-by: Roman Gushchin <[email protected]>
---
kernel/bpf/stackmap.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 5beb2f8c23da..9ac0f405beef 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -90,7 +90,6 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
{
u32 value_size = attr->value_size;
struct bpf_stack_map *smap;
- struct bpf_map_memory mem;
u64 cost, n_buckets;
int err;
@@ -119,15 +118,9 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
- err = bpf_map_charge_init(&mem, cost);
- if (err)
- return ERR_PTR(err);
-
smap = bpf_map_area_alloc(cost, bpf_map_attr_numa_node(attr));
- if (!smap) {
- bpf_map_charge_finish(&mem);
+ if (!smap)
return ERR_PTR(-ENOMEM);
- }
bpf_map_init_from_attr(&smap->map, attr);
smap->map.value_size = value_size;
@@ -135,20 +128,17 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
err = get_callchain_buffers(sysctl_perf_event_max_stack);
if (err)
- goto free_charge;
+ goto free_smap;
err = prealloc_elems_and_freelist(smap);
if (err)
goto put_buffers;
- bpf_map_charge_move(&smap->map.memory, &mem);
-
return &smap->map;
put_buffers:
put_callchain_buffers();
-free_charge:
- bpf_map_charge_finish(&mem);
+free_smap:
bpf_map_area_free(smap);
return ERR_PTR(err);
}
--
2.26.2
On Mon, Jul 27, 2020 at 12:22 PM Roman Gushchin <[email protected]> wrote:
>
> Do not use rlimit-based memory accounting for stackmap maps.
> It has been replaced with the memcg-based memory accounting.
>
> Signed-off-by: Roman Gushchin <[email protected]>
Acked-by: Song Liu <[email protected]>
> ---
> kernel/bpf/stackmap.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> index 5beb2f8c23da..9ac0f405beef 100644
> --- a/kernel/bpf/stackmap.c
> +++ b/kernel/bpf/stackmap.c
> @@ -90,7 +90,6 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
> {
> u32 value_size = attr->value_size;
> struct bpf_stack_map *smap;
> - struct bpf_map_memory mem;
> u64 cost, n_buckets;
> int err;
>
> @@ -119,15 +118,9 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
>
> cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
> cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
> - err = bpf_map_charge_init(&mem, cost);
> - if (err)
> - return ERR_PTR(err);
> -
> smap = bpf_map_area_alloc(cost, bpf_map_attr_numa_node(attr));
> - if (!smap) {
> - bpf_map_charge_finish(&mem);
> + if (!smap)
> return ERR_PTR(-ENOMEM);
> - }
>
> bpf_map_init_from_attr(&smap->map, attr);
> smap->map.value_size = value_size;
> @@ -135,20 +128,17 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
>
> err = get_callchain_buffers(sysctl_perf_event_max_stack);
> if (err)
> - goto free_charge;
> + goto free_smap;
>
> err = prealloc_elems_and_freelist(smap);
> if (err)
> goto put_buffers;
>
> - bpf_map_charge_move(&smap->map.memory, &mem);
> -
> return &smap->map;
>
> put_buffers:
> put_callchain_buffers();
> -free_charge:
> - bpf_map_charge_finish(&mem);
> +free_smap:
> bpf_map_area_free(smap);
> return ERR_PTR(err);
> }
> --
> 2.26.2
>