Question about why trace point inserting fails
- Dominant language
- C
- Stars
- 22.7k
- Forks
- 4.1k
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 3
Description
hi, all
This is my questions about using bcc to trace some kernel functions, here is my script:
`from __future__ import print_function
from bcc import BPF
import time
bpf_text="""
#include
#include
#include
int kprobe__balance_pgdat(struct pt_regs* ctx)
{
bpf_trace_printk("node");
return 0;
}
"""
b=BPF(text=bpf_text)
print("Tracing... Hit Ctrl-C to end.")
while 1:
# Read message from kernel pipe
try:
(task,pid,cpu,flags,ts,msg)=b.trac_fields()
(_tag,node_id)=msg.split(" ")
except KeyboardInterrupt:
print("over")
break`
I want to trace kernel function balance_pgdat, but fails with following errors:
`
raceback (most recent call last):
File "balance_pgdat.py", line 19, in
b=BPF(text=bpf_text)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 302, in __init__
self._trace_autoload()
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 914, in _trace_autoload
self.attach_kprobe(event=fn.name[8:], fn_name=fn.name)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 522, in attach_kprobe
raise Exception("Failed to attach BPF to kprobe")
Exception: Failed to attach BPF to kprobe
`
Then I also tried kpeob like this: kprobe "p:balance_pgdat"
`
ERROR: func balance_pgdat not in /sys/kernel/debug/tracing/available_filter_functions.
Either it doesn't exist, or, it might be unsafe to kprobe. Exiting. Use -F to override
and get:
`
I have cheked balance_pgdat is not in /sys/kernel/debug/tracing/available_filter_functions, but defined here: http://elixir.free-electrons.com/linux/latest/source/mm/vmscan.c#L3237
So I am wondering if bcc/kprobe can only work for part of the kernel functions or I have some mis-configurations. But after I installed bcc, I tried my its examples, it truely worked.
Appreciate for anyone's help
Wei
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Python script's BPF(text=bpf_text) call and the attach_kprobe traceback. Compare the balance_pgdat definition in mm/vmscan.c with /sys/kernel/debug/tracing/available_filter_functions and the reported kprobe command. Done means explaining why this function cannot be attached in the reported environment and identifying the relevant configuration or supported tracing path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux, python
- Domain
- observability, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100