All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: Pu Lehui <pulehui@huawei.com>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org
Cc: Ivan Babrou <ivan@cloudflare.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH bpf-next 2/2] riscv, bpf: Fix incorrect runtime stats
Date: Tue, 16 Apr 2024 16:09:03 +0200	[thread overview]
Message-ID: <871q754cxs.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <39b55f13-69a1-401e-b87e-1040e33c9368@huawei.com>

Pu Lehui <pulehui@huawei.com> writes:

> On 2024/4/16 14:42, Xu Kuohai wrote:
>> From: Xu Kuohai <xukuohai@huawei.com>
>> 
>> When __bpf_prog_enter() returns zero, the s1 register is not set to zero,
>> resulting in incorrect runtime stats. Fix it by setting s1 immediately upon
>> the return of __bpf_prog_enter().
>> 
>> Fixes: 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64")
>> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
>> ---
>>   arch/riscv/net/bpf_jit_comp64.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
>> index 15e482f2c657..e713704be837 100644
>> --- a/arch/riscv/net/bpf_jit_comp64.c
>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>> @@ -730,6 +730,9 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
>>   	if (ret)
>>   		return ret;
>>   
>> +	/* store prog start time */
>> +	emit_mv(RV_REG_S1, RV_REG_A0, ctx);
>> +
>>   	/* if (__bpf_prog_enter(prog) == 0)
>>   	 *	goto skip_exec_of_prog;
>>   	 */
>> @@ -737,9 +740,6 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
>>   	/* nop reserved for conditional jump */
>>   	emit(rv_nop(), ctx);
>>   
>> -	/* store prog start time */
>> -	emit_mv(RV_REG_S1, RV_REG_A0, ctx);
>> -
>>   	/* arg1: &args_off */
>>   	emit_addi(RV_REG_A0, RV_REG_FP, -args_off, ctx);
>>   	if (!p->jited)
>
> Thanks.
>
> Reviewed-by: Pu Lehui <pulehui@huawei.com>

Acked-by: Björn Töpel <bjorn@kernel.org>

WARNING: multiple messages have this Message-ID (diff)
From: "Björn Töpel" <bjorn@kernel.org>
To: Pu Lehui <pulehui@huawei.com>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org
Cc: Ivan Babrou <ivan@cloudflare.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH bpf-next 2/2] riscv, bpf: Fix incorrect runtime stats
Date: Tue, 16 Apr 2024 16:09:03 +0200	[thread overview]
Message-ID: <871q754cxs.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <39b55f13-69a1-401e-b87e-1040e33c9368@huawei.com>

Pu Lehui <pulehui@huawei.com> writes:

> On 2024/4/16 14:42, Xu Kuohai wrote:
>> From: Xu Kuohai <xukuohai@huawei.com>
>> 
>> When __bpf_prog_enter() returns zero, the s1 register is not set to zero,
>> resulting in incorrect runtime stats. Fix it by setting s1 immediately upon
>> the return of __bpf_prog_enter().
>> 
>> Fixes: 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64")
>> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
>> ---
>>   arch/riscv/net/bpf_jit_comp64.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
>> index 15e482f2c657..e713704be837 100644
>> --- a/arch/riscv/net/bpf_jit_comp64.c
>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>> @@ -730,6 +730,9 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
>>   	if (ret)
>>   		return ret;
>>   
>> +	/* store prog start time */
>> +	emit_mv(RV_REG_S1, RV_REG_A0, ctx);
>> +
>>   	/* if (__bpf_prog_enter(prog) == 0)
>>   	 *	goto skip_exec_of_prog;
>>   	 */
>> @@ -737,9 +740,6 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
>>   	/* nop reserved for conditional jump */
>>   	emit(rv_nop(), ctx);
>>   
>> -	/* store prog start time */
>> -	emit_mv(RV_REG_S1, RV_REG_A0, ctx);
>> -
>>   	/* arg1: &args_off */
>>   	emit_addi(RV_REG_A0, RV_REG_FP, -args_off, ctx);
>>   	if (!p->jited)
>
> Thanks.
>
> Reviewed-by: Pu Lehui <pulehui@huawei.com>

