Do not use rlimit-based memory accounting for cpumap maps. It has been replaced with the memcg-based memory accounting.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -84,8 +84,6 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr) · 83 unmodified lines | |||
| 84 | u32 value_size = attr->value_size; | 84 | u32 value_size = attr->value_size; |
| 85 | struct bpf_cpu_map *cmap; | 85 | struct bpf_cpu_map *cmap; |
| 86 | int err = -ENOMEM; | 86 | int err = -ENOMEM; |
| 87 | u64 cost; | ||
| 88 | int ret; | ||
| 89 | 87 | ||
| 90 | if (!bpf_capable()) | 88 | if (!bpf_capable()) |
| 91 | return ERR_PTR(-EPERM); | 89 | return ERR_PTR(-EPERM); |
| @@ -109,26 +107,14 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr) · 17 unmodified lines | |||
| 109 | goto free_cmap; | 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 | /* Alloc array for possible remote "destination" CPUs */ | 110 | /* Alloc array for possible remote "destination" CPUs */ |
| 123 | cmap->cpu_map = bpf_map_area_alloc(cmap->map.max_entries * | 111 | cmap->cpu_map = bpf_map_area_alloc(cmap->map.max_entries * |
| 124 | sizeof(struct bpf_cpu_map_entry *), | 112 | sizeof(struct bpf_cpu_map_entry *), |
| 125 | cmap->map.numa_node); | 113 | cmap->map.numa_node); |
| 126 | if (!cmap->cpu_map) | 114 | if (!cmap->cpu_map) |
| 127 | goto free_charge; | 115 | goto free_cmap; |
| 128 | 116 | ||
| 129 | return &cmap->map; | 117 | return &cmap->map; |
| 130 | free_charge: | ||
| 131 | bpf_map_charge_finish(&cmap->map.memory); | ||
| 132 | free_cmap: | 118 | free_cmap: |
| 133 | kfree(cmap); | 119 | kfree(cmap); |
| 134 | return ERR_PTR(err); | 120 | return ERR_PTR(err); |