Re: [PATCH bpf-next 1/2] libbpf: implement bpf_usdt_arg_size BPF function

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

 



On Mon, Feb 24, 2025 at 3:15 PM Ihor Solodrai <ihor.solodrai@xxxxxxxxx> wrote:
>
> On 2/24/25 2:05 PM, Andrii Nakryiko wrote:
>
> > [...]
> >
> > arg_bitshift is stored as char (which could be signed), so that's why
> > you were getting signed division, just cast to unsigned and keep
> > division:
> >
> > return (64 - (unsigned)arg_spec->arg_bitshift) / 8;
>
> As it turns out, this doesn't work either. Presumably because
> (64 - (u8)x) is still a signed int.

hm... ok, surprising, but fine

>
> This works, however:
>
>     return (unsigned char)(64 - arg_spec->arg_bitshift) / 8;
>


nit: just unsigned (int), BPF doesn't have single-byte division
anyways, so it will be upconverted to 32-bit (or 64-bit for noalu32).
So let's be bold and use 32-bits here ;)

> >
> >> [...]





[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