[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z3Mr8bqHyjTEFqGm@google.com>
Date: Mon, 30 Dec 2024 23:25:37 +0000
From: Peilin Ye <yepeilin@...gle.com>
To: Xu Kuohai <xukuohai@...weicloud.com>
Cc: bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
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>, Stanislav Fomichev <sdf@...ichev.me>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Puranjay Mohan <puranjay@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Josh Don <joshdon@...gle.com>,
Barret Rhoden <brho@...gle.com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next 2/2] bpf, arm64: Emit A64_{ADD,SUB}_I when
possible in emit_{lse,ll_sc}_atomic()
On Mon, Dec 30, 2024 at 04:44:26PM +0800, Xu Kuohai wrote:
> > @@ -721,7 +727,7 @@ static int emit_ll_sc_atomic(const struct bpf_insn *insn, struct jit_ctx *ctx)
> > const s32 imm = insn->imm;
> > const s16 off = insn->off;
> > const bool isdw = BPF_SIZE(code) == BPF_DW;
> > - u8 reg;
> > + u8 reg = dst;
> > s32 jmp_offset;
> > if (BPF_MODE(code) == BPF_PROBE_ATOMIC) {
> > @@ -730,11 +736,15 @@ static int emit_ll_sc_atomic(const struct bpf_insn *insn, struct jit_ctx *ctx)
> > return -EINVAL;
> > }
> > - if (!off) {
> > - reg = dst;
> > - } else {
> > - emit_a64_mov_i(1, tmp, off, ctx);
> > - emit(A64_ADD(1, tmp, tmp, dst), ctx);
> > + if (off) {
> > + if (is_addsub_imm(off)) {
> > + emit(A64_ADD_I(1, tmp, reg, off), ctx);
> > + } else if (is_addsub_imm(-off)) {
> > + emit(A64_SUB_I(1, tmp, reg, -off), ctx);
> > + } else {
> > + emit_a64_mov_i(1, tmp, off, ctx);
> > + emit(A64_ADD(1, tmp, tmp, reg), ctx);
> > + }
> > reg = tmp;
> > }
>
> Thanks, this looks good to me, but we now have serveral repetitive code
> snippets like this. It would be better to refactor them into a common
> function.
Sure! I will do that in v2.
Thanks,
Peilin Ye
Powered by blists - more mailing lists