[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c587edd1-811b-4cc2-8738-a01196bab274@huaweicloud.com>
Date: Thu, 5 Sep 2024 14:42:15 +0800
From: Pu Lehui <pulehui@...weicloud.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: bpf@...r.kernel.org, linux-riscv@...ts.infradead.org,
netdev@...r.kernel.org, Andrii Nakryiko <andrii@...nel.org>,
Björn Töpel <bjorn@...nel.org>,
Ilya Leoshkevich <iii@...ux.ibm.com>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
<eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Puranjay Mohan <puranjay@...nel.org>, Palmer Dabbelt <palmer@...belt.com>,
Pu Lehui <pulehui@...wei.com>
Subject: Re: [PATCH bpf-next v3 2/4] libbpf: Access first syscall argument
with CO-RE direct read on arm64
On 2024/9/5 4:21, Andrii Nakryiko wrote:
> On Fri, Aug 30, 2024 at 9:17 PM Pu Lehui <pulehui@...weicloud.com> wrote:
>>
>> From: Pu Lehui <pulehui@...wei.com>
>>
>> Currently PT_REGS_PARM1 SYSCALL(x) is consistent with PT_REGS_PARM1_CORE
>> SYSCALL(x), which will introduce the overhead of BPF_CORE_READ(), taking
>> into account the read pt_regs comes directly from the context, let's use
>> CO-RE direct read to access the first system call argument.
>>
>> Suggested-by: Andrii Nakryiko <andrii@...nel.org>
>> Signed-off-by: Pu Lehui <pulehui@...wei.com>
>> ---
>> tools/lib/bpf/bpf_tracing.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
>> index e7d9382efeb3..051c408e6aed 100644
>> --- a/tools/lib/bpf/bpf_tracing.h
>> +++ b/tools/lib/bpf/bpf_tracing.h
>> @@ -222,7 +222,7 @@ struct pt_regs___s390 {
>>
>> struct pt_regs___arm64 {
>> unsigned long orig_x0;
>> -};
>> +} __attribute__((preserve_access_index));
>>
>> /* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */
>> #define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x))
>> @@ -241,7 +241,7 @@ struct pt_regs___arm64 {
>> #define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
>> #define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
>> #define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
>> -#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x)
>> +#define PT_REGS_PARM1_SYSCALL(x) (((const struct pt_regs___arm64 *)(x))->orig_x0)
>
> It would probably be best (for consistency) to stick to using
> __PTR_PARM1_SYSCALL_REG instead of hard-coding orig_x0 here, no? I'll
> fix it up while applying. Same for patch #1 and #4.
>
> It would be great if you can double-check that final patches in
> bpf-next/master compile and work well for arm64, s390x, and RV64 (as I
> can't really test that much locally).
I check that locally with cross-platform vmtest on RV64, it looks good:
Summary: 569/3944 PASSED, 104 SKIPPED, 0 FAILED
and BPF CI meet happy on arm64, s390x.
>
>
>
>> #define PT_REGS_PARM1_CORE_SYSCALL(x) \
>> BPF_CORE_READ((const struct pt_regs___arm64 *)(x), __PT_PARM1_SYSCALL_REG)
>>
>> --
>> 2.34.1
>>
Powered by blists - more mailing lists