mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
bpf: Eliminate rlimit-based memory accounting for queue_stack_maps maps
Do not use rlimit-based memory accounting for queue_stack 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-26-guro@fb.com
This commit is contained in:
committed by
Alexei Starovoitov
parent
cbddcb574d
commit
a37fb7ef24
@@ -66,29 +66,21 @@ static int queue_stack_map_alloc_check(union bpf_attr *attr)
|
|||||||
|
|
||||||
static struct bpf_map *queue_stack_map_alloc(union bpf_attr *attr)
|
static struct bpf_map *queue_stack_map_alloc(union bpf_attr *attr)
|
||||||
{
|
{
|
||||||
int ret, numa_node = bpf_map_attr_numa_node(attr);
|
int numa_node = bpf_map_attr_numa_node(attr);
|
||||||
struct bpf_map_memory mem = {0};
|
|
||||||
struct bpf_queue_stack *qs;
|
struct bpf_queue_stack *qs;
|
||||||
u64 size, queue_size, cost;
|
u64 size, queue_size;
|
||||||
|
|
||||||
size = (u64) attr->max_entries + 1;
|
size = (u64) attr->max_entries + 1;
|
||||||
cost = queue_size = sizeof(*qs) + size * attr->value_size;
|
queue_size = sizeof(*qs) + size * attr->value_size;
|
||||||
|
|
||||||
ret = bpf_map_charge_init(&mem, cost);
|
|
||||||
if (ret < 0)
|
|
||||||
return ERR_PTR(ret);
|
|
||||||
|
|
||||||
qs = bpf_map_area_alloc(queue_size, numa_node);
|
qs = bpf_map_area_alloc(queue_size, numa_node);
|
||||||
if (!qs) {
|
if (!qs)
|
||||||
bpf_map_charge_finish(&mem);
|
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
|
||||||
|
|
||||||
memset(qs, 0, sizeof(*qs));
|
memset(qs, 0, sizeof(*qs));
|
||||||
|
|
||||||
bpf_map_init_from_attr(&qs->map, attr);
|
bpf_map_init_from_attr(&qs->map, attr);
|
||||||
|
|
||||||
bpf_map_charge_move(&qs->map.memory, &mem);
|
|
||||||
qs->size = size;
|
qs->size = size;
|
||||||
|
|
||||||
raw_spin_lock_init(&qs->lock);
|
raw_spin_lock_init(&qs->lock);
|
||||||
|
Reference in New Issue
Block a user