-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libbpf-tools/offcputime: Allow offcputime to run on old kernels #4334
Conversation
} | ||
|
||
SEC("kprobe/finish_task_switch") | ||
int BPF_PROG(sched_switch_tp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fallback to raw tracepoint instead. See #4217.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for replay, but on my test env, the "raw_tp/sched_switch"
won't work:
libbpf: sched_switch is not found in vmlinux BTF
entries_lock
failed to get syms
- (0)
51
entries_lock
failed to get syms
- (0)
4811
entries_lock
The comm is empty and PID is always 0, I think the prev
is not correctly taken. Do you have any suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fallback to raw tracepoint instead. See #4217.
I tried to make it work and succeed, but the call stacks still seem always belong to the tracepoint raw_tp/sched_switch
.
Changed code:
SEC("raw_tp/sched_switch")
int BPF_PROG(sched_switch_tp) {
struct task_struct *prev = (struct task_struct *)((struct bpf_raw_tracepoint_args *)ctx)->args[1];
return handle_switch(ctx, prev);
}
Output example:
entries_lock [250/15106]
- kworker/2:2 (2704182)
9
entries_lock
wait4
- bash (2708107)
13
entries_lock
- ksoftirqd/0 (10)
1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does #4217 work for you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does #4217 work for you ?
Everything works fine except the callstacks, so close this pr until I find the reason and solutions。
libbpf-tools/offcputime.c
Outdated
if (probe_tp_btf("sched_switch")) { | ||
bpf_program__set_autoload(obj->progs.sched_switch_tp, false); | ||
} else { | ||
bpf_program__set_autoload(obj->progs.sched_switch_btf, false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are following kernel code style guide, so drop the surrounding {}
.
Allow offcputime to run on old kernels according to #4231.
Test OK on Ubuntu with 5.4.0 kernel.