bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT
@ 2024-05-19  5:05 Xiao Wang
  2024-05-21 16:35 ` Björn Töpel
  2024-05-24 15:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Xiao Wang @ 2024-05-19  5:05 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, luke.r.nels, xi.wang, bjorn
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-riscv,
	linux-kernel, bpf, pulehui, haicheng.li, Xiao Wang

We could try to emit compressed insn for reg move operation during CMPXCHG
JIT, the instruction compression has no impact on the jump offsets of
following forward and backward jump instructions.

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 arch/riscv/net/bpf_jit_comp64.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index aac190085472..c134aaec4295 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -531,8 +531,10 @@ static void emit_atomic(u8 rd, u8 rs, s16 off, s32 imm, bool is64,
 	/* r0 = atomic_cmpxchg(dst_reg + off16, r0, src_reg); */
 	case BPF_CMPXCHG:
 		r0 = bpf_to_rv_reg(BPF_REG_0, ctx);
-		emit(is64 ? rv_addi(RV_REG_T2, r0, 0) :
-		     rv_addiw(RV_REG_T2, r0, 0), ctx);
+		if (is64)
+			emit_mv(RV_REG_T2, r0, ctx);
+		else
+			emit_addiw(RV_REG_T2, r0, 0, ctx);
 		emit(is64 ? rv_lr_d(r0, 0, rd, 0, 0) :
 		     rv_lr_w(r0, 0, rd, 0, 0), ctx);
 		jmp_offset = ninsns_rvoff(8);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT
  2024-05-19  5:05 [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT Xiao Wang
@ 2024-05-21 16:35 ` Björn Töpel
  2024-05-24 15:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Björn Töpel @ 2024-05-21 16:35 UTC (permalink / raw)
  To: Xiao Wang, paul.walmsley, palmer, aou, luke.r.nels, xi.wang
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-riscv,
	linux-kernel, bpf, pulehui, haicheng.li, Xiao Wang

Xiao Wang <xiao.w.wang@intel.com> writes:

> We could try to emit compressed insn for reg move operation during CMPXCHG
> JIT, the instruction compression has no impact on the jump offsets of
> following forward and backward jump instructions.

...and at some point we should start supporting Zacas and friends,
instead of lr/sc.

> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT
  2024-05-19  5:05 [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT Xiao Wang
  2024-05-21 16:35 ` Björn Töpel
@ 2024-05-24 15:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-24 15:50 UTC (permalink / raw)
  To: Wang, Xiao W
  Cc: paul.walmsley, palmer, aou, luke.r.nels, xi.wang, bjorn, ast,
	daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-riscv,
	linux-kernel, bpf, pulehui, haicheng.li

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Sun, 19 May 2024 13:05:07 +0800 you wrote:
> We could try to emit compressed insn for reg move operation during CMPXCHG
> JIT, the instruction compression has no impact on the jump offsets of
> following forward and backward jump instructions.
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> ---
>  arch/riscv/net/bpf_jit_comp64.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Here is the summary with links:
  - riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT
    https://git.kernel.org/bpf/bpf-next/c/99fa63d9ca60

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-24 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-19  5:05 [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT Xiao Wang
2024-05-21 16:35 ` Björn Töpel
2024-05-24 15:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).