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

cachestat broken by recent kernel change #3687

Open chenhengqi opened 3 years ago

chenhengqi commented 3 years ago

The BCC tool and libbpf-tool cachestat are broken on latest kernel. Kernel commit 203a31516616 ("mm/writeback: Add __folio_mark_dirty()") converted account_page_dirtied to folio_account_dirtied, so the attach target of these tools disppeared, making them broken.

$ sudo ./cachestat                                 
libbpf: failed to find kernel BTF type ID of 'account_page_dirtied': -3
libbpf: prog 'account_page_dirtied': failed to prepare load attributes: -3
libbpf: failed to load program 'account_page_dirtied'
libbpf: failed to load object 'cachestat_bpf'
libbpf: failed to load BPF skeleton 'cachestat_bpf': -3
failed to open and/or load BPF object
sudo ./cachestat.py 
cannot attach kprobe, probe entry may not exist
Traceback (most recent call last):
  File "./cachestat.py", line 99, in <module>
    b.attach_kprobe(event="account_page_dirtied", fn_name="do_count")
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 833, in attach_kprobe
    (fn_name, event))
Exception: Failed to attach BPF program do_count to kprobe account_page_dirtied
chenhengqi commented 3 years ago

BCC tool cachetop has the same problem.

chenhengqi commented 3 years ago

Maybe this problem date back to kernel v5.14 with https://github.com/torvalds/linux/commit/6e1cae881a0646f31fe2bda90297d820da1137eb .

yonghong-song commented 3 years ago

Thanks @chenhengqi I will take a look at this soon to see whether we can make a compatible change without changing tool's functionality.

ShawnZhong commented 1 year ago

I guess this issue is fixed by https://github.com/iovisor/bcc/pull/3747 & https://github.com/iovisor/bcc/pull/3692 and can be closed?