Re: [PATCH bpf-next v2 14/35] bpf: eliminate rlimit-based memory accounting for bpf_struct_ops maps

2020-07-27 Thread Song Liu
On Mon, Jul 27, 2020 at 12:26 PM Roman Gushchin  wrote:
>
> Do not use rlimit-based memory accounting for bpf_struct_ops maps.
> It has been replaced with the memcg-based memory accounting.
>
> Signed-off-by: Roman Gushchin 

Acked-by: Song Liu 


[PATCH bpf-next v2 14/35] bpf: eliminate rlimit-based memory accounting for bpf_struct_ops maps

2020-07-27 Thread Roman Gushchin
Do not use rlimit-based memory accounting for bpf_struct_ops maps.
It has been replaced with the memcg-based memory accounting.

Signed-off-by: Roman Gushchin 
---
 kernel/bpf/bpf_struct_ops.c | 19 +++
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index 969c5d47f81f..22bfa236683b 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -550,12 +550,10 @@ static int bpf_struct_ops_map_alloc_check(union bpf_attr 
*attr)
 static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
 {
const struct bpf_struct_ops *st_ops;
-   size_t map_total_size, st_map_size;
+   size_t st_map_size;
struct bpf_struct_ops_map *st_map;
const struct btf_type *t, *vt;
-   struct bpf_map_memory mem;
struct bpf_map *map;
-   int err;
 
if (!bpf_capable())
return ERR_PTR(-EPERM);
@@ -575,20 +573,11 @@ static struct bpf_map *bpf_struct_ops_map_alloc(union 
bpf_attr *attr)
 * struct bpf_struct_ops_tcp_congestions_ops
 */
(vt->size - sizeof(struct bpf_struct_ops_value));
-   map_total_size = st_map_size +
-   /* uvalue */
-   sizeof(vt->size) +
-   /* struct bpf_progs **progs */
-btf_type_vlen(t) * sizeof(struct bpf_prog *);
-   err = bpf_map_charge_init(, map_total_size);
-   if (err < 0)
-   return ERR_PTR(err);
 
st_map = bpf_map_area_alloc(st_map_size, NUMA_NO_NODE);
-   if (!st_map) {
-   bpf_map_charge_finish();
+   if (!st_map)
return ERR_PTR(-ENOMEM);
-   }
+
st_map->st_ops = st_ops;
map = _map->map;
 
@@ -599,14 +588,12 @@ static struct bpf_map *bpf_struct_ops_map_alloc(union 
bpf_attr *attr)
st_map->image = bpf_jit_alloc_exec(PAGE_SIZE);
if (!st_map->uvalue || !st_map->progs || !st_map->image) {
bpf_struct_ops_map_free(map);
-   bpf_map_charge_finish();
return ERR_PTR(-ENOMEM);
}
 
mutex_init(_map->lock);
set_vm_flush_reset_perms(st_map->image);
bpf_map_init_from_attr(map, attr);
-   bpf_map_charge_move(>memory, );
 
return map;
 }
-- 
2.26.2