diff --git a/kernel-collector b/kernel-collector index 16fcff1..6021b1a 160000 --- a/kernel-collector +++ b/kernel-collector @@ -1 +1 @@ -Subproject commit 16fcff1f0ae7c155ff046e05c58aabd5f562478e +Subproject commit 6021b1a73077737ddeadd95140caaf24466ee58d diff --git a/src/cachestat.bpf.c b/src/cachestat.bpf.c index dbf1e56..c69d3d1 100644 --- a/src/cachestat.bpf.c +++ b/src/cachestat.bpf.c @@ -63,11 +63,7 @@ static __always_inline int netdata_common_page_cache_lru() libnetdata_update_u64(&fill->add_to_page_cache_lru, 1); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.add_to_page_cache_lru = 1; bpf_map_update_elem(&cstat_pid, &key, &data, BPF_ANY); @@ -91,11 +87,7 @@ static __always_inline int netdata_common_page_accessed() libnetdata_update_u64(&fill->mark_page_accessed, 1); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.mark_page_accessed = 1; bpf_map_update_elem(&cstat_pid, &key, &data, BPF_ANY); @@ -119,11 +111,7 @@ static __always_inline int netdata_common_page_dirtied() libnetdata_update_u64(&fill->account_page_dirtied, 1); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.account_page_dirtied = 1; bpf_map_update_elem(&cstat_pid, &key, &data, BPF_ANY); @@ -147,11 +135,7 @@ static __always_inline int netdata_common_buffer_dirty() libnetdata_update_u64(&fill->mark_buffer_dirty, 1); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.mark_buffer_dirty = 1; bpf_map_update_elem(&cstat_pid, &key, &data, BPF_ANY); diff --git a/src/dc.bpf.c b/src/dc.bpf.c index 837bb66..00c2402 100644 --- a/src/dc.bpf.c +++ b/src/dc.bpf.c @@ -63,6 +63,7 @@ static __always_inline int netdata_common_lookup_fast() libnetdata_update_u64(&fill->references, 1); } else { data.references = 1; + bpf_get_current_comm(&data.name, TASK_COMM_LEN); bpf_map_update_elem(&dcstat_pid, &key, &data, BPF_ANY); libnetdata_update_global(&dcstat_ctrl, NETDATA_CONTROLLER_PID_TABLE_ADD, 1); @@ -86,6 +87,7 @@ static __always_inline int netdata_common_d_lookup(long ret) libnetdata_update_u64(&fill->slow, 1); } else { data.slow = 1; + bpf_get_current_comm(&data.name, TASK_COMM_LEN); bpf_map_update_elem(&dcstat_pid, &key, &data, BPF_ANY); libnetdata_update_global(&dcstat_ctrl, NETDATA_CONTROLLER_PID_TABLE_ADD, 1); @@ -99,6 +101,7 @@ static __always_inline int netdata_common_d_lookup(long ret) libnetdata_update_u64(&fill->missed, 1); } else { data.missed = 1; + bpf_get_current_comm(&data.name, TASK_COMM_LEN); bpf_map_update_elem(&dcstat_pid, &key, &data, BPF_ANY); libnetdata_update_global(&dcstat_ctrl, NETDATA_CONTROLLER_PID_TABLE_ADD, 1); @@ -108,23 +111,6 @@ static __always_inline int netdata_common_d_lookup(long ret) return 0; } -static inline int netdata_release_task_dcstat() -{ - netdata_dc_stat_t *removeme; - __u32 key = 0; - if (netdata_dc_not_update_apps()) - return 0; - - removeme = netdata_get_pid_structure(&key, &dcstat_ctrl, &dcstat_pid); - if (removeme) { - bpf_map_delete_elem(&dcstat_pid, &key); - - libnetdata_update_global(&dcstat_ctrl, NETDATA_CONTROLLER_PID_TABLE_DEL, 1); - } - - return 0; -} - /*********************************************************************************** * * DC SECTION(kprobe) @@ -145,12 +131,6 @@ int BPF_KRETPROBE(netdata_d_lookup_kretprobe) return netdata_common_d_lookup(ret); } -SEC("kprobe/release_task") -int BPF_KPROBE(netdata_dcstat_release_task_kprobe) -{ - return netdata_release_task_dcstat(); -} - /*********************************************************************************** * * DC SECTION(trampoline) @@ -170,11 +150,5 @@ int BPF_PROG(netdata_d_lookup_fexit, const struct dentry *parent, const struct q return netdata_common_d_lookup((long)ret); } -SEC("fentry/release_task") -int BPF_PROG(netdata_dcstat_release_task_fentry) -{ - return netdata_release_task_dcstat(); -} - char _license[] SEC("license") = "GPL"; diff --git a/src/dc.c b/src/dc.c index 81cb3ca..715ee1e 100644 --- a/src/dc.c +++ b/src/dc.c @@ -16,8 +16,7 @@ #include "dc.skel.h" char *function_list[] = { "lookup_fast", - "d_lookup", - "release_task" + "d_lookup" }; // This preprocessor is defined here, because it is not useful in kernel-colector #define NETDATA_DCSTAT_RELEASE_TASK 2 @@ -26,14 +25,12 @@ static inline void ebpf_disable_probes(struct dc_bpf *obj) { bpf_program__set_autoload(obj->progs.netdata_lookup_fast_kprobe, false); bpf_program__set_autoload(obj->progs.netdata_d_lookup_kretprobe, false); - bpf_program__set_autoload(obj->progs.netdata_dcstat_release_task_kprobe, false); } static inline void ebpf_disable_trampoline(struct dc_bpf *obj) { bpf_program__set_autoload(obj->progs.netdata_lookup_fast_fentry, false); bpf_program__set_autoload(obj->progs.netdata_d_lookup_fexit, false); - bpf_program__set_autoload(obj->progs.netdata_dcstat_release_task_fentry, false); } static void ebpf_set_trampoline_target(struct dc_bpf *obj) @@ -43,9 +40,6 @@ static void ebpf_set_trampoline_target(struct dc_bpf *obj) bpf_program__set_attach_target(obj->progs.netdata_d_lookup_fexit, 0, function_list[NETDATA_D_LOOKUP]); - - bpf_program__set_attach_target(obj->progs.netdata_dcstat_release_task_fentry, 0, - function_list[NETDATA_DCSTAT_RELEASE_TASK]); } static int ebpf_attach_probes(struct dc_bpf *obj) @@ -62,13 +56,6 @@ static int ebpf_attach_probes(struct dc_bpf *obj) if (ret) return -1; - obj->links.netdata_dcstat_release_task_kprobe = bpf_program__attach_kprobe(obj->progs.netdata_dcstat_release_task_kprobe, - false, - function_list[NETDATA_DCSTAT_RELEASE_TASK]); - ret = libbpf_get_error(obj->links.netdata_lookup_fast_kprobe); - if (ret) - return -1; - return 0; } diff --git a/src/fd.bpf.c b/src/fd.bpf.c index 3829e28..c6da566 100644 --- a/src/fd.bpf.c +++ b/src/fd.bpf.c @@ -70,11 +70,7 @@ static __always_inline int netdata_apps_do_sys_openat2(long ret) libnetdata_update_u32(&fill->open_err, 1) ; } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.open_call = 1; if (ret < 0) data.open_err = 1; @@ -112,11 +108,7 @@ static __always_inline int netdata_apps_close_fd(int ret) libnetdata_update_u32(&fill->close_err, 1) ; } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.close_call = 1; if (ret < 0) data.close_err = 1; diff --git a/src/netdata_dc.h b/src/netdata_dc.h deleted file mode 100644 index 46f5414..0000000 --- a/src/netdata_dc.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef _NETDATA_DIRECTORY_CACHE_H_ -#define _NETDATA_DIRECTORY_CACHE_H_ 1 - -typedef struct netdata_dc_stat { - __u64 references; - __u64 slow; - __u64 missed; -} netdata_dc_stat_t; - -enum directory_cache_counters { - NETDATA_KEY_DC_REFERENCE, - NETDATA_KEY_DC_SLOW, - NETDATA_KEY_DC_MISS, - - // Keep this as last and don't skip numbers as it is used as element counter - NETDATA_DIRECTORY_CACHE_END -}; - -enum directory_cachec_functions { - NETDATA_LOOKUP_FAST, - NETDATA_D_LOOKUP, - - NETDATA_DC_COUNTER -}; - -#endif /* _NETDATA_DIRECTORY_CACHE_H_ */ - diff --git a/src/process.bpf.c b/src/process.bpf.c index fea4589..ce88474 100644 --- a/src/process.bpf.c +++ b/src/process.bpf.c @@ -41,11 +41,7 @@ struct { static __always_inline void netdata_fill_common_process_data(struct netdata_pid_stat_t *data) { data->ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data->name, TASK_COMM_LEN); -#else - data->name[0] = '\0'; -#endif __u64 pid_tgid = bpf_get_current_pid_tgid(); __u32 tgid = (__u32)( 0x00000000FFFFFFFF & pid_tgid); diff --git a/src/shm.bpf.c b/src/shm.bpf.c index 26a1782..cd06860 100644 --- a/src/shm.bpf.c +++ b/src/shm.bpf.c @@ -74,11 +74,7 @@ static __always_inline int netdata_update_apps(__u32 idx) netdata_update_stored_data(fill, idx); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif netdata_set_structure_value(&data, idx); bpf_map_update_elem(&tbl_pid_shm, &key, &data, BPF_ANY); diff --git a/src/socket.bpf.c b/src/socket.bpf.c index 2a17cfc..c4cf01e 100644 --- a/src/socket.bpf.c +++ b/src/socket.bpf.c @@ -117,11 +117,7 @@ static __always_inline short unsigned int set_idx_value(netdata_socket_idx_t *ns static __always_inline void update_socket_common(netdata_socket_t *data, __u16 protocol, __u16 family) { data->ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data->name, TASK_COMM_LEN); -#else - data->name[0] = '\0'; -#endif data->first = bpf_ktime_get_ns(); data->ct = data->first; diff --git a/src/swap.bpf.c b/src/swap.bpf.c index 40629eb..65809de 100644 --- a/src/swap.bpf.c +++ b/src/swap.bpf.c @@ -63,11 +63,7 @@ static __always_inline int common_readpage() libnetdata_update_u64(&fill->read, 1); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.read = 1; bpf_map_update_elem(&tbl_pid_swap, &key, &data, BPF_ANY); @@ -93,11 +89,7 @@ static __always_inline int common_writepage() libnetdata_update_u64(&fill->write, 1); } else { data.ct = bpf_ktime_get_ns(); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,11,0)) bpf_get_current_comm(&data.name, TASK_COMM_LEN); -#else - data.name[0] = '\0'; -#endif data.write = 1; bpf_map_update_elem(&tbl_pid_swap, &key, &data, BPF_ANY);