summaryrefslogtreecommitdiffstats
path: root/src/collectors/ebpf.plugin/ebpf_shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/collectors/ebpf.plugin/ebpf_shm.c')
-rw-r--r--src/collectors/ebpf.plugin/ebpf_shm.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf_shm.c b/src/collectors/ebpf.plugin/ebpf_shm.c
index ac44549b2..6282a2547 100644
--- a/src/collectors/ebpf.plugin/ebpf_shm.c
+++ b/src/collectors/ebpf.plugin/ebpf_shm.c
@@ -12,11 +12,7 @@ netdata_ebpf_shm_t *shm_vector = NULL;
static netdata_idx_t shm_hash_values[NETDATA_SHM_END];
static netdata_idx_t *shm_values = NULL;
-struct config shm_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 shm_config = APPCONFIG_INITIALIZER;
static ebpf_local_maps_t shm_maps[] = {{.name = "tbl_pid_shm", .internal_input = ND_EBPF_DEFAULT_PID_SIZE,
.user_input = 0,
@@ -569,9 +565,8 @@ static void ebpf_update_shm_cgroup()
* 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_shm_apps_table(int maps_per_core, uint32_t max_period)
+static void ebpf_read_shm_apps_table(int maps_per_core)
{
netdata_ebpf_shm_t *cv = shm_vector;
int fd = shm_maps[NETDATA_PID_SHM_TABLE].map_fd;
@@ -1063,9 +1058,6 @@ void ebpf_shm_resume_apps_data() {
*/
void *ebpf_read_shm_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;
@@ -1078,16 +1070,16 @@ void *ebpf_read_shm_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_SHM_IDX] = shm_maps[NETDATA_PID_SHM_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);
+ (void)heartbeat_next(&hb);
if (ebpf_plugin_stop() || ++counter != update_every)
continue;
pthread_mutex_lock(&collect_data_mutex);
- ebpf_read_shm_apps_table(maps_per_core, max_period);
+ ebpf_read_shm_apps_table(maps_per_core);
ebpf_shm_resume_apps_data();
pthread_mutex_unlock(&collect_data_mutex);
@@ -1113,16 +1105,17 @@ static void shm_collector(ebpf_module_t *em)
{
int cgroups = 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);
+ heartbeat_next(&hb);
+
if (ebpf_plugin_stop() || ++counter != update_every)
continue;