diff options
Diffstat (limited to 'src/collectors/ebpf.plugin/ebpf_swap.c')
-rw-r--r-- | src/collectors/ebpf.plugin/ebpf_swap.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf_swap.c b/src/collectors/ebpf.plugin/ebpf_swap.c index 933353178..3be56cfa4 100644 --- a/src/collectors/ebpf.plugin/ebpf_swap.c +++ b/src/collectors/ebpf.plugin/ebpf_swap.c @@ -12,11 +12,7 @@ static netdata_idx_t *swap_values = NULL; netdata_ebpf_swap_t *swap_vector = NULL; -struct config swap_config = { .first_section = NULL, - .last_section = NULL, - .mutex = NETDATA_MUTEX_INITIALIZER, - .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare }, - .rwlock = AVL_LOCK_INITIALIZER } }; +struct config swap_config = APPCONFIG_INITIALIZER; static ebpf_local_maps_t swap_maps[] = {{.name = "tbl_pid_swap", .internal_input = ND_EBPF_DEFAULT_PID_SIZE, .user_input = 0, @@ -543,9 +539,8 @@ void ebpf_swap_resume_apps_data() { * Read the apps table and store data inside the structure. * * @param maps_per_core do I need to read all cores? - * @param max_period limit of iterations without updates before remove data from hash table */ -static void ebpf_read_swap_apps_table(int maps_per_core, uint32_t max_period) +static void ebpf_read_swap_apps_table(int maps_per_core) { netdata_ebpf_swap_t *cv = swap_vector; int fd = swap_maps[NETDATA_PID_SWAP_TABLE].map_fd; @@ -597,9 +592,6 @@ end_swap_loop: */ void *ebpf_read_swap_thread(void *ptr) { - heartbeat_t hb; - heartbeat_init(&hb); - ebpf_module_t *em = (ebpf_module_t *)ptr; int maps_per_core = em->maps_per_core; @@ -612,17 +604,17 @@ void *ebpf_read_swap_thread(void *ptr) uint32_t lifetime = em->lifetime; uint32_t running_time = 0; - usec_t period = update_every * USEC_PER_SEC; - uint32_t max_period = EBPF_CLEANUP_FACTOR; pids_fd[EBPF_PIDS_SWAP_IDX] = swap_maps[NETDATA_PID_SWAP_TABLE].map_fd; + heartbeat_t hb; + heartbeat_init(&hb, update_every * USEC_PER_SEC); while (!ebpf_plugin_stop() && running_time < lifetime) { - (void)heartbeat_next(&hb, period); + heartbeat_next(&hb); if (ebpf_plugin_stop() || ++counter != update_every) continue; pthread_mutex_lock(&collect_data_mutex); - ebpf_read_swap_apps_table(maps_per_core, max_period); + ebpf_read_swap_apps_table(maps_per_core); ebpf_swap_resume_apps_data(); pthread_mutex_unlock(&collect_data_mutex); @@ -930,16 +922,17 @@ static void swap_collector(ebpf_module_t *em) { int cgroup = em->cgroup_charts; int update_every = em->update_every; - heartbeat_t hb; - heartbeat_init(&hb); int counter = update_every - 1; int maps_per_core = em->maps_per_core; uint32_t running_time = 0; uint32_t lifetime = em->lifetime; netdata_idx_t *stats = em->hash_table_stats; memset(stats, 0, sizeof(em->hash_table_stats)); + + heartbeat_t hb; + heartbeat_init(&hb, USEC_PER_SEC); while (!ebpf_plugin_stop() && running_time < lifetime) { - (void)heartbeat_next(&hb, USEC_PER_SEC); + (void)heartbeat_next(&hb); if (ebpf_plugin_stop() || ++counter != update_every) continue; |