Skip to content

Conversation

@jeromemarchand
Copy link
Contributor

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

obj = syncsnoop_bpf__open_and_load();
if (!obj) {
fprintf(stderr, "failed to open and load BPF object\n");
obj = syncsnoop_bpf__open();
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

return 1;
}

if (!tracepoint_exists("syscalls", "sys_enter__sync_file_range"))
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Will fix.


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"))
Copy link
Collaborator

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?

Copy link
Contributor Author

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]>
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);
Copy link
Collaborator

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"))
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants