diff options
author | Yafang Shao <laoar.shao@gmail.com> | 2023-02-10 15:47:32 +0000 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-02-10 18:59:56 -0800 |
commit | ddef81b5fd1da4d7c3cc8785d2043b73b72f38ef (patch) | |
tree | ddf4f357cb13ca9c4e979624ebb4dc09f8a701fe /kernel/bpf/bpf_local_storage.c | |
parent | b6c1a8af5b1eec42aabc13376f94aa90c3d765f1 (diff) | |
download | linux-ddef81b5fd1da4d7c3cc8785d2043b73b72f38ef.tar.gz linux-ddef81b5fd1da4d7c3cc8785d2043b73b72f38ef.tar.bz2 linux-ddef81b5fd1da4d7c3cc8785d2043b73b72f38ef.zip |
bpf: use bpf_map_kvcalloc in bpf_local_storage
Introduce new helper bpf_map_kvcalloc() for the memory allocation in
bpf_local_storage(). Then the allocation will charge the memory from the
map instead of from current, though currently they are the same thing as
it is only used in map creation path now. By charging map's memory into
the memcg from the map, it will be more clear.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Link: https://lore.kernel.org/r/20230210154734.4416-3-laoar.shao@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/bpf_local_storage.c')
-rw-r--r-- | kernel/bpf/bpf_local_storage.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c index 373c3c2c75bc..35f4138a54dc 100644 --- a/kernel/bpf/bpf_local_storage.c +++ b/kernel/bpf/bpf_local_storage.c @@ -568,8 +568,8 @@ static struct bpf_local_storage_map *__bpf_local_storage_map_alloc(union bpf_att nbuckets = max_t(u32, 2, nbuckets); smap->bucket_log = ilog2(nbuckets); - smap->buckets = kvcalloc(sizeof(*smap->buckets), nbuckets, - GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); + smap->buckets = bpf_map_kvcalloc(&smap->map, sizeof(*smap->buckets), + nbuckets, GFP_USER | __GFP_NOWARN); if (!smap->buckets) { bpf_map_area_free(smap); return ERR_PTR(-ENOMEM); |