Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

woodpenker
Copy link
Contributor

Allow offcputime to run on old kernels according to #4231.
Test OK on Ubuntu with 5.4.0 kernel.

}

SEC("kprobe/finish_task_switch")
int BPF_PROG(sched_switch_tp) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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                              

Copy link
Collaborator

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 ?

Copy link
Contributor Author

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。

Comment on lines 317 to 321
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);
}
Copy link
Collaborator

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 {}.

@woodpenker woodpenker changed the title offcputime: Allow offcputime to run on old kernels libbpf-tools/offcputime: Allow offcputime to run on old kernels Nov 12, 2022
@woodpenker woodpenker closed this Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants