Re: [PATCH bpf-next v3 03/15] libbpf: honor autocreate flag for struct_ops maps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2024-03-05 at 11:19 -0800, Andrii Nakryiko wrote:
[...]

> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 2c0cb72bc7a4..25c452c20d7d 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -1209,7 +1209,7 @@ static int bpf_object__init_kern_struct_ops_maps(struct bpf_object *obj)
> >         for (i = 0; i < obj->nr_maps; i++) {
> >                 map = &obj->maps[i];
> > 
> > -               if (!bpf_map__is_struct_ops(map))
> > +               if (!bpf_map__is_struct_ops(map) || !map->autocreate)
> 
> tbh, I'd keep them as separate checks (they check very different
> aspects, so feels appropriate to not combine them in one check)
> 
> >                         continue;
> > 
> >                 err = bpf_map__init_kern_struct_ops(map);
> > @@ -8136,7 +8136,7 @@ static int bpf_object_prepare_struct_ops(struct bpf_object *obj)
> >         int i;
> > 
> >         for (i = 0; i < obj->nr_maps; i++)
> > -               if (bpf_map__is_struct_ops(&obj->maps[i]))
> > +               if (bpf_map__is_struct_ops(&obj->maps[i]) && obj->maps[i].autocreate)
> 
> especially here, this becomes a bit convoluted
> 
> how about we make it a bit more verbose, but also straightforward
> 
> map = &obj->maps[i];
> if (!bpf_map__is_struct_ops(map))
>     continue;
> if (!map->autocreate)
>     continue;
> bpf_map_prepare_vdata(...)

Ok, will do

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux