Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libbpf-tools/syncsnoop.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ void tracepoint__syscalls__sys_enter_sync_file_range(struct trace_event_raw_sys_
__syscall(ctx, SYS_SYNC_FILE_RANGE);
}

SEC("tracepoint/syscalls/sys_enter_sync_file_range2")
void tracepoint__syscalls__sys_enter_sync_file_range2(struct trace_event_raw_sys_enter *ctx)
{
__syscall(ctx, SYS_SYNC_FILE_RANGE2);
}

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?

}

SEC("tracepoint/syscalls/sys_enter_syncfs")
void tracepoint__syscalls__sys_enter_syncfs(struct trace_event_raw_sys_enter *ctx)
{
Expand Down
18 changes: 16 additions & 2 deletions libbpf-tools/syncsnoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <bpf/libbpf.h>
#include "syncsnoop.h"
#include "syncsnoop.skel.h"
#include "trace_helpers.h"

#define PERF_BUFFER_PAGES 16
#define PERF_POLL_TIMEOUT_MS 100
Expand Down Expand Up @@ -101,9 +102,22 @@ int main(int argc, char **argv)

libbpf_set_print(libbpf_print_fn);

obj = syncsnoop_bpf__open_and_load();
obj = syncsnoop_bpf__open();
if (!obj) {
fprintf(stderr, "failed to open and load BPF object\n");
fprintf(stderr, "failed to open BPF object\n");
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?

bpf_program__set_autoload(obj->progs.tracepoint__syscalls__sys_enter_sync_file_range, false);
if (!tracepoint_exists("syscalls", "sys_enter_sync_file_range2"))
bpf_program__set_autoload(obj->progs.tracepoint__syscalls__sys_enter_sync_file_range2, false);
if (!tracepoint_exists("syscalls", "sys_enter_arm_sync_file_range"))
bpf_program__set_autoload(obj->progs.tracepoint__syscalls__sys_enter_arm_sync_file_range, false);

err = syncsnoop_bpf__load(obj);
if (err) {
fprintf(stderr, "failed to load BPF object\n");
return 1;
}

Expand Down
4 changes: 4 additions & 0 deletions libbpf-tools/syncsnoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ enum sync_syscalls {
SYS_FDATASYNC,
SYS_MSYNC,
SYS_SYNC_FILE_RANGE,
SYS_SYNC_FILE_RANGE2,
SYS_ARM_SYNC_FILE_RANGE,
SYS_SYNCFS,
SYS_T_MAX,
};
Expand All @@ -28,6 +30,8 @@ static const char *sys_names[] = {
"fdatasync",
"msync",
"sync_file_range",
"sync_file_range2",
"arm_sync_file_range",
"syncfs",
"N/A",
};
Expand Down
Loading