Acked-by: Björn Töpel <bjorn@kernel.org>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: "Björn Töpel" <bjorn@kernel.org>
To: Pu Lehui <pulehui@huawei.com>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org
Cc: Ivan Babrou <ivan@cloudflare.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH bpf-next 2/2] riscv, bpf: Fix incorrect runtime stats
Date: Tue, 16 Apr 2024 16:09:03 +0200	[thread overview]
Message-ID: <871q754cxs.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <39b55f13-69a1-401e-b87e-1040e33c9368@huawei.com>

Pu Lehui <pulehui@huawei.com> writes:

> On 2024/4/16 14:42, Xu Kuohai wrote:
>> From: Xu Kuohai <xukuohai@huawei.com>
>> 
>> When __bpf_prog_enter() returns zero, the s1 register is not set to zero,
>> resulting in incorrect runtime stats. Fix it by setting s1 immediately upon
>> the return of __bpf_prog_enter().
>> 
>> Fixes: 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64")
>> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
>> ---
>>   arch/riscv/net/bpf_jit_comp64.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
>> index 15e482f2c657..e713704be837 100644
>> --- a/arch/riscv/net/bpf_jit_comp64.c
>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>> @@ -730,6 +730,9 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
>>   	if (ret)
>>   		return ret;
>>   
>> +	/* store prog start time */
>> +	emit_mv(RV_REG_S1, RV_REG_A0, ctx);
>> +
>>   	/* if (__bpf_prog_enter(prog) == 0)
>>   	 *	goto skip_exec_of_prog;
>>   	 */
>> @@ -737,9 +740,6 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
>>   	/* nop reserved for conditional jump */
>>   	emit(rv_nop(), ctx);
>>   
>> -	/* store prog start time */
>> -	emit_mv(RV_REG_S1, RV_REG_A0, ctx);
>> -
>>   	/* arg1: &args_off */
>>   	emit_addi(RV_REG_A0, RV_REG_FP, -args_off, ctx);
>>   	if (!p->jited)
>
> Thanks.
>
> Reviewed-by: Pu Lehui <pulehui@huawei.com>

Acked-by: Björn Töpel <bjorn@kernel.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-04-16 14:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16  6:42 [PATCH bpf-next 0/2] Fix incorrect bpf runtime stats for arm64 and riscv64 Xu Kuohai
2024-04-16  6:42 ` Xu Kuohai
2024-04-16  6:42 ` Xu Kuohai
2024-04-16  6:42 ` [PATCH bpf-next 1/2] bpf, arm64: Fix incorrect runtime stats Xu Kuohai
2024-04-16  6:42   ` Xu Kuohai
2024-04-16  6:42   ` Xu Kuohai
2024-04-16  6:42 ` [PATCH bpf-next 2/2] riscv, bpf: " Xu Kuohai
2024-04-16  6:42   ` Xu Kuohai
2024-04-16  6:42   ` Xu Kuohai
2024-04-16  9:35   ` Pu Lehui
2024-04-16  9:35     ` Pu Lehui
2024-04-16  9:35     ` Pu Lehui
2024-04-16 14:09     ` Björn Töpel [this message]
2024-04-16 14:09       ` Björn Töpel
2024-04-16 14:09       ` Björn Töpel
2024-04-16 15:30 ` [PATCH bpf-next 0/2] Fix incorrect bpf runtime stats for arm64 and riscv64 patchwork-bot+netdevbpf
2024-04-16 15:30   ` patchwork-bot+netdevbpf
2024-04-16 15:30   ` patchwork-bot+netdevbpf

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=871q754cxs.fsf@all.your.base.are.belong.to.us \
    --to=bjorn@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=ivan@cloudflare.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=pulehui@huawei.com \
    --cc=xukuohai@huaweicloud.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.