diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2023-01-27 16:31:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-27 16:31:52 +0000 |
commit | be615262a2a933d1c51aa927c83629f9c1e8a713 (patch) | |
tree | 0f035b93bc3c92c6fef1420b5dcdd85fe29abd46 /collectors/ebpf.plugin | |
parent | 081dbc6cedbc7c035d8e3bc7bcb1845db656bacf (diff) |
Improve ebpf exit (#14270)
Diffstat (limited to 'collectors/ebpf.plugin')
30 files changed, 110 insertions, 975 deletions
diff --git a/collectors/ebpf.plugin/ebpf.c b/collectors/ebpf.plugin/ebpf.c index 00761b4b7b..6349d80c19 100644 --- a/collectors/ebpf.plugin/ebpf.c +++ b/collectors/ebpf.plugin/ebpf.c @@ -483,7 +483,7 @@ static void ebpf_exit() if (unlink(filename)) error("Cannot remove PID file %s", filename); - exit(0); + ebpf_exit_plugin = 2; } /** @@ -534,7 +534,7 @@ static void ebpf_stop_threads(int sig) pthread_mutex_unlock(&ebpf_exit_cleanup); ebpf_exit_plugin = 1; - usec_t max = 3 * USEC_PER_SEC, step = 100000; + usec_t max = USEC_PER_SEC, step = 100000; while (i && max) { max -= step; sleep_usec(step); @@ -548,32 +548,35 @@ static void ebpf_stop_threads(int sig) pthread_mutex_unlock(&ebpf_exit_cleanup); } - //Unload threads(except sync and filesystem) - pthread_mutex_lock(&ebpf_exit_cleanup); - for (i = 0; ebpf_threads[i].name != NULL; i++) { - if (ebpf_threads[i].enabled == NETDATA_THREAD_EBPF_STOPPED && i != EBPF_MODULE_FILESYSTEM_IDX && - i != EBPF_MODULE_SYNC_IDX) - ebpf_unload_legacy_code(ebpf_modules[i].objects, ebpf_modules[i].probe_links); - } - pthread_mutex_unlock(&ebpf_exit_cleanup); + if (!i) { + //Unload threads(except sync and filesystem) + pthread_mutex_lock(&ebpf_exit_cleanup); + for (i = 0; ebpf_threads[i].name != NULL; i++) { + if (ebpf_threads[i].enabled == NETDATA_THREAD_EBPF_STOPPED && i != EBPF_MODULE_FILESYSTEM_IDX && + i != EBPF_MODULE_SYNC_IDX) + ebpf_unload_legacy_code(ebpf_modules[i].objects, ebpf_modules[i].probe_links); + } + pthread_mutex_unlock(&ebpf_exit_cleanup); - //Unload filesystem - pthread_mutex_lock(&ebpf_exit_cleanup); - if (ebpf_threads[EBPF_MODULE_FILESYSTEM_IDX].enabled == NETDATA_THREAD_EBPF_STOPPED) { - for (i = 0; localfs[i].filesystem != NULL; i++) { - ebpf_unload_legacy_code(localfs[i].objects, localfs[i].probe_links); + //Unload filesystem + pthread_mutex_lock(&ebpf_exit_cleanup); + if (ebpf_threads[EBPF_MODULE_FILESYSTEM_IDX].enabled == NETDATA_THREAD_EBPF_STOPPED) { + for (i = 0; localfs[i].filesystem != NULL; i++) { + ebpf_unload_legacy_code(localfs[i].objects, localfs[i].probe_links); + } } - } - pthread_mutex_unlock(&ebpf_exit_cleanup); + pthread_mutex_unlock(&ebpf_exit_cleanup); - //Unload Sync - pthread_mutex_lock(&ebpf_exit_cleanup); - if (ebpf_threads[EBPF_MODULE_SYNC_IDX].enabled == NETDATA_THREAD_EBPF_STOPPED) { - for (i = 0; local_syscalls[i].syscall != NULL; i++) { - ebpf_unload_legacy_code(local_syscalls[i].objects, local_syscalls[i].probe_links); + //Unload Sync + pthread_mutex_lock(&ebpf_exit_cleanup); + if (ebpf_threads[EBPF_MODULE_SYNC_IDX].enabled == NETDATA_THREAD_EBPF_STOPPED) { + for (i = 0; local_syscalls[i].syscall != NULL; i++) { + ebpf_unload_legacy_code(local_syscalls[i].objects, local_syscalls[i].probe_links); + } } + pthread_mutex_unlock(&ebpf_exit_cleanup); + } - pthread_mutex_unlock(&ebpf_exit_cleanup); ebpf_exit(); } @@ -2245,12 +2248,25 @@ int main(int argc, char **argv) } } - usec_t step = EBPF_DEFAULT_UPDATE_EVERY * USEC_PER_SEC; + usec_t step = USEC_PER_SEC; + int counter = NETDATA_EBPF_CGROUP_UPDATE - 1; heartbeat_t hb; heartbeat_init(&hb); //Plugin will be killed when it receives a signal - while (!ebpf_exit_plugin) { + while (ebpf_exit_plugin != 2) { (void)heartbeat_next(&hb, step); + if (ebpf_exit_plugin == 2) + break; + + // We are using a small heartbeat time to wake up thread, + // but we should not update so frequently the shared memory data + if (++counter >= NETDATA_EBPF_CGROUP_UPDATE) { + counter = 0; + if (!shm_ebpf_cgroup.header) + ebpf_map_cgroup_shared_memory(); + + ebpf_parse_cgroup_shm_data(); + } } return 0; diff --git a/collectors/ebpf.plugin/ebpf_cachestat.c b/collectors/ebpf.plugin/ebpf_cachestat.c index 62efc0b8f4..d322993d1c 100644 --- a/collectors/ebpf.plugin/ebpf_cachestat.c +++ b/collectors/ebpf.plugin/ebpf_cachestat.c @@ -15,15 +15,6 @@ netdata_cachestat_pid_t *cachestat_vector = NULL; static netdata_idx_t cachestat_hash_values[NETDATA_CACHESTAT_END]; static netdata_idx_t *cachestat_values = NULL; -struct netdata_static_thread cachestat_threads = {.name = "CACHESTAT KERNEL", - .config_section = NULL, - .config_name = NULL, - .env_name = NULL, - .enabled = 1, - .thread = NULL, - .init_routine = NULL, - .start_routine = NULL}; - ebpf_local_maps_t cachestat_maps[] = {{.name = "cstat_global", .internal_input = NETDATA_CACHESTAT_END, .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC, .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}, @@ -342,18 +333,13 @@ static inline int ebpf_cachestat_load_and_attach(struct cachestat_bpf *obj, ebpf static void ebpf_cachestat_free(ebpf_module_t *em) { pthread_mutex_lock(&ebpf_exit_cleanup); - if (em->thread->enabled == NETDATA_THREAD_EBPF_RUNNING) { - em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; - pthread_mutex_unlock(&ebpf_exit_cleanup); - return; - } + em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; pthread_mutex_unlock(&ebpf_exit_cleanup); ebpf_cleanup_publish_syscall(cachestat_counter_publish_aggregated); freez(cachestat_vector); freez(cachestat_values); - freez(cachestat_threads.thread); #ifdef LIBBPF_MAJOR_VERSION if (bpf_obj) @@ -374,21 +360,7 @@ static void ebpf_cachestat_free(ebpf_module_t *em) static void ebpf_cachestat_exit(void *ptr) { ebpf_module_t *em = (ebpf_module_t *)ptr; - if (cachestat_threads.thread) - netdata_thread_cancel(*cachestat_threads.thread); - ebpf_cachestat_free(em); -} -/** - * Cachestat cleanup - * - * Clean up allocated addresses. - * - * @param ptr thread data. - */ -static void ebpf_cachestat_cleanup(void *ptr) -{ - ebpf_module_t *em = (ebpf_module_t *)ptr; ebpf_cachestat_free(em); } @@ -668,7 +640,7 @@ void ebpf_cachestat_create_apps_charts(struct ebpf_module *em, void *ptr) * * Read the table with number of calls for all functions */ -static void read_global_table() +static void ebpf_cachestat_read_global_table() { uint32_t idx; netdata_idx_t *val = cachestat_hash_values; @@ -689,35 +661,6 @@ static void read_global_table() } /** - * Socket read hash - * - * This is the thread callback. - * This thread is necessary, because we cannot freeze the whole plugin to read the data on very busy socket. - * - * @param ptr It is a NULL value for this thread. - * - * @return It always returns NULL. - */ -void *ebpf_cachestat_read_hash(void *ptr) -{ - netdata_thread_cleanup_push(ebpf_cachestat_cleanup, ptr); - heartbeat_t hb; - heartbeat_init(&hb); - - ebpf_module_t *em = (ebpf_module_t *)ptr; - - usec_t step = NETDATA_LATENCY_CACHESTAT_SLEEP_MS * em->update_every; - while (!ebpf_exit_plugin) { - (void)heartbeat_next(&hb, step); - - read_global_table(); - } - - netdata_thread_cleanup_pop(1); - return NULL; -} - -/** * Send global * * Send global charts to Netdata @@ -1118,12 +1061,6 @@ void ebpf_cachestat_send_cgroup_data(int update_every) */ static void cachestat_collector(ebpf_module_t *em) { - cachestat_threads.thread = callocz(1, sizeof(netdata_thread_t)); - cachestat_threads.start_routine = ebpf_cachestat_read_hash; - - netdata_thread_create(cachestat_threads.thread, cachestat_threads.name, NETDATA_THREAD_OPTION_DEFAULT, - ebpf_cachestat_read_hash, em); - netdata_publish_cachestat_t publish; memset(&publish, 0, sizeof(publish)); int cgroups = em->cgroup_charts; @@ -1138,6 +1075,7 @@ static void cachestat_collector(ebpf_module_t *em) break; netdata_apps_integration_flags_t apps = em->apps_charts; + ebpf_cachestat_read_global_table(); pthread_mutex_lock(&collect_data_mutex); if (apps) read_apps_table(); diff --git a/collectors/ebpf.plugin/ebpf_cachestat.h b/collectors/ebpf.plugin/ebpf_cachestat.h index fba2772293..15b06511ec 100644 --- a/collectors/ebpf.plugin/ebpf_cachestat.h +++ b/collectors/ebpf.plugin/ebpf_cachestat.h @@ -19,8 +19,6 @@ #define EBPF_CACHESTAT_DIMENSION_HITS "hits/s" #define EBPF_CACHESTAT_DIMENSION_MISSES "misses/s" -#define NETDATA_LATENCY_CACHESTAT_SLEEP_MS 600000ULL - // configuration file #define NETDATA_CACHESTAT_CONFIG_FILE "cachestat.conf" diff --git a/collectors/ebpf.plugin/ebpf_dcstat.c b/collectors/ebpf.plugin/ebpf_dcstat.c index e8dacb4b84..d1e189d1ad 100644 --- a/collectors/ebpf.plugin/ebpf_dcstat.c +++ b/collectors/ebpf.plugin/ebpf_dcstat.c @@ -19,15 +19,6 @@ struct config dcstat_config = { .first_section = NULL, .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare }, .rwlock = AVL_LOCK_INITIALIZER } }; -struct netdata_static_thread dcstat_threads = {"DCSTAT KERNEL", - .config_section = NULL, - .config_name = NULL, - .env_name = NULL, - .enabled = 1, - .thread = NULL, - .init_routine = NULL, - .start_routine = NULL}; - ebpf_local_maps_t dcstat_maps[] = {{.name = "dcstat_global", .internal_input = NETDATA_DIRECTORY_CACHE_END, .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC, .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}, @@ -303,16 +294,11 @@ void ebpf_dcstat_clean_names() static void ebpf_dcstat_free(ebpf_module_t *em ) { pthread_mutex_lock(&ebpf_exit_cleanup); - if (em->thread->enabled == NETDATA_THREAD_EBPF_RUNNING) { - em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; - pthread_mutex_unlock(&ebpf_exit_cleanup); - return; - } + em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; pthread_mutex_unlock(&ebpf_exit_cleanup); freez(dcstat_vector); freez(dcstat_values); - freez(dcstat_threads.thread); ebpf_cleanup_publish_syscall(dcstat_counter_publish_aggregated); @@ -338,19 +324,6 @@ static void ebpf_dcstat_free(ebpf_module_t *em ) static void ebpf_dcstat_exit(void *ptr) { ebpf_module_t *em = (ebpf_module_t *)ptr; - if (dcstat_threads.thread) - netdata_thread_cancel(*dcstat_threads.thread); - ebpf_dcstat_free(em); -} - -/** - * Clean up the main thread. - * - * @param ptr thread data. - */ -static void ebpf_dcstat_cleanup(void *ptr) -{ - ebpf_module_t *em = (ebpf_module_t *)ptr; ebpf_dcstat_free(em); } @@ -539,7 +512,7 @@ static void ebpf_update_dc_cgroup() * * Read the table with number of calls for all functions */ -static void read_global_table() +static void ebpf_dc_read_global_table() { uint32_t idx; netdata_idx_t *val = dcstat_hash_values; @@ -560,35 +533,6 @@ static void read_global_table() } /** - * DCstat read hash - * - * This is the thread callback. - * This thread is necessary, because we cannot freeze the whole plugin to read the data. - * - * @param ptr It is a NULL value for this thread. - * - * @return It always returns NULL. - */ -void *ebpf_dcstat_read_hash(void *ptr) -{ - netdata_thread_cleanup_push(ebpf_dcstat_cleanup, ptr); - heartbeat_t hb; - heartbeat_init(&hb); - - ebpf_module_t *em = (ebpf_module_t *)ptr; - - usec_t step = NETDATA_LATENCY_DCSTAT_SLEEP_MS * em->update_every; - while (!ebpf_exit_plugin) { - (void)heartbeat_next(&hb, step); - - read_global_table(); - } - - netdata_thread_cleanup_pop(1); - return NULL; -} - -/** * Cachestat sum PIDs * * Sum values for all PIDs associated to a group @@ -1035,12 +979,6 @@ void ebpf_dc_send_cgroup_data(int update_every) */ static void dcstat_collector(ebpf_module_t *em) { - dcstat_threads.thread = mallocz(sizeof(netdata_thread_t)); - dcstat_threads.start_routine = ebpf_dcstat_read_hash; - - netdata_thread_create(dcstat_threads.thread, dcstat_threads.name, NETDATA_THREAD_OPTION_DEFAULT, - ebpf_dcstat_read_hash, em); - netdata_publish_dcstat_t publish; memset(&publish, 0, sizeof(publish)); int cgroups = em->cgroup_charts; @@ -1054,6 +992,7 @@ static void dcstat_collector(ebpf_module_t *em) break; netdata_apps_integration_flags_t apps = em->apps_charts; + ebpf_dc_read_global_table(); pthread_mutex_lock(&collect_data_mutex); if (apps) read_apps_table(); diff --git a/collectors/ebpf.plugin/ebpf_dcstat.h b/collectors/ebpf.plugin/ebpf_dcstat.h index d8687f9681..201fc8a029 100644 --- a/collectors/ebpf.plugin/ebpf_dcstat.h +++ b/collectors/ebpf.plugin/ebpf_dcstat.h @@ -28,8 +28,6 @@ #define NETDATA_SYSTEMD_DC_NOT_CACHE_CONTEXT "services.dc_not_cache" #define NETDATA_SYSTEMD_DC_NOT_FOUND_CONTEXT "services.dc_not_found" -#define NETDATA_LATENCY_DCSTAT_SLEEP_MS 700000ULL - enum directory_cache_indexes { NETDATA_DCSTAT_IDX_RATIO, NETDATA_DCSTAT_IDX_REFERENCE, diff --git a/collectors/ebpf.plugin/ebpf_disk.c b/collectors/ebpf.plugin/ebpf_disk.c index 1c9bb0ede9..36d260d5df 100644 --- a/collectors/ebpf.plugin/ebpf_disk.c +++ b/collectors/ebpf.plugin/ebpf_disk.c @@ -33,16 +33,6 @@ static netdata_syscall_stat_t disk_aggregated_data[NETDATA_EBPF_HIST_MAX_BINS]; static netdata_publish_syscall_t disk_publish_aggregated[NETDATA_EBPF_HIST_MAX_BINS]; static netdata_idx_t *disk_hash_values = NULL; -static struct netdata_static_thread disk_threads = { - .name = "DISK KERNEL", - .config_section = NULL, - .config_name = NULL, - .env_name = NULL, - .enabled = 1, - .thread = NULL, - .init_routine = NULL, - .start_routine = NULL -}; ebpf_publish_disk_t *plot_disks = NULL; pthread_mutex_t plot_mutex; @@ -439,11 +429,7 @@ static void ebpf_cleanup_disk_list() static void ebpf_disk_free(ebpf_module_t *em) { pthread_mutex_lock(&ebpf_exit_cleanup); - if (em->thread->enabled == NETDATA_THREAD_EBPF_RUNNING) { - em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; - pthread_mutex_unlock(&ebpf_exit_cleanup); - return; - } + em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; pthread_mutex_unlock(&ebpf_exit_cleanup); ebpf_disk_disable_tracepoints(); @@ -452,7 +438,6 @@ static void ebpf_disk_free(ebpf_module_t *em) ebpf_histogram_dimension_cleanup(dimensions, NETDATA_EBPF_HIST_MAX_BINS); freez(disk_hash_values); - freez(disk_threads.thread); pthread_mutex_destroy(&plot_mutex); ebpf_cleanup_plot_disks(); @@ -473,21 +458,6 @@ static void ebpf_disk_free(ebpf_module_t *em) static void ebpf_disk_exit(void *ptr) { ebpf_module_t *em = (ebpf_module_t *)ptr; - if (disk_threads.thread) - netdata_thread_cancel(*disk_threads.thread); - ebpf_disk_free(em); -} - -/** - * Disk Cleanup - * - * Clean up allocated memory. - * - * @param ptr thread data. - */ -static void ebpf_disk_cleanup(void *ptr) -{ - ebpf_module_t *em = (ebpf_module_t *)ptr; ebpf_disk_free(em); } @@ -593,35 +563,6 @@ static void read_hard_disk_tables(int table) } /** - * Disk read hash - * - * This is the thread callback. - * This thread is necessary, because we cannot freeze the whole plugin to read the data on very busy socket. - * - * @param ptr It is a NULL value for this thread. - * - * @return It always returns NULL. - */ -void *ebpf_disk_read_hash(void *ptr) -{ - netdata_thread_cleanup_push(ebpf_disk_cleanup, ptr); - heartbeat_t hb; - heartbeat_init(&hb); - - ebpf_module_t *em = (ebpf_module_t *)ptr; - - usec_t step = NETDATA_LATENCY_DISK_SLEEP_MS * em->update_every; - while (!ebpf_exit_plugin) { - (void)heartbeat_next(&hb, step); - - read_hard_disk_tables(disk_maps[NETDATA_DISK_READ].map_fd); - } - - netdata_thread_cleanup_pop(1); - return NULL; -} - -/** * Obsolete Hard Disk charts * * Make Hard disk charts and fill chart name @@ -744,11 +685,6 @@ static void ebpf_latency_send_hd_data(int update_every) static void disk_collector(ebpf_module_t *em) { disk_hash_values = callocz(ebpf_nprocs, sizeof(netdata_idx_t)); - disk_threads.thread = mallocz(sizeof(netdata_thread_t)); - disk_threads.start_routine = ebpf_disk_read_hash; - - netdata_thread_create(disk_threads.thread, disk_threads.name, NETDATA_THREAD_OPTION_DEFAULT, - ebpf_disk_read_hash, em); int update_every = em->update_every; heartbeat_t hb; @@ -759,6 +695,7 @@ static void disk_collector(ebpf_module_t *em) if (ebpf_exit_plugin) break; + read_hard_disk_tables(disk_maps[NETDATA_DISK_READ].map_fd); pthread_mutex_lock(&lock); ebpf_remove_pointer_from_plot_disk(em); ebpf_latency_send_hd_data(update_every); diff --git a/collectors/ebpf.plugin/ebpf_disk.h b/collectors/ebpf.plugin/ebpf_disk.h index c14b887f8c..c606d6594f 100644 --- a/collectors/ebpf.plugin/ebpf_disk.h +++ b/collectors/ebpf.plugin/ebpf_disk.h @@ -11,8 +11,6 @@ #define NETDATA_EBPF_PROC_PARTITIONS "/proc/partitions" -#define NETDATA_LATENCY_DISK_SLEEP_MS 650000ULL - // Process configuration name #define NETDATA_DISK_CONFIG_FILE "disk.conf" diff --git a/collectors/ebpf.plugin/ebpf_fd.c b/collectors/ebpf.plugin/ebpf_fd.c index 78e80b2f56..ed9880fdef 100644 --- a/collectors/ebpf.plugin/ebpf_fd.c +++ b/collectors/ebpf.plugin/ebpf_fd.c @@ -32,15 +32,6 @@ struct config fd_config = { .first_section = NULL, .last_section = NULL, .mutex .index = {.avl_tree = { .root = NULL, .compar = appconfig_section_compare }, .rwlock = AVL_LOCK_INITIALIZER } }; -struct netdata_static_thread fd_thread = {"FD KERNEL", - .config_section = NULL, - .config_name = NULL, - .env_name = NULL, - .enabled = 1, - .thread = NULL, - .init_routine = NULL, - .start_routine = NULL}; - static netdata_idx_t fd_hash_values[NETDATA_FD_COUNTER]; static netdata_idx_t *fd_values = NULL; @@ -373,15 +364,10 @@ static inline int ebpf_fd_load_and_attach(struct fd_bpf *obj, ebpf_module_t *em) static void ebpf_fd_free(ebpf_module_t *em) { pthread_mutex_lock(&ebpf_exit_cleanup); - if (em->thread->enabled == NETDATA_THREAD_EBPF_RUNNING) { - em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; - pthread_mutex_unlock(&ebpf_exit_cleanup); - return; - } + em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; pthread_mutex_unlock(&ebpf_exit_cleanup); ebpf_cleanup_publish_syscall(fd_publish_aggregated); - freez(fd_thread.thread); freez(fd_values); freez(fd_vector); @@ -405,19 +391,6 @@ static void ebpf_fd_free(ebpf_module_t *em) static void ebpf_fd_exit(void *ptr) { ebpf_module_t *em = (ebpf_module_t *)ptr; - if (fd_thread.thread) - netdata_thread_cancel(*fd_thread.thread); - ebpf_fd_free(em); -} - -/** - * Clean up the main thread. - * - * @param ptr thread data. - */ -static void ebpf_fd_cleanup(void *ptr) -{ - ebpf_module_t *em = (ebpf_module_t *)ptr; ebpf_fd_free(em); } @@ -454,7 +427,7 @@ static void ebpf_fd_send_data(ebpf_module_t *em) * * Read the table with number of calls for all functions */ -static void read_global_table() +static void ebpf_fd_read_global_table() { uint32_t idx; netdata_idx_t *val = fd_hash_values; @@ -475,34 +448,6 @@ static void read_global_table() } /** - * File descriptor read hash - * - * This is the thread callback. - * This thread is necessary, because we cannot freeze the whole plugin to read the data. - * - * @param ptr It is a NULL value for this thread. - * - * @return It always returns NULL. - */ -void *ebpf_fd_read_hash(void *ptr) -{ - netdata_thread_cleanup_push(ebpf_fd_cleanup, ptr); - heartbeat_t hb; - heartbeat_init(&hb); - - ebpf_module_t *em = (ebpf_module_t *)ptr; - usec_t step = NETDATA_FD_SLEEP_MS * em->update_every; - while (!ebpf_exit_plugin) { - (void)heartbeat_next(&hb, step); - - read_global_table(); - } - - netdata_thread_cleanup_pop(1); - return NULL; -} - -/** * Apps Accumulator * * Sum all values read from kernel and store in the first address. @@ -976,12 +921,6 @@ static void ebpf_fd_send_cgroup_data(ebpf_module_t *em) */ static void fd_collector(ebpf_module_t *em) { - fd_thread.thread = mallocz(sizeof(netdata_thread_t)); - fd_thread.start_routine = ebpf_fd_read_hash; - - netdata_thread_create(fd_thread.thread, fd_thread.name, NETDATA_THREAD_OPTION_DEFAULT, - ebpf_fd_read_hash, em); - int cgroups = em->cgroup_charts; heartbeat_t hb; heartbeat_init(&hb); @@ -992,6 +931,7 @@ static void fd_collector(ebpf_module_t *em) break; netdata_apps_integration_flags_t apps = em->apps_charts; + ebpf_fd_read_global_table(); pthread_mutex_lock(&collect_data_mutex); if (apps) read_apps_table(); diff --git a/collectors/ebpf.plugin/ebpf_fd.h b/collectors/ebpf.plugin/ebpf_fd.h index e33cad74e0..e6545d79c4 100644 --- a/collectors/ebpf.plugin/ebpf_fd.h +++ b/collectors/ebpf.plugin/ebpf_fd.h @@ -6,8 +6,6 @@ // Module name #define NETDATA_EBPF_MODULE_NAME_FD "filedescriptor" -#define NETDATA_FD_SLEEP_MS 850000ULL - // Menu group #define NETDATA_FILE_GROUP "file_access" diff --git a/collectors/ebpf.plugin/ebpf_filesystem.c b/collectors/ebpf.plugin/ebpf_filesystem.c index 3027197299..86095e837a 100644 --- a/collectors/ebpf.plugin/ebpf_filesystem.c +++ b/collectors/ebpf.plugin/ebpf_filesystem.c @@ -30,17 +30,6 @@ static ebpf_local_maps_t fs_maps[] = {{.name = "tbl_ext4", .internal_input = NET .type = NETDATA_EBPF_MAP_CONTROLLER, .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}}; -struct netdata_static_thread filesystem_threads = { - .name = "EBPF FS READ", - .config_section = NULL, - .config_name = NULL, - .env_name = NULL, - .enabled = 1, - .thread = NULL, - .init_routine = NULL, - .start_routine = NULL -}; - static netdata_syscall_stat_t filesystem_aggregated_data[NETDATA_EBPF_HIST_MAX_BINS]; static netdata_publish_syscall_t filesystem_publish_aggregated[NETDATA_EBPF_HIST_MAX_BINS]; @@ -337,14 +326,9 @@ void ebpf_filesystem_cleanup_ebpf_data() static void ebpf_filesystem_free(ebpf_module_t *em) { pthread_mutex_lock(&ebpf_exit_cleanup); - if (em->thread->enabled == NETDATA_THREAD_EBPF_RUNNING) { - em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; - pthread_mutex_unlock(&ebpf_exit_cleanup); - return; - } + em->thread->enabled = NETDATA_THREAD_EBPF_STOPPING; pthread_mutex_unlock(&ebpf_exit_cleanup); - freez(filesystem_threads.thread); ebpf_cleanup_publish_syscall(filesystem_publish_aggregated); ebpf_filesystem_cleanup_ebpf_data(); @@ -367,21 +351,6 @@ static void ebpf_filesystem_free(ebpf_module_t *em) static void ebpf_filesystem_exit(void *ptr) { ebpf_module_t *em = (ebpf_module_t *)ptr; - if (filesystem_threads.thread) - netdata_thread_cancel(*filesystem_threads.thread); - ebpf_filesystem_free(em); -} - -/** - * File system cleanup - * - * Clean up allocated thread. - * - * @param ptr thread data |