iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.57k stars 3.88k forks source link

failed to create kprobe 'mutex_lock' using klockstat in kernel 6.7 #4885

Open Rrooach opened 9 months ago

Rrooach commented 9 months ago

Hi, when I using klockstat in libbpf_example, I have the following problem,

libbpf: prog 'kprobe_mutex_lock': failed to create kprobe 'mutex_lock+0x0' pey
libbpf: prog 'kprobe_mutex_lock': failed to auto-attach: -2
failed to attach BPF object

it seems the latest kernel does not have mutex_lock. Instead, it has __mutex_lock, and there is a similar problem for kprobe_mutex_lock_interruptible. Do you have any idea how to fix that?

Much thanks.

yonghong-song commented 9 months ago

Your kernel configuration file probably has this config CONFIG_DEBUG_LOCK_ALLOC under which we have

#define mutex_lock(lock) mutex_lock_nested(lock, 0)

So in your kernel, you need to trace mutex_lock_nested() function.

Since bcc tools intend for production system which in general does not enable CONFIG_DEBUG_LOCK_ALLOC, so klockstat tool itself will stay as is.