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.
The latest kernels select CONFIG_THREAD_INFO_IN_TASK, it can just read
preempt_count from the thread_info which is embedded within task_struct.
With this patch, "./test_progs -t exe_ctx" passes on LoongArch.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
return bpf_get_current_task_btf()->thread_info.preempt_count;
#elif defined(bpf_target_s390)
return bpf_get_lowcore()->preempt_count;
+#elif defined(bpf_target_loongarch)
+ return bpf_get_current_task_btf()->thread_info.preempt_count;
#endif
return 0;
}
* * arm64
* * powerpc64
* * s390x
+ * * loongarch
*/
static inline int bpf_in_interrupt(void)
{
* * arm64
* * powerpc64
* * s390x
+ * * loongarch
*/
static inline int bpf_in_nmi(void)
{
* * arm64
* * powerpc64
* * s390x
+ * * loongarch
*/
static inline int bpf_in_hardirq(void)
{
* * arm64
* * powerpc64
* * s390x
+ * * loongarch
*/
static inline int bpf_in_serving_softirq(void)
{
* * arm64
* * powerpc64
* * s390x
+ * * loongarch
*/
static inline int bpf_in_task(void)
{