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

libbpf-tools: Fix cachestat with kernel 5.15 #3747

Merged
merged 1 commit into from Mar 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 21 additions & 2 deletions libbpf-tools/cachestat.c
Expand Up @@ -142,12 +142,31 @@ int main(int argc, char **argv)
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
libbpf_set_print(libbpf_print_fn);

obj = cachestat_bpf__open_and_load();
obj = cachestat_bpf__open();
if (!obj) {
fprintf(stderr, "failed to open and/or load BPF object\n");
fprintf(stderr, "failed to open BPF object\n");
return 1;
}

/**
* account_page_dirtied was renamed to folio_account_dirtied
* in kernel commit 203a31516616 ("mm/writeback: Add __folio_mark_dirty()")
*/
if (fentry_exists("folio_account_dirtied", NULL)) {
err = bpf_program__set_attach_target(obj->progs.account_page_dirtied, 0,
"folio_account_dirtied");
if (err) {
fprintf(stderr, "failed to set attach target\n");
goto cleanup;
}
}

err = cachestat_bpf__load(obj);
if (err) {
fprintf(stderr, "failed to load BPF object\n");
goto cleanup;
}

if (!obj->bss) {
fprintf(stderr, "Memory-mapping BPF maps is supported starting from Linux 5.7, please upgrade.\n");
goto cleanup;
Expand Down