Do not use rlimit-based memory accounting for stackmap maps. It has been replaced with the memcg-based memory accounting.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -90,7 +90,6 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr) · 89 unmodified lines | ||
| 90 | 90 | { |
| 91 | 91 | u32 value_size = attr->value_size; |
| 92 | 92 | struct bpf_stack_map *smap; |
| 93 | − struct bpf_map_memory mem; | |
| 94 | 93 | u64 cost, n_buckets; |
| 95 | 94 | int err; |
| 96 | 95 | |
| @@ -119,15 +118,9 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr) · 22 unmodified lines | ||
| 119 | 118 | |
| 120 | 119 | cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap); |
| 121 | 120 | 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 | − | |
| 126 | 121 | smap = bpf_map_area_alloc(cost, bpf_map_attr_numa_node(attr)); |
| 127 | − if (!smap) { | |
| 128 | − bpf_map_charge_finish(&mem); | |
| 122 | + if (!smap) | |
| 129 | 123 | return ERR_PTR(-ENOMEM); |
| 130 | − } | |
| 131 | 124 | |
| 132 | 125 | bpf_map_init_from_attr(&smap->map, attr); |
| 133 | 126 | smap->map.value_size = value_size; |
| @@ -135,20 +128,17 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr) · 1 unmodified line | ||
| 135 | 128 | |
| 136 | 129 | err = get_callchain_buffers(sysctl_perf_event_max_stack); |
| 137 | 130 | if (err) |
| 138 | − goto free_charge; | |
| 131 | + goto free_smap; | |
| 139 | 132 | |
| 140 | 133 | err = prealloc_elems_and_freelist(smap); |
| 141 | 134 | if (err) |
| 142 | 135 | goto put_buffers; |
| 143 | 136 | |
| 144 | − bpf_map_charge_move(&smap->map.memory, &mem); | |
| 145 | − | |
| 146 | 137 | return &smap->map; |
| 147 | 138 | |
| 148 | 139 | put_buffers: |
| 149 | 140 | put_callchain_buffers(); |
| 150 | −free_charge: | |
| 151 | − bpf_map_charge_finish(&mem); | |
| 141 | +free_smap: | |
| 152 | 142 | bpf_map_area_free(smap); |
| 153 | 143 | return ERR_PTR(err); |
| 154 | 144 | } |