Re: [PATCH bpf-next v4 07/24] bpf: Consolidate spin_lock, timer management into btf_record

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

 



On Fri, Nov 04, 2022 at 12:13:45PM IST, Kumar Kartikeya Dwivedi wrote:
> On Fri, Nov 04, 2022 at 11:00:11AM IST, Alexei Starovoitov wrote:
> > On Thu, Nov 3, 2022 at 12:11 PM Kumar Kartikeya Dwivedi
> > <memxor@xxxxxxxxx> wrote:
> > >  static int bpf_map_alloc_off_arr(struct bpf_map *map)
> > >  {
> > > -       bool has_spin_lock = map_value_has_spin_lock(map);
> > > -       bool has_timer = map_value_has_timer(map);
> > >         bool has_fields = !IS_ERR_OR_NULL(map);
> > >         struct btf_field_offs *fo;
> > > -       u32 i;
> > > +       struct btf_record *rec;
> > > +       u32 i, *off;
> > > +       u8 *sz;
> > >
> > > -       if (!has_spin_lock && !has_timer && !has_fields) {
> > > +       if (!has_fields) {
> > >                 map->field_offs = NULL;
> > >                 return 0;
> > >         }
> > > @@ -970,32 +987,14 @@ static int bpf_map_alloc_off_arr(struct bpf_map *map)
> > >                 return -ENOMEM;
> > >         map->field_offs = fo;
> > >
> > > -       fo->cnt = 0;
> > > -       if (has_spin_lock) {
> > > -               i = fo->cnt;
> > > -
> > > -               fo->field_off[i] = map->spin_lock_off;
> > > -               fo->field_sz[i] = sizeof(struct bpf_spin_lock);
> > > -               fo->cnt++;
> > > -       }
> > > -       if (has_timer) {
> > > -               i = fo->cnt;
> > > -
> > > -               fo->field_off[i] = map->timer_off;
> > > -               fo->field_sz[i] = sizeof(struct bpf_timer);
> > > -               fo->cnt++;
> > > -       }
> > > -       if (has_fields) {
> > > -               struct btf_record *rec = map->record;
> > > -               u32 *off = &fo->field_off[fo->cnt];
> > > -               u8 *sz = &fo->field_sz[fo->cnt];
> > > -
> > > -               for (i = 0; i < rec->cnt; i++) {
> > > -                       *off++ = rec->fields[i].offset;
> > > -                       *sz++ = btf_field_type_size(rec->fields[i].type);
> > > -               }
> > > -               fo->cnt += rec->cnt;
> > > +       rec = map->record;
> > > +       off = &fo->field_off[fo->cnt];
> > > +       sz = &fo->field_sz[fo->cnt];
> >
> > Another bug that would have been obvious if you run any tests.
> > (fo->cnt contains garbage)
> >
> > I'm surprised by the amount of issues in the series.
> >
>
> It's my bad, I deleted what was fo->cnt very recently and didn't give this a run

deleted

> > > -       fo->cnt = 0;



[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