Re: [PATCH RFC bpf-next 2/2] selftests/bpf: Add LoongArch support for get_preempt_count()
Tiezhu Yang <[email protected]>
| Newsgroups | dev.linux.lists.sashiko,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On 2026/4/20 下午9:35, [email protected] wrote: > Sashiko AI review found 1 potential issue(s): > - [High] BPF programs including `bpf_experimental.h` will fail to compile on LoongArch due to a non-existent `thread_info` field in `struct task_struct`. > -- > > commit 82453686fe5eacd9f219e2a050dc016b297cfc79 > Author: Tiezhu Yang <[email protected]> > > selftests/bpf: Add LoongArch support for get_preempt_count() > > This commit adds LoongArch support for get_preempt_count() in the BPF > experimental helpers. It enables bpf_in_interrupt() and related macros to > work properly on LoongArch systems. > >> diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h >> index e5c039bc44cb4..5847bbf12d240 100644 >> --- a/tools/testing/selftests/bpf/bpf_experimental.h >> +++ b/tools/testing/selftests/bpf/bpf_experimental.h >> @@ -507,6 +507,8 @@ static inline int get_preempt_count(void) >> return bpf_get_lowcore()->preempt_count; >> #elif defined(bpf_target_riscv) >> return bpf_get_current_task_btf()->thread_info.preempt_count; >> +#elif defined(bpf_target_loongarch) >> + return bpf_get_current_task_btf()->thread_info.preempt_count; > > Will this compile successfully on LoongArch? > > Since LoongArch does not select CONFIG_THREAD_INFO_IN_TASK, struct > thread_info is allocated on the kernel stack rather than being embedded > within struct task_struct. Because of this, the generated BTF and vmlinux.h > for LoongArch will not contain a thread_info field in task_struct. > > Could this lead to a compiler error indicating that there is no member named > thread_info in struct task_struct when building BPF selftests? As mentioned in the cover letter, it needs to apply the kernel patch "LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK" [1] before testing. [1] https://lore.kernel.org/loongarch/[email protected]/ Thanks, Tiezhu