Do not use rlimit-based memory accounting for lpm_trie maps. It has been replaced with the memcg-based memory accounting.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -540,8 +540,6 @@ out: · 539 unmodified lines | |||
| 540 | static struct bpf_map *trie_alloc(union bpf_attr *attr) | 540 | static struct bpf_map *trie_alloc(union bpf_attr *attr) |
| 541 | { | 541 | { |
| 542 | struct lpm_trie *trie; | 542 | struct lpm_trie *trie; |
| 543 | u64 cost = sizeof(*trie), cost_per_node; | ||
| 544 | int ret; | ||
| 545 | 543 | ||
| 546 | if (!bpf_capable()) | 544 | if (!bpf_capable()) |
| 547 | return ERR_PTR(-EPERM); | 545 | return ERR_PTR(-EPERM); |
| @@ -567,20 +565,9 @@ static struct bpf_map *trie_alloc(union bpf_attr *attr) · 19 unmodified lines | |||
| 567 | offsetof(struct bpf_lpm_trie_key, data); | 565 | offsetof(struct bpf_lpm_trie_key, data); |
| 568 | trie->max_prefixlen = trie->data_size * 8; | 566 | trie->max_prefixlen = trie->data_size * 8; |
| 569 | 567 | ||
| 570 | cost_per_node = sizeof(struct lpm_trie_node) + | ||
| 571 | attr->value_size + trie->data_size; | ||
| 572 | cost += (u64) attr->max_entries * cost_per_node; | ||
| 573 | |||
| 574 | ret = bpf_map_charge_init(&trie->map.memory, cost); | ||
| 575 | if (ret) | ||
| 576 | goto out_err; | ||
| 577 | |||
| 578 | spin_lock_init(&trie->lock); | 568 | spin_lock_init(&trie->lock); |
| 579 | 569 | ||
| 580 | return &trie->map; | 570 | return &trie->map; |
| 581 | out_err: | ||
| 582 | kfree(trie); | ||
| 583 | return ERR_PTR(ret); | ||
| 584 | } | 571 | } |
| 585 | 572 | ||
| 586 | static void trie_free(struct bpf_map *map) | 573 | static void trie_free(struct bpf_map *map) |