Skip to content

selftests/bpf: Add some tests for LoongArch#12148

Open
kernel-patches-daemon-bpf[bot] wants to merge 2 commits into
bpf-next_basefrom
series/1098735=>bpf-next
Open

selftests/bpf: Add some tests for LoongArch#12148
kernel-patches-daemon-bpf[bot] wants to merge 2 commits into
bpf-next_basefrom
series/1098735=>bpf-next

Conversation

@kernel-patches-daemon-bpf
Copy link
Copy Markdown

Pull request for series with
subject: selftests/bpf: Add some tests for LoongArch
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1098735

There is no LoongArch support for get_preempt_count() currently and its
fallback path always returns 0, just add it so that bpf_in_interrupt(),
bpf_in_nmi(), bpf_in_hardirq(), bpf_in_serving_softirq(), bpf_in_task()
work for LoongArch as well.

Since LoongArch is transitioning to CONFIG_THREAD_INFO_IN_TASK, use
bpf_core_field_exists() to provide compatibility for both legacy and
future kernels. A struct flavor "task_struct___local" is introduced
to bypass static compiler checks when thread_info is missing from the
base task_struct.

For the newer kernels that select CONFIG_THREAD_INFO_IN_TASK, it reads
preempt_count from the thread_info embedded within task_struct. For the
older kernels without selecting CONFIG_THREAD_INFO_IN_TASK, it retrieves
the thread_info pointer from the bottom of the kernel stack (task->stack)
and then reads the preempt_count. This ensures the BPF selftests remain
functional across various LoongArch kernel versions.

With this patch, "./test_progs -t exe_ctx" passes on LoongArch regardless
of whether CONFIG_THREAD_INFO_IN_TASK is set.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Make it possible to limit certain tests to loongarch, just like it is
already done for x86_64, arm64, riscv64, and s390x.

This is a follow up patch of:

  commit ee7fe84 ("selftests/bpf: __arch_* macro to limit test cases to specific archs")
  commit 1e4e6b9 ("selftests/bpf: Add __arch_s390x macro")

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: b1fcdf9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1098735
version: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant