2020-07-27 19:22:43

by Roman Gushchin

[permalink] [raw]
Subject: [PATCH bpf-next v2 25/35] bpf: eliminate rlimit-based memory accounting for socket storage maps

Do not use rlimit-based memory accounting for socket storage maps.
It has been replaced with the memcg-based memory accounting.

Signed-off-by: Roman Gushchin <[email protected]>
---
net/core/bpf_sk_storage.c | 11 -----------
1 file changed, 11 deletions(-)

diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index fbcd03cd00d3..c0a35b6368af 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -676,8 +676,6 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr)
struct bpf_sk_storage_map *smap;
unsigned int i;
u32 nbuckets;
- u64 cost;
- int ret;

smap = kzalloc(sizeof(*smap), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT);
if (!smap)
@@ -688,18 +686,9 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr)
/* Use at least 2 buckets, select_bucket() is undefined behavior with 1 bucket */
nbuckets = max_t(u32, 2, nbuckets);
smap->bucket_log = ilog2(nbuckets);
- cost = sizeof(*smap->buckets) * nbuckets + sizeof(*smap);
-
- ret = bpf_map_charge_init(&smap->map.memory, cost);
- if (ret < 0) {
- kfree(smap);
- return ERR_PTR(ret);
- }
-
smap->buckets = kvcalloc(sizeof(*smap->buckets), nbuckets,
GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT);
if (!smap->buckets) {
- bpf_map_charge_finish(&smap->map.memory);
kfree(smap);
return ERR_PTR(-ENOMEM);
}
--
2.26.2


2020-07-28 05:44:42

by Song Liu

[permalink] [raw]
Subject: Re: [PATCH bpf-next v2 25/35] bpf: eliminate rlimit-based memory accounting for socket storage maps

On Mon, Jul 27, 2020 at 12:26 PM Roman Gushchin <[email protected]> wrote:
>
> Do not use rlimit-based memory accounting for socket storage maps.
> It has been replaced with the memcg-based memory accounting.
>
> Signed-off-by: Roman Gushchin <[email protected]>

Acked-by: Song Liu <[email protected]>

> ---
> net/core/bpf_sk_storage.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
> index fbcd03cd00d3..c0a35b6368af 100644
> --- a/net/core/bpf_sk_storage.c
> +++ b/net/core/bpf_sk_storage.c
> @@ -676,8 +676,6 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr)
> struct bpf_sk_storage_map *smap;
> unsigned int i;
> u32 nbuckets;
> - u64 cost;
> - int ret;
>
> smap = kzalloc(sizeof(*smap), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT);
> if (!smap)
> @@ -688,18 +686,9 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr)
> /* Use at least 2 buckets, select_bucket() is undefined behavior with 1 bucket */
> nbuckets = max_t(u32, 2, nbuckets);
> smap->bucket_log = ilog2(nbuckets);
> - cost = sizeof(*smap->buckets) * nbuckets + sizeof(*smap);
> -
> - ret = bpf_map_charge_init(&smap->map.memory, cost);
> - if (ret < 0) {
> - kfree(smap);
> - return ERR_PTR(ret);
> - }
> -
> smap->buckets = kvcalloc(sizeof(*smap->buckets), nbuckets,
> GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT);
> if (!smap->buckets) {
> - bpf_map_charge_finish(&smap->map.memory);
> kfree(smap);
> return ERR_PTR(-ENOMEM);
> }
> --
> 2.26.2
>