Merge tag 'arm-soc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / kernel / bpf / lpm_trie.c
index 00e32f2..cec792a 100644 (file)
@@ -282,8 +282,8 @@ static struct lpm_trie_node *lpm_trie_node_alloc(const struct lpm_trie *trie,
        if (value)
                size += trie->map.value_size;
 
-       node = kmalloc_node(size, GFP_ATOMIC | __GFP_NOWARN,
-                           trie->map.numa_node);
+       node = bpf_map_kmalloc_node(&trie->map, size, GFP_ATOMIC | __GFP_NOWARN,
+                                   trie->map.numa_node);
        if (!node)
                return NULL;
 
@@ -540,8 +540,6 @@ out:
 static struct bpf_map *trie_alloc(union bpf_attr *attr)
 {
        struct lpm_trie *trie;
-       u64 cost = sizeof(*trie), cost_per_node;
-       int ret;
 
        if (!bpf_capable())
                return ERR_PTR(-EPERM);
@@ -557,7 +555,7 @@ static struct bpf_map *trie_alloc(union bpf_attr *attr)
            attr->value_size > LPM_VAL_SIZE_MAX)
                return ERR_PTR(-EINVAL);
 
-       trie = kzalloc(sizeof(*trie), GFP_USER | __GFP_NOWARN);
+       trie = kzalloc(sizeof(*trie), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT);
        if (!trie)
                return ERR_PTR(-ENOMEM);
 
@@ -567,20 +565,9 @@ static struct bpf_map *trie_alloc(union bpf_attr *attr)
                          offsetof(struct bpf_lpm_trie_key, data);
        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);
 
        return &trie->map;
-out_err:
-       kfree(trie);
-       return ERR_PTR(ret);
 }
 
 static void trie_free(struct bpf_map *map)