-
Notifications
You must be signed in to change notification settings - Fork 4k
libbpf-tools/syncsnoop: Add support for sync_file_range2 #5402
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
base: master
Are you sure you want to change the base?
Conversation
libbpf-tools/syncsnoop.c
Outdated
| obj = syncsnoop_bpf__open_and_load(); | ||
| if (!obj) { | ||
| fprintf(stderr, "failed to open and load BPF object\n"); | ||
| obj = syncsnoop_bpf__open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the indentation and blank line overall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. there is something wrong with my editor setting ATM. Will fix.
libbpf-tools/syncsnoop.c
Outdated
| return 1; | ||
| } | ||
|
|
||
| if (!tracepoint_exists("syscalls", "sys_enter__sync_file_range")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the number of underscores.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Will fix.
libbpf-tools/syncsnoop.c
Outdated
|
|
||
| if (!tracepoint_exists("syscalls", "sys_enter__sync_file_range")) | ||
| bpf_program__set_autoload(obj->progs.tracepoint__syscalls__sys_enter_sync_file_range, false); | ||
| if (!tracepoint_exists("syscalls", "sys_enter__sync_file_range2")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using else here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not work on arm system with an older kernel where this syscall was called arm_sync_file_range().
On the other end, not failing here, means the tools will silently skip file range synchronization events.
Best solution would probably to add that third syscall here too.
…_file_range() Some architectures like ppc64 don't use the sync_file_range syscall, but sync_file_range2 instead and that makes syncsnoop fails on those arches. Add support for it. On some older kernel, this function was called arm_sync_file_range() on arm architecture. Support this syscall too. Fixes the following error: libbpf: failed to determine tracepoint 'syscalls/sys_enter_sync_file_range' perf event ID: No such file or directory libbpf: prog 'tracepoint__syscalls__sys_enter_sync_file_range': failed to create tracepoint 'syscalls/sys_enter_sync_file_range' perf event: No such file or directory libbpf: prog 'tracepoint__syscalls__sys_enter_sync_file_range': failed to auto-attach: -2 failed to attach BPF object Signed-off-by: Jerome Marchand <[email protected]>
e7098b9 to
7c7d2c3
Compare
| SEC("tracepoint/syscalls/sys_enter_arm_sync_file_range") | ||
| void tracepoint__syscalls__sys_enter_arm_sync_file_range(struct trace_event_raw_sys_enter *ctx) | ||
| { | ||
| __syscall(ctx, SYS_SYNC_FILE_RANGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SYS_ARM_SYNC_FILE_RANGE?
| return 1; | ||
| } | ||
|
|
||
| if (!tracepoint_exists("syscalls", "sys_enter_sync_file_range")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about failing as the tool previously did when none of the tracepoints are found?
Some architectures like ppc64 don't use the sync_file_range syscall, but sync_file_range2 instead and that makes syncsnoop fails on those arches. Add support for it.
Fixes the following error:
libbpf: failed to determine tracepoint 'syscalls/sys_enter_sync_file_range' perf event ID: No such file or directory libbpf: prog 'tracepoint__syscalls__sys_enter_sync_file_range': failed to create tracepoint 'syscalls/sys_enter_sync_file_range' perf event: No such file or directory libbpf: prog 'tracepoint__syscalls__sys_enter_sync_file_range': failed to auto-attach: -2 failed to attach BPF object