From: "Ihor Solodrai" <ihor.solodrai@linux.dev>
To: "Andrii Nakryiko" <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, andrii@kernel.org, ast@kernel.org,
daniel@iogearbox.net, eddyz87@gmail.com, mykolal@fb.com,
kernel-team@meta.com
Subject: Re: [PATCH bpf-next 1/2] libbpf: implement bpf_usdt_arg_size BPF function
Date: Mon, 24 Feb 2025 23:38:05 +0000 [thread overview]
Message-ID: <e73e0f197c012b0c770dfe4579914721c13eaedd@linux.dev> (raw)
In-Reply-To: <CAEf4BzZkmAQOeFWLn7BTcqLVj812dfhxxrybMxvWXfQG7hBi2g@mail.gmail.com>
On 2/24/25 3:25 PM, Andrii Nakryiko wrote:
> On Mon, Feb 24, 2025 at 3:15 PM Ihor Solodrai <ihor.solodrai@linux.dev> 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 ;)
oh
I specified a type because:
$ ./scripts/checkpatch.pl /tmpfs/0001-libbpf-implement-bpf_usdt_arg_size-BPF-function.patch
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#56: FILE: tools/lib/bpf/usdt.bpf.h:140:
+ return (64 - (unsigned)arg_spec->arg_bitshift) / 8;
(unsigned int) it is then
>
>>>
>>>> [...]
prev parent reply other threads:[~2025-02-24 23:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 21:59 [PATCH bpf-next 1/2] libbpf: implement bpf_usdt_arg_size BPF function Ihor Solodrai
2025-02-20 21:59 ` [PATCH bpf-next 2/2] selftests/bpf: test bpf_usdt_arg_size() function Ihor Solodrai
2025-02-24 22:05 ` [PATCH bpf-next 1/2] libbpf: implement bpf_usdt_arg_size BPF function Andrii Nakryiko
2025-02-24 22:21 ` Ihor Solodrai
2025-02-24 23:14 ` Ihor Solodrai
2025-02-24 23:25 ` Andrii Nakryiko
2025-02-24 23:38 ` Ihor Solodrai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e73e0f197c012b0c770dfe4579914721c13eaedd@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@meta.com \
--cc=mykolal@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.