summaryrefslogtreecommitdiff
path: root/include/linux/timerqueue.h
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2026-11-10 17:20:30 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2026-11-10 17:20:30 +0800
commit9496832b824ab5f570c86d65e3b6f08163e6908b (patch)
treecd1c5257510dc6c26529cc15da2ac3c20f950064 /include/linux/timerqueue.h
parent40d7a3e63c3d88b43e9115d23d9937dd506bbd02 (diff)
LoongArch: BPF: Make arena support depend on 128-bit cmpxchg
When testing bpf selftest "jit_insns/cast_to_user", there are different behaviors on different Loongson machines. (1) Loongson-3A6000 $ sudo ./test_progs -a jit_insns/cast_to_user ... Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED (2) Loongson-3A5000 $ sudo ./test_progs -a jit_insns/cast_to_user ... libbpf: map 'arena': failed to create: -ENOMEM run_subtest:FAIL:unexpected_load_failure unexpected error: -12 (errno 12) ... Summary: 0/0 PASSED, 0 SKIPPED, 1/1 FAILED This is because the arena range tree uses kmalloc_nolock() API, which requires 128-bit atomic cmpxchg. This feature is provided by not only hardware SCQ extension but also assembler support on LoongArch. On CPUs without the SCQ extension, or if the older versions of assembler do not support the sc.q instruction, arena map creation fails with a misleading -ENOMEM error. Since system_has_cmpxchg128() and arch_cmpxchg128() are only available when CONFIG_AS_HAS_SCQ_EXTENSION is enabled (need assembler support), we guard bpf_jit_supports_arena() with an #ifdef block to preserve compile- time robustness first, and then safely return system_has_cmpxchg128() if defined, otherwise falling back to false. This ensures that arena map creation cleanly fails with a -EOPNOTSUPP on the systems without either the assembler support or the hardware SCQ extension. With this patch, here is the test result on Loongson-3A5000 without SCQ extension: $ sudo ./test_progs -a jit_insns/cast_to_user ... libbpf: map 'arena': failed to create: -EOPNOTSUPP run_subtest:FAIL:unexpected_load_failure unexpected error: -95 (errno 95) ... Summary: 0/0 PASSED, 0 SKIPPED, 1/1 FAILED It is better to mark the test status as SKIPPED rather than logging a false-alarm failure if the feature is not supported, but this belongs to a separate bpf selftest patch. This is similar to commit 536b523b4073 ("bpf, riscv: Make arena support depend on ZACAS"). Note that BPF should not depend on a SLUB debug-mode escape hatch, so no need to consider the slub_debug exception. Cc: stable@vger.kernel.org Fixes: 4fdb5dd8aeba ("LoongArch: BPF: Implement bpf_addr_space_cast instruction") Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'include/linux/timerqueue.h')
0 files changed, 0 insertions, 0 deletions