From: George Guo <dongtai.guo@linux.dev>
To: chenhuacai@kernel.org, yangtiezhu@loongson.cn,
hengqi.chen@gmail.com, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org
Cc: kernel@xen0n.name, martin.lau@linux.dev, eddyz87@gmail.com,
memxor@gmail.com, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, guodongtai@kylinos.cn, bpf@vger.kernel.org,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v3 0/2] LoongArch: BPF: per-CPU address resolution and timed may_goto
Date: Tue, 4 Aug 2026 23:39:36 +0800 [thread overview]
Message-ID: <20260804153938.16129-1-dongtai.guo@linux.dev> (raw)
These are the first two patches of the LoongArch BPF JIT feature work,
sent on their own to make review easier. The remaining pieces
(per-program private stacks, exceptions/bpf_throw, sign-extending loads
and atomics on arena pointers, and the matching selftests) will follow in
a later series.
Both patches are independent of each other. They apply on top of Chenguang
Zhao's "LoongArch bpf kptr xchg inline support" v4 series:
https://lore.kernel.org/all/20260729022837.355549-1-chenguang.zhao@linux.dev/
Patch 1 adds the internal-only BPF MOV that resolves a per-CPU offset to
the current CPU's address, advertised through
bpf_jit_supports_percpu_insn(). LoongArch keeps the current CPU's per-CPU
base in $r21 (__my_cpu_offset), so the resolution is a single add.
Exercised by the cpumask and percpu_alloc selftests.
Patch 2 implements arch_bpf_timed_may_goto() and advertises it, so the
verifier lowers may_goto to its timed variant, which bounds the loop by a
wall-clock timeout kept in a per-loop stack slot. It uses a custom calling
convention: the count/timestamp stack offset is passed in BPF_REG_AX and
returned there, so the JIT call path skips the usual "BPF_REG_0 = return
value" move for this helper. Exercised by the iters selftests.
Selftest results (all PASS):
Feature Test(s)
--------------------------------------------------------------
1 internal-only MOV (percpu) cpumask, percpu_alloc
2 timed may_goto iters
$ sudo ./test_progs -t cpumask
...
Summary: 1/35 PASSED, 0 SKIPPED, 0 FAILED
$ sudo ./test_progs -t percpu_alloc
...
Summary: 1/18 PASSED, 0 SKIPPED, 0 FAILED
$ sudo ./test_progs -t iters
...
Summary: 1/93 PASSED, 0 SKIPPED, 0 FAILED
Based on loongarch-next:
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git/log/?h=loongarch-next
These two patches are split from the full v2 series (11 patches):
https://lore.kernel.org/all/20260702022322.51033-1-dongtai.guo@linux.dev/
George Guo (2):
LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrs
LoongArch: BPF: Add timed may_goto support
arch/loongarch/include/asm/inst.h | 1 +
arch/loongarch/net/Makefile | 2 +-
arch/loongarch/net/bpf_jit.c | 27 +++++++++++++-
arch/loongarch/net/bpf_timed_may_goto.S | 47 +++++++++++++++++++++++++
4 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 arch/loongarch/net/bpf_timed_may_goto.S
--
2.53.0
next reply other threads:[~2026-08-04 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 15:39 George Guo [this message]
2026-08-04 15:39 ` [PATCH v3 1/2] LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrs George Guo
2026-08-04 15:39 ` [PATCH v3 2/2] LoongArch: BPF: Add timed may_goto support George Guo
2026-08-05 7:11 ` [PATCH v3 0/2] LoongArch: BPF: per-CPU address resolution and timed may_goto Huacai Chen
2026-08-05 9:10 ` George Guo
2026-08-06 12:22 ` Tiezhu Yang
2026-08-09 4:09 ` Huacai Chen
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=20260804153938.16129-1-dongtai.guo@linux.dev \
--to=dongtai.guo@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=guodongtai@kylinos.cn \
--cc=hengqi.chen@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yangtiezhu@loongson.cn \
--cc=yonghong.song@linux.dev \
/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.