Skip to content

Commit

Permalink
fix(bpf): Fix kepler_write_page_cache attach
Browse files Browse the repository at this point in the history
We need to use a standard tracepoint for kepler_write_page_cache to
avoid BTF relocation errors on systems where the writeback_dirty_folio
tracepoint doesn't exist.

This is due to the rename of writeback_dirty_page to
writeback_dirty_folio that happened in Kernel 5.16.

This patch adjust the attach logic to fall back to the old name if the
writeback_dirty_folio tracepoint does not exist.

Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Jun 18, 2024
1 parent fbe9b3c commit a57041c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bpfassets/libbpf/src/kepler.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ int kepler_read_page_trace(void *ctx)
}

// count write page cache
SEC("tp_btf/writeback_dirty_folio")
int kepler_write_page_trace(u64 *ctx)
SEC("tp/writeback_dirty_folio")
int kepler_write_page_trace(void *ctx)
{
u32 curr_tgid;
struct process_metrics_t *process_metrics;
Expand Down
10 changes: 7 additions & 3 deletions pkg/bpf/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ func (e *exporter) attach() error {
if err != nil {
return fmt.Errorf("failed to get kepler_write_page_trace: %w", err)
} else {
_, err = page_write.AttachTracepoint("writeback", "writeback_dirty_folio")
if err != nil {
klog.Warningf("failed to attach tp/writeback/writeback_dirty_folio: %v. Kepler will not collect page cache write events. This will affect the DRAM power model estimation on VMs.", err)
category := "writeback"
name := "writeback_dirty_page"
if _, err := os.Stat("/sys/kernel/debug/tracing/events/writeback/writeback_dirty_folio"); err == nil {
name = "writeback_dirty_folio"
}
if _, err = page_write.AttachTracepoint(category, name); err != nil {
klog.Warningf("failed to attach tp/%s/%s: %v. Kepler will not collect page cache write events. This will affect the DRAM power model estimation on VMs.", category, name, err)
} else {
e.enabledSoftwareCounters[config.PageCacheHit] = struct{}{}
}
Expand Down

0 comments on commit a57041c

Please sign in to comment.