diff options
author | Roman Gushchin | 2020-12-01 13:58:42 -0800 |
---|---|---|
committer | Alexei Starovoitov | 2020-12-02 18:32:46 -0800 |
commit | 7846dd9f835e248901a9f77a43745f8f1de04741 (patch) | |
tree | 773a44945d1e25b9cae0415d924d644a1516c95b /net/core | |
parent | e9aae8beba825e4670463ddcf420b954f18d5ced (diff) |
bpf: Refine memcg-based memory accounting for sockmap and sockhash maps
Include internal metadata into the memcg-based memory accounting.
Also include the memory allocated on updating an element.
Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201201215900.3569844-17-guro@fb.com
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock_map.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/core/sock_map.c b/net/core/sock_map.c index ddc899e83313..153652a582ee 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -39,7 +39,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) attr->map_flags & ~SOCK_CREATE_FLAG_MASK) return ERR_PTR(-EINVAL); - stab = kzalloc(sizeof(*stab), GFP_USER); + stab = kzalloc(sizeof(*stab), GFP_USER | __GFP_ACCOUNT); if (!stab) return ERR_PTR(-ENOMEM); @@ -975,8 +975,9 @@ static struct bpf_shtab_elem *sock_hash_alloc_elem(struct bpf_shtab *htab, } } - new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, - htab->map.numa_node); + new = bpf_map_kmalloc_node(&htab->map, htab->elem_size, + GFP_ATOMIC | __GFP_NOWARN, + htab->map.numa_node); if (!new) { atomic_dec(&htab->count); return ERR_PTR(-ENOMEM); @@ -1116,7 +1117,7 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) if (attr->key_size > MAX_BPF_STACK) return ERR_PTR(-E2BIG); - htab = kzalloc(sizeof(*htab), GFP_USER); + htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); if (!htab) return ERR_PTR(-ENOMEM); |