BPF List
 help / color / mirror / Atom feed
* [PATCH v3 0/2] LoongArch: BPF: per-CPU address resolution and timed may_goto
@ 2026-08-04 15:39 George Guo
  2026-08-04 15:39 ` [PATCH v3 1/2] LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrs George Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: George Guo @ 2026-08-04 15:39 UTC (permalink / raw)
  To: chenhuacai, yangtiezhu, hengqi.chen, ast, daniel, andrii
  Cc: kernel, martin.lau, eddyz87, memxor, song, yonghong.song, jolsa,
	guodongtai, bpf, loongarch, linux-kernel

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


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

end of thread, other threads:[~2026-08-06 12:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 15:39 [PATCH v3 0/2] LoongArch: BPF: per-CPU address resolution and timed may_goto George Guo
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox