mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
perf record: Fix BTF type checks in the off-cpu profiling
[ Upstream commit0e501a65d3
] The BTF func proto for a tracepoint has one more argument than the actual tracepoint function since it has a context argument at the begining. So it should compare to 5 when the tracepoint has 4 arguments. typedef void (*btf_trace_sched_switch)(void *, bool, struct task_struct *, struct task_struct *, unsigned int); Also, recent change in the perf tool would use a hand-written minimal vmlinux.h to generate BTF in the skeleton. So it won't have the info of the tracepoint. Anyway it should use the kernel's vmlinux BTF to check the type in the kernel. Fixes:b36888f71c
("perf record: Handle argument change in sched_switch") Reviewed-by: Ian Rogers <irogers@google.com> Acked-by: Song Liu <song@kernel.org> Cc: Hao Luo <haoluo@google.com> CC: bpf@vger.kernel.org Link: https://lore.kernel.org/r/20230922234444.3115821-1-namhyung@kernel.org Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
fe9d8c08de
commit
d9bd26de86
1 changed files with 3 additions and 2 deletions
|
@ -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 */
|
/* v5.18 kernel added prev_state arg, so it needs to check the signature */
|
||||||
static void check_sched_switch_args(void)
|
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;
|
const struct btf_type *t1, *t2, *t3;
|
||||||
u32 type_id;
|
u32 type_id;
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ static void check_sched_switch_args(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
t3 = btf__type_by_id(btf, t2->type);
|
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 */
|
/* new format: pass prev_state as 4th arg */
|
||||||
skel->rodata->has_prev_state = true;
|
skel->rodata->has_prev_state = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue