Skip to content
Merged
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
34 changes: 14 additions & 20 deletions kernel/btrfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ NETDATA_BPF_ARRAY_DEF(btrfs_ctrl, __u32, __u64, NETDATA_CONTROLLER_END);

static __always_inline int netdata_btrfs_entry()
{
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 pid = (__u32)(pid_tgid >> 32);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
__u64 ts = bpf_ktime_get_ns();

bpf_map_update_elem(&tmp_btrfs, &pid, &ts, BPF_ANY);
bpf_map_update_elem(&tmp_btrfs, &tid, &ts, BPF_ANY);

libnetdata_update_global(&btrfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);

Expand Down Expand Up @@ -129,15 +128,14 @@ int netdata_ret_generic_file_read_iter(struct pt_regs *ctx)
#endif
{
__u64 *fill, data;
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 bin, pid = (__u32)(pid_tgid >> 32);
__u32 bin, tid = (__u32)bpf_get_current_pid_tgid();

fill = bpf_map_lookup_elem(&tmp_btrfs, &pid);
fill = bpf_map_lookup_elem(&tmp_btrfs, &tid);
if (!fill)
return 0;

data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_btrfs, &pid);
bpf_map_delete_elem(&tmp_btrfs, &tid);

libnetdata_update_global(&btrfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_DEL, 1);

Expand All @@ -157,15 +155,14 @@ SEC("kretprobe/btrfs_file_write_iter")
int netdata_ret_btrfs_file_write_iter(struct pt_regs *ctx)
{
__u64 *fill, data;
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 bin, pid = (__u32)(pid_tgid >> 32);
__u32 bin, tid = (__u32)bpf_get_current_pid_tgid();

fill = bpf_map_lookup_elem(&tmp_btrfs, &pid);
fill = bpf_map_lookup_elem(&tmp_btrfs, &tid);
if (!fill)
return 0;

data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_btrfs, &pid);
bpf_map_delete_elem(&tmp_btrfs, &tid);

libnetdata_update_global(&btrfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_DEL, 1);

Expand All @@ -185,15 +182,14 @@ SEC("kretprobe/btrfs_file_open")
int netdata_ret_btrfs_file_open(struct pt_regs *ctx)
{
__u64 *fill, data;
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 bin, pid = (__u32)(pid_tgid >> 32);
__u32 bin, tid = (__u32)bpf_get_current_pid_tgid();

fill = bpf_map_lookup_elem(&tmp_btrfs, &pid);
fill = bpf_map_lookup_elem(&tmp_btrfs, &tid);
if (!fill)
return 0;

data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_btrfs, &pid);
bpf_map_delete_elem(&tmp_btrfs, &tid);

libnetdata_update_global(&btrfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_DEL, 1);

Expand All @@ -213,15 +209,14 @@ SEC("kretprobe/btrfs_sync_file")
int netdata_ret_btrfs_sync_file(struct pt_regs *ctx)
{
__u64 *fill, data;
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 bin, pid = (__u32)(pid_tgid >> 32);
__u32 bin, tid = (__u32)bpf_get_current_pid_tgid();

fill = bpf_map_lookup_elem(&tmp_btrfs, &pid);
fill = bpf_map_lookup_elem(&tmp_btrfs, &tid);
if (!fill)
return 0;

data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_btrfs, &pid);
bpf_map_delete_elem(&tmp_btrfs, &tid);

libnetdata_update_global(&btrfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_DEL, 1);

Expand All @@ -238,4 +233,3 @@ int netdata_ret_btrfs_sync_file(struct pt_regs *ctx)
}

char _license[] SEC("license") = "GPL";

23 changes: 11 additions & 12 deletions kernel/ext4_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ static __always_inline void netdata_ext4_store_bin(__u32 bin, __u32 selection)

static __always_inline int netdata_ext4_ret(struct pt_regs *ctx, __u32 selector)
{
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 pid = (__u32)(pid_tgid >> 32);
__u32 tid = (__u32)bpf_get_current_pid_tgid();

__u64 *fill = bpf_map_lookup_elem(&tmp_ext4, &pid);
__u64 *fill = bpf_map_lookup_elem(&tmp_ext4, &tid);
if (!fill)
return 0;

__u64 data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_ext4, &pid);
bpf_map_delete_elem(&tmp_ext4, &tid);

if ((s64)data < 0)
return 0;
Expand All @@ -76,35 +75,35 @@ static __always_inline int netdata_ext4_ret(struct pt_regs *ctx, __u32 selector)
SEC("kprobe/ext4_file_read_iter")
int netdata_ext4_file_read_iter(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_ext4, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_ext4, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&ext4_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/ext4_file_write_iter")
int netdata_ext4_file_write_iter(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_ext4, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_ext4, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&ext4_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/ext4_file_open")
int netdata_ext4_file_open(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_ext4, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_ext4, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&ext4_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/ext4_sync_file")
int netdata_ext4_sync_file(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_ext4, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_ext4, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&ext4_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}
Expand Down
27 changes: 13 additions & 14 deletions kernel/nfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ static __always_inline void netdata_nfs_store_bin(__u32 bin, __u32 selection)

static __always_inline int netdata_nfs_ret(struct pt_regs *ctx, __u32 selector)
{
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 pid = (__u32)(pid_tgid >> 32);
__u32 tid = (__u32)bpf_get_current_pid_tgid();

__u64 *fill = bpf_map_lookup_elem(&tmp_nfs, &pid);
__u64 *fill = bpf_map_lookup_elem(&tmp_nfs, &tid);
if (!fill)
return 0;

__u64 data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_nfs, &pid);
bpf_map_delete_elem(&tmp_nfs, &tid);

if ((s64)data < 0)
return 0;
Expand All @@ -76,44 +75,44 @@ static __always_inline int netdata_nfs_ret(struct pt_regs *ctx, __u32 selector)
SEC("kprobe/nfs_file_read")
int netdata_nfs_file_read(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_nfs, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_nfs, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&nfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/nfs_file_write")
int netdata_nfs_file_write(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_nfs, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_nfs, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&nfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/nfs_file_open")
int netdata_nfs_file_open(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_nfs, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_nfs, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&nfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/nfs4_file_open")
int netdata_nfs4_file_open(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_nfs, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_nfs, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&nfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}

SEC("kprobe/nfs_getattr")
int netdata_nfs_getattr(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_nfs, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_nfs, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&nfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
return 0;
}
Expand Down
11 changes: 5 additions & 6 deletions kernel/xfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ NETDATA_BPF_ARRAY_DEF(xfs_ctrl, __u32, __u64, NETDATA_CONTROLLER_END);

static __always_inline void netdata_xfs_entry(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_xfs, &pid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_xfs, &tid, &(unsigned long long){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&xfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
}

Expand All @@ -43,15 +43,14 @@ static __always_inline void netdata_xfs_store_bin(__u32 bin, __u32 selection)

static __always_inline int netdata_xfs_ret(struct pt_regs *ctx, __u32 selector)
{
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 pid = (__u32)(pid_tgid >> 32);
__u32 tid = (__u32)bpf_get_current_pid_tgid();

__u64 *fill = bpf_map_lookup_elem(&tmp_xfs, &pid);
__u64 *fill = bpf_map_lookup_elem(&tmp_xfs, &tid);
if (!fill)
return 0;

__u64 data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_xfs, &pid);
bpf_map_delete_elem(&tmp_xfs, &tid);

if ((s64)data < 0)
return 0;
Expand Down
11 changes: 5 additions & 6 deletions kernel/zfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ static __always_inline void netdata_zfs_store_bin(__u32 bin, __u32 selection)

static __always_inline int netdata_zfs_ret(struct pt_regs *ctx, __u32 selector)
{
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 pid = (__u32)(pid_tgid >> 32);
__u32 tid = (__u32)bpf_get_current_pid_tgid();

__u64 *fill = bpf_map_lookup_elem(&tmp_zfs, &pid);
__u64 *fill = bpf_map_lookup_elem(&tmp_zfs, &tid);
if (!fill)
return 0;

__u64 data = bpf_ktime_get_ns() - *fill;
bpf_map_delete_elem(&tmp_zfs, &pid);
bpf_map_delete_elem(&tmp_zfs, &tid);

if ((s64)data < 0)
return 0;
Expand All @@ -75,8 +74,8 @@ static __always_inline int netdata_zfs_ret(struct pt_regs *ctx, __u32 selector)

static __always_inline void netdata_zfs_start(struct pt_regs *ctx)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
bpf_map_update_elem(&tmp_zfs, &pid, &(__u64){bpf_ktime_get_ns()}, BPF_ANY);
__u32 tid = (__u32)bpf_get_current_pid_tgid();
bpf_map_update_elem(&tmp_zfs, &tid, &(__u64){bpf_ktime_get_ns()}, BPF_ANY);
libnetdata_update_global(&zfs_ctrl, NETDATA_CONTROLLER_TEMP_TABLE_ADD, 1);
}

Expand Down