Skip to content

Commit 3708681

Browse files
Roman GushchinAlexei Starovoitov
authored andcommitted
bpf: Eliminate rlimit-based memory accounting for stackmap maps
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 <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-30-guro@fb.com
1 parent 0d2c4f9 commit 3708681

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

‎kernel/bpf/stackmap.c‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
9090
{
9191
u32 value_size = attr->value_size;
9292
struct bpf_stack_map *smap;
93-
struct bpf_map_memory mem;
9493
u64 cost, n_buckets;
9594
int err;
9695

@@ -119,36 +118,27 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
119118

120119
cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
121120
cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
122-
err = bpf_map_charge_init(&mem, cost);
123-
if (err)
124-
return ERR_PTR(err);
125-
126121
smap = bpf_map_area_alloc(cost, bpf_map_attr_numa_node(attr));
127-
if (!smap) {
128-
bpf_map_charge_finish(&mem);
122+
if (!smap)
129123
return ERR_PTR(-ENOMEM);
130-
}
131124

132125
bpf_map_init_from_attr(&smap->map, attr);
133126
smap->map.value_size = value_size;
134127
smap->n_buckets = n_buckets;
135128

136129
err = get_callchain_buffers(sysctl_perf_event_max_stack);
137130
if (err)
138-
goto free_charge;
131+
goto free_smap;
139132

140133
err = prealloc_elems_and_freelist(smap);
141134
if (err)
142135
goto put_buffers;
143136

144-
bpf_map_charge_move(&smap->map.memory, &mem);
145-
146137
return &smap->map;
147138

148139
put_buffers:
149140
put_callchain_buffers();
150-
free_charge:
151-
bpf_map_charge_finish(&mem);
141+
free_smap:
152142
bpf_map_area_free(smap);
153143
return ERR_PTR(err);
154144
}

0 commit comments

Comments
 (0)