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

Failed to attach BPF program b'oncpu' to kprobe b'finish_task_switch' offcputime-bpfcc #4937

Open
p0mvn opened this issue Mar 16, 2024 · 3 comments

Comments

@p0mvn
Copy link

p0mvn commented Mar 16, 2024

I'm on Ubuntu 5.15.0-100-generic

built using the instructions for Ubuntu

I run:

/sbin/offcputime-bpfcc
3 warnings generated.
cannot attach kprobe, probe entry may not exist
Traceback (most recent call last):
  File "/sbin/offcputime-bpfcc", line 234, in <module>
    b.attach_kprobe(event="finish_task_switch", fn_name="oncpu")
  File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 683, in attach_kprobe
    raise Exception("Failed to attach BPF program %s to kprobe %s" %
Exception: Failed to attach BPF program b'oncpu' to kprobe b'finish_task_switch'

Would appreciate any help on this

@yonghong-song
Copy link
Collaborator

Maybe kernel function finish_task_switch is completely inlined? You can cat /proc/kallsyms to see whether this is the case or not.

@portnov
Copy link

portnov commented Apr 10, 2024

Hello
I have a similar problem.
I looked into /proc/kallsyms. There are records like "finish_task_switch.isra.0.cold" and several similar. Should it be this way?
If not, what to do in order for offcputime to work? recompile kernel with disabled optimizations? :)

@yonghong-song
Copy link
Collaborator

Unfortunately, finish_task_switch is a static function so indeed it could be easily inlined. In the above, it is lined with gcc. in order for offcputime to work, yes, you need to add 'noline' attribute to offcputime function in the kernel.

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

No branches or pull requests

3 participants