[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z23zes0fA3KGABcN@google.com>
Date: Fri, 27 Dec 2024 00:23:22 +0000
From: Peilin Ye <yepeilin@...gle.com>
To: Xu Kuohai <xukuohai@...weicloud.com>
Cc: bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...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>,
"Paul E. McKenney" <paulmck@...nel.org>,
Puranjay Mohan <puranjay@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Quentin Monnet <qmo@...nel.org>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
Josh Don <joshdon@...gle.com>, Barret Rhoden <brho@...gle.com>,
Neel Natu <neelnatu@...gle.com>,
Benjamin Segall <bsegall@...gle.com>,
David Vernet <dvernet@...a.com>,
Dave Marchevsky <davemarchevsky@...a.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC bpf-next v1 2/4] bpf: Introduce load-acquire and
store-release instructions
On Thu, Dec 26, 2024 at 11:07:10PM +0000, Peilin Ye wrote:
> > > + if (BPF_ATOMIC_TYPE(insn->imm) == BPF_ATOMIC_LOAD)
> > > + ptr = src;
> > > + else
> > > + ptr = dst;
> > > +
> > > + if (off) {
> > > + emit_a64_mov_i(true, tmp, off, ctx);
> > > + emit(A64_ADD(true, tmp, tmp, ptr), ctx);
> >
> > The mov and add instructions can be optimized to a single A64_ADD_I
> > if is_addsub_imm(off) is true.
>
> Thanks! I'll try this.
The following diff seems to work:
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -658,9 +658,15 @@ static int emit_atomic_load_store(const struct bpf_insn *insn, struct jit_ctx *c
ptr = dst;
if (off) {
- emit_a64_mov_i(true, tmp, off, ctx);
- emit(A64_ADD(true, tmp, tmp, ptr), ctx);
- ptr = tmp;
+ if (is_addsub_imm(off)) {
+ emit(A64_ADD_I(true, ptr, ptr, off), ctx);
+ } else if (is_addsub_imm(-off)) {
+ emit(A64_SUB_I(true, ptr, ptr, -off), ctx);
+ } else {
+ emit_a64_mov_i(true, tmp, off, ctx);
+ emit(A64_ADD(true, tmp, tmp, ptr), ctx);
+ ptr = tmp;
+ }
}
if (arena) {
emit(A64_ADD(true, tmp, ptr, arena_vm_base), ctx);
I'll include it in the next version. I think the same thing can be done
for emit_lse_atomic() and emit_ll_sc_atomic(); let me do that in a
separate patch.
Thanks,
Peilin Ye
Powered by blists - more mailing lists