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