perf record: Fix BTF type checks in the off-cpu profiling
[platform/kernel/linux-starfive.git] / tools / perf / util / bpf_off_cpu.c
index 01f70b8..21f4d9b 100644 (file)
@@ -98,7 +98,7 @@ static void off_cpu_finish(void *arg __maybe_unused)
 /* v5.18 kernel added prev_state arg, so it needs to check the signature */
 static void check_sched_switch_args(void)
 {
-       const struct btf *btf = bpf_object__btf(skel->obj);
+       const struct btf *btf = btf__load_vmlinux_btf();
        const struct btf_type *t1, *t2, *t3;
        u32 type_id;
 
@@ -116,7 +116,8 @@ static void check_sched_switch_args(void)
                return;
 
        t3 = btf__type_by_id(btf, t2->type);
-       if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 4) {
+       /* btf_trace func proto has one more argument for the context */
+       if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 5) {
                /* new format: pass prev_state as 4th arg */
                skel->rodata->has_prev_state = true;
        }