Do not use rlimit-based memory accounting for cpumap maps. It has been replaced with the memcg-based memory accounting.
Unified · Split
| @@ -84,8 +84,6 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr) · 83 unmodified lines | ||
| 84 | 84 | u32 value_size = attr->value_size; |
| 85 | 85 | struct bpf_cpu_map *cmap; |
| 86 | 86 | int err = -ENOMEM; |
| 87 | − u64 cost; | |
| 88 | − int ret; | |
| 89 | 87 | |
| 90 | 88 | if (!bpf_capable()) |
| 91 | 89 | return ERR_PTR(-EPERM); |
| @@ -109,26 +107,14 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr) · 17 unmodified lines | ||
| 109 | 107 | goto free_cmap; |
| 110 | 108 | } |
| 111 | 109 | |
| 112 | − /* make sure page count doesn't overflow */ | |
| 113 | − cost = (u64) cmap->map.max_entries * sizeof(struct bpf_cpu_map_entry *); | |
| 114 | − | |
| 115 | − /* Notice returns -EPERM on if map size is larger than memlock limit */ | |
| 116 | − ret = bpf_map_charge_init(&cmap->map.memory, cost); | |
| 117 | − if (ret) { | |
| 118 | − err = ret; | |
| 119 | − goto free_cmap; | |
| 120 | − } | |
| 121 | − | |
| 122 | 110 | /* Alloc array for possible remote "destination" CPUs */ |
| 123 | 111 | cmap->cpu_map = bpf_map_area_alloc(cmap->map.max_entries * |
| 124 | 112 | sizeof(struct bpf_cpu_map_entry *), |
| 125 | 113 | cmap->map.numa_node); |
| 126 | 114 | if (!cmap->cpu_map) |
| 127 | − goto free_charge; | |
| 115 | + goto free_cmap; | |
| 128 | 116 | |
| 129 | 117 | return &cmap->map; |
| 130 | −free_charge: | |
| 131 | − bpf_map_charge_finish(&cmap->map.memory); | |
| 132 | 118 | free_cmap: |
| 133 | 119 | kfree(cmap); |
| 134 | 120 | return ERR_PTR(err); |