Re: [PATCH v3 0/2] LoongArch: BPF: per-CPU address resolution and timed may_goto
From: Huacai Chen
Date: Wed Aug 05 2026 - 03:15:25 EST
Hi, George,
In V1 it is independent,
In V2 it is part of
https://lore.kernel.org/loongarch/20260702022322.51033-1-dongtai.guo@xxxxxxxxx/T/#t
In V3 it is independent again.
What do you want? You can ask Tiezhu and Hengqi to review your
patches, but don't do such confusing things.
Huacai
On Tue, Aug 4, 2026 at 11:46 PM George Guo <dongtai.guo@xxxxxxxxx> wrote:
>
> 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@xxxxxxxxx/
>
> 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@xxxxxxxxx/
>
> 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
>