Commit cbddcb57 authored by Roman Gushchin's avatar Roman Gushchin Committed by Alexei Starovoitov

bpf: Eliminate rlimit-based memory accounting for lpm_trie maps

Do not use rlimit-based memory accounting for lpm_trie maps.
It has been replaced with the memcg-based memory accounting.
Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20201201215900.3569844-25-guro@fb.com
parent 755e5d55
...@@ -540,8 +540,6 @@ static int trie_delete_elem(struct bpf_map *map, void *_key) ...@@ -540,8 +540,6 @@ static int trie_delete_elem(struct bpf_map *map, void *_key)
static struct bpf_map *trie_alloc(union bpf_attr *attr) static struct bpf_map *trie_alloc(union bpf_attr *attr)
{ {
struct lpm_trie *trie; struct lpm_trie *trie;
u64 cost = sizeof(*trie), cost_per_node;
int ret;
if (!bpf_capable()) if (!bpf_capable())
return ERR_PTR(-EPERM); return ERR_PTR(-EPERM);
...@@ -567,20 +565,9 @@ static struct bpf_map *trie_alloc(union bpf_attr *attr) ...@@ -567,20 +565,9 @@ static struct bpf_map *trie_alloc(union bpf_attr *attr)
offsetof(struct bpf_lpm_trie_key, data); offsetof(struct bpf_lpm_trie_key, data);
trie->max_prefixlen = trie->data_size * 8; trie->max_prefixlen = trie->data_size * 8;
cost_per_node = sizeof(struct lpm_trie_node) +
attr->value_size + trie->data_size;
cost += (u64) attr->max_entries * cost_per_node;
ret = bpf_map_charge_init(&trie->map.memory, cost);
if (ret)
goto out_err;
spin_lock_init(&trie->lock); spin_lock_init(&trie->lock);
return &trie->map; return &trie->map;
out_err:
kfree(trie);
return ERR_PTR(ret);
} }
static void trie_free(struct bpf_map *map) static void trie_free(struct bpf_map *map)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment