bpf: rework memlock-based memory accounting for maps
[linux-2.6-microblaze.git] / kernel / bpf / queue_stack_maps.c
index 0b140d2..224cb0f 100644 (file)
@@ -67,6 +67,7 @@ static int queue_stack_map_alloc_check(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);
+       struct bpf_map_memory mem = {0};
        struct bpf_queue_stack *qs;
        u64 size, queue_size, cost;
 
@@ -77,19 +78,21 @@ static struct bpf_map *queue_stack_map_alloc(union bpf_attr *attr)
 
        cost = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT;
 
-       ret = bpf_map_precharge_memlock(cost);
+       ret = bpf_map_charge_init(&mem, cost);
        if (ret < 0)
                return ERR_PTR(ret);
 
        qs = bpf_map_area_alloc(queue_size, numa_node);
-       if (!qs)
+       if (!qs) {
+               bpf_map_charge_finish(&mem);
                return ERR_PTR(-ENOMEM);
+       }
 
        memset(qs, 0, sizeof(*qs));
 
        bpf_map_init_from_attr(&qs->map, attr);
 
-       qs->map.pages = cost;
+       bpf_map_charge_move(&qs->map.memory, &mem);
        qs->size = size;
 
        raw_spin_lock_init(&qs->lock);