Re: [PATCH bpf-next v3 2/4] bpf, libbpf: Support global percpu data

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

 



On Mon, May 26, 2025 at 9:22 AM Leon Hwang <leon.hwang@xxxxxxxxx> wrote:
> +
> +       data_sz = map->def.value_size;
> +       if (is_percpu) {
> +               num_cpus = libbpf_num_possible_cpus();
> +               if (num_cpus < 0) {
> +                       err = num_cpus;
> +                       return err;
> +               }
> +
> +               data_sz = data_sz * num_cpus;
> +               data = malloc(data_sz);
> +               if (!data) {
> +                       err = -ENOMEM;
> +                       return err;
> +               }
> +
> +               elem_sz = map->def.value_size;
> +               for (i = 0; i < num_cpus; i++)
> +                       memcpy(data + i * elem_sz, map->mmaped, elem_sz);
> +       } else {
> +               data = map->mmaped;
> +       }
>
>         if (obj->gen_loader) {
>                 bpf_gen__map_update_elem(obj->gen_loader, map - obj->maps,
> -                                        map->mmaped, map->def.value_size);
> +                                        data, data_sz);

I missed it earlier, but now I wonder how this is supposed to work ?
skel and lskel may be generated on a system with N cpus,
but loaded with M cpus.

Another concern is num_cpus multiplier can be huge.
lksel adds all that init data into a global array.
Pls avoid this multiplier.





[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