From: 赵佳炜 <phoenix500526@163.com>
To: "Jiri Olsa" <olsajiri@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
yonghong.song@linux.dev, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re:Re: [PATCH bpf-next v12 0/2] libbpf: fix USDT SIB argument handling causing unrecognized register error
Date: Fri, 22 Aug 2025 23:18:03 +0800 (CST) [thread overview]
Message-ID: <7078a326.98e2.198d25bb89b.Coremail.phoenix500526@163.com> (raw)
In-Reply-To: <aKhuA0xklnLCIbsv@krava>
Ok, done.
At 2025-08-22 21:17:55, "Jiri Olsa" <olsajiri@gmail.com> wrote:
>On Thu, Aug 21, 2025 at 03:27:10PM +0000, Jiawei Zhao wrote:
>> When using GCC on x86-64 to compile an usdt prog with -O1 or higher
>> optimization, the compiler will generate SIB addressing mode for global
>> array and PC-relative addressing mode for global variable,
>> e.g. "1@-96(%rbp,%rax,8)" and "-1@4+t1(%rip)".
>>
>> The current USDT implementation in libbpf cannot parse these two formats,
>> causing `bpf_program__attach_usdt()` to fail with -ENOENT
>> (unrecognized register).
>>
>> This patch series adds support for SIB addressing mode in USDT probes.
>> The main changes include:
>> - add correct handling logic for SIB-addressed arguments in
>> `parse_usdt_arg`.
>> - add an usdt_o2 test case to cover SIB addressing mode.
>>
>> Testing shows that the SIB probe correctly generates 8@(%rcx,%rax,8)
>> argument spec and passes all validation checks.
>>
>> The modification history of this patch series:
>> Change since v1:
>> - refactor the code to make it more readable
>> - modify the commit message to explain why and how
>>
>> Change since v2:
>> - fix the `scale` uninitialized error
>>
>> Change since v3:
>> - force -O2 optimization for usdt.test.o to generate SIB addressing usdt
>> and pass all test cases.
>>
>> Change since v4:
>> - split the patch into two parts, one for the fix and the other for the
>> test
>>
>> Change since v5:
>> - Only enable optimization for x86 architecture to generate SIB addressing
>> usdt argument spec.
>>
>> Change since v6:
>> - Add an usdt_o2 test case to cover SIB addressing mode.
>> - Reinstate the usdt.c test case.
>>
>> Change since v7:
>> - Refactor modifications to __bpf_usdt_arg_spec to avoid increasing its size,
>> achieving better compatibility
>> - Fix some minor code style issues
>> - Refactor the usdt_o2 test case, removing semaphore and adding GCC attribute
>> to force -O2 optimization
>>
>> Change since v8:
>> - Refactor the usdt_o2 test case, using assembly to force SIB addressing mode.
>>
>> Change since v9:
>> - Only enable the usdt_o2 test case on x86_64 and i386 architectures since the
>> SIB addressing mode is only supported on x86_64 and i386.
>>
>> Change since v10:
>> - Replace `__attribute__((optimize("O2")))` with `#pragma GCC optimize("O1")`
>> to fix the issue where the optimized compilation condition works improperly.
>> - Renamed test case usdt_o2 and relevant files name to usdt_o1 in that O1
>> level optimization is enough to generate SIB addressing usdt argument spec.
>>
>> Change since v11:
>> - Replace `STAP_PROBE1` with `STAP_PROBE_ASM`
>> - Use bit fields instead of bit shifting operations
>> - Merge the usdt_o1 test case into the usdt test case
>
>hi,
>I can see patchset v12 twice with different stats.. this one's the latter,
>but you might want to resend with new version
>
>jirka
>
>
>>
>> Jiawei Zhao (2):
>> libbpf: fix USDT SIB argument handling causing unrecognized register
>> error
>> selftests/bpf: Enrich subtest_basic_usdt case in selftests to cover
>> SIB handling logic
>>
>> tools/lib/bpf/usdt.bpf.h | 47 ++++++++++++++-
>> tools/lib/bpf/usdt.c | 58 +++++++++++++++++--
>> tools/testing/selftests/bpf/prog_tests/usdt.c | 44 +++++++++++++-
>> tools/testing/selftests/bpf/progs/test_usdt.c | 30 ++++++++++
>> 4 files changed, 170 insertions(+), 9 deletions(-)
>>
>> --
>> 2.43.0
>>
>>
prev parent reply other threads:[~2025-08-22 15:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 15:27 [PATCH bpf-next v12 0/2] libbpf: fix USDT SIB argument handling causing unrecognized register error Jiawei Zhao
2025-08-21 15:27 ` [PATCH bpf-next v12 1/2] " Jiawei Zhao
2025-08-21 15:27 ` [PATCH bpf-next v12 2/2] selftests/bpf: Enrich subtest_basic_usdt case in selftests to cover SIB handling logic Jiawei Zhao
2025-08-22 13:17 ` [PATCH bpf-next v12 0/2] libbpf: fix USDT SIB argument handling causing unrecognized register error Jiri Olsa
2025-08-22 15:18 ` 赵佳炜 [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=7078a326.98e2.198d25bb89b.Coremail.phoenix500526@163.com \
--to=phoenix500526@163.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=olsajiri@gmail.com \
--cc=yonghong.song@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox