@cryptotaxi247 / netdata / commits / 5b9cd0ba9

Use netdata mutex cond and lock (#20737)

replace pthread mutex and condition variables with netdata equivalents

Stelios Fragkakis committed Jul 31, 2025 at 08:29 UTC 5b9cd0ba98129be68c037d092379b3b002af51fe
27 files changed +489 -441
src/collectors/ebpf.plugin/ebpf.c
+32 -32
@@ -32,9 +32,9 @@ ND_THREAD *socket_ipc = NULL;
32 static size_t global_iterations_counter = 1;
33 bool publish_internal_metrics = true;
34
35 -pthread_mutex_t lock;
36 -pthread_mutex_t ebpf_exit_cleanup;
37 -pthread_mutex_t collect_data_mutex;
35 +netdata_mutex_t lock;
36 +netdata_mutex_t ebpf_exit_cleanup;
37 +netdata_mutex_t collect_data_mutex;
38
39 struct netdata_static_thread cgroup_integration_thread = {
40 .name = "EBPF CGROUP INT",
@@ -800,7 +800,7 @@ ebpf_sync_syscalls_t local_syscalls[] = {
800 netdata_ebpf_cgroup_shm_t shm_ebpf_cgroup = {NULL, NULL};
801 int shm_fd_ebpf_cgroup = -1;
802 sem_t *shm_sem_ebpf_cgroup = SEM_FAILED;
803 -pthread_mutex_t mutex_cgroup_shm;
803 +netdata_mutex_t mutex_cgroup_shm;
804
805 //Network viewer
806 ebpf_network_viewer_options_t network_viewer_opt;
@@ -939,12 +939,12 @@ static inline void ebpf_check_before2go()
939 sleep_usec(step);
940 i = 0;
941 int j;
942 - pthread_mutex_lock(&ebpf_exit_cleanup);
942 + netdata_mutex_lock(&ebpf_exit_cleanup);
943 for (j = 0; ebpf_modules[j].info.thread_name != NULL; j++) {
944 if (ebpf_modules[j].enabled < NETDATA_THREAD_EBPF_STOPPING)
945 i++;
946 }
947 - pthread_mutex_unlock(&ebpf_exit_cleanup);
947 + netdata_mutex_unlock(&ebpf_exit_cleanup);
948 }
949
950 if (i) {
@@ -958,12 +958,12 @@ static inline void ebpf_check_before2go()
958 static void ebpf_exit()
959 {
960 #ifdef LIBBPF_MAJOR_VERSION
961 - pthread_mutex_lock(&ebpf_exit_cleanup);
961 + netdata_mutex_lock(&ebpf_exit_cleanup);
962 if (default_btf) {
963 btf__free(default_btf);
964 default_btf = NULL;
965 }
966 - pthread_mutex_unlock(&ebpf_exit_cleanup);
966 + netdata_mutex_unlock(&ebpf_exit_cleanup);
967 #endif
968
969 char filename[FILENAME_MAX + 1];
@@ -978,12 +978,12 @@ static void ebpf_exit()
978 fflush(stdout);
979
980 ebpf_check_before2go();
981 - pthread_mutex_lock(&mutex_cgroup_shm);
981 + netdata_mutex_lock(&mutex_cgroup_shm);
982 if (shm_ebpf_cgroup.header) {
983 ebpf_unmap_cgroup_shared_memory();
984 shm_unlink(NETDATA_SHARED_MEMORY_EBPF_CGROUP_NAME);
985 }
986 - pthread_mutex_unlock(&mutex_cgroup_shm);
986 + netdata_mutex_unlock(&mutex_cgroup_shm);
987 netdata_integration_cleanup_shm();
988
989 exit(0);
@@ -1103,9 +1103,9 @@ void ebpf_stop_threads(int sig)
1103 static int only_one = 0;
1104
1105 // Child thread should be closed by itself.
1106 - pthread_mutex_lock(&ebpf_exit_cleanup);
1106 + netdata_mutex_lock(&ebpf_exit_cleanup);
1107 if (main_thread_id != gettid_cached() || only_one) {
1108 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1108 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1109 return;
1110 }
1111 only_one = 1;
@@ -1118,7 +1118,7 @@ void ebpf_stop_threads(int sig)
1118 #endif
1119 }
1120 }
1121 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1121 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1122
1123 for (i = 0; ebpf_modules[i].info.thread_name != NULL; i++) {
1124 if (ebpf_threads[i].thread)
@@ -1127,20 +1127,20 @@ void ebpf_stop_threads(int sig)
1127
1128 ebpf_plugin_exit = true;
1129
1130 - pthread_mutex_lock(&mutex_cgroup_shm);
1130 + netdata_mutex_lock(&mutex_cgroup_shm);
1131 nd_thread_signal_cancel(cgroup_integration_thread.thread);
1132 #ifdef NETDATA_DEV_MODE
1133 netdata_log_info("Sending cancel for thread %s", cgroup_integration_thread.name);
1134 #endif
1135 - pthread_mutex_unlock(&mutex_cgroup_shm);
1135 + netdata_mutex_unlock(&mutex_cgroup_shm);
1136
1137 ebpf_check_before2go();
1138
1139 - pthread_mutex_lock(&ebpf_exit_cleanup);
1139 + netdata_mutex_lock(&ebpf_exit_cleanup);
1140 ebpf_unload_unique_maps();
1141 ebpf_unload_filesystems();
1142 ebpf_unload_sync();
1143 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1143 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1144
1145 ebpf_exit();
1146 }
@@ -2423,9 +2423,9 @@ static inline void ebpf_disable_cgroups()
2423 */
2424 void ebpf_update_disabled_plugin_stats(ebpf_module_t *em)
2425 {
2426 - pthread_mutex_lock(&lock);
2426 + netdata_mutex_lock(&lock);
2427 ebpf_update_stats(&plugin_statistics, em);
2428 - pthread_mutex_unlock(&lock);
2428 + netdata_mutex_unlock(&lock);
2429 }
2430
2431 /**
@@ -2885,14 +2885,14 @@ void ebpf_read_local_addresses_unsafe()
2885 /**
2886 * Start Pthread Variable
2887 *
2888 - * This function starts all pthread variables.
2888 + * This function starts all
2889 */
2890 -void ebpf_start_pthread_variables()
2890 +static void ebpf_mutex_initialize()
2891 {
2892 - pthread_mutex_init(&lock, NULL);
2893 - pthread_mutex_init(&ebpf_exit_cleanup, NULL);
2894 - pthread_mutex_init(&collect_data_mutex, NULL);
2895 - pthread_mutex_init(&mutex_cgroup_shm, NULL);
2892 + netdata_mutex_init(&lock);
2893 + netdata_mutex_init(&ebpf_exit_cleanup);
2894 + netdata_mutex_init(&collect_data_mutex);
2895 + netdata_mutex_init(&mutex_cgroup_shm);
2896 rw_spinlock_init(&ebpf_judy_pid.index.rw_spinlock);
2897 }
2898
@@ -4362,7 +4362,7 @@ int main(int argc, char **argv)
4362 signal(SIGTERM, ebpf_stop_threads);
4363 signal(SIGPIPE, ebpf_stop_threads);
4364
4365 - ebpf_start_pthread_variables();
4365 + ebpf_mutex_initialize();
4366
4367 netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
4368 if (verify_netdata_host_prefix(true) == -1)
@@ -4422,24 +4422,24 @@ int main(int argc, char **argv)
4422 (void)heartbeat_next(&hb);
4423
4424 if (global_iterations_counter % EBPF_DEFAULT_UPDATE_EVERY == 0) {
4425 - pthread_mutex_lock(&lock);
4425 + netdata_mutex_lock(&lock);
4426 ebpf_create_statistic_charts(EBPF_DEFAULT_UPDATE_EVERY);
4427
4428 ebpf_send_statistic_data();
4429 fflush(stdout);
4430 - pthread_mutex_unlock(&lock);
4430 + netdata_mutex_unlock(&lock);
4431 }
4432
4433 if (++update_apps_list == update_apps_every) {
4434 update_apps_list = 0;
4435 - pthread_mutex_lock(&lock);
4435 + netdata_mutex_lock(&lock);
4436 if (collect_pids) {
4437 - pthread_mutex_lock(&collect_data_mutex);
4437 + netdata_mutex_lock(&collect_data_mutex);
4438 ebpf_parse_proc_files();
4439 ebpf_create_apps_charts(apps_groups_root_target);
4440 - pthread_mutex_unlock(&collect_data_mutex);
4440 + netdata_mutex_unlock(&collect_data_mutex);
4441 }
4442 - pthread_mutex_unlock(&lock);
4442 + netdata_mutex_unlock(&lock);
4443 }
4444 }
4445
src/collectors/ebpf.plugin/ebpf.h
+3 -3
@@ -183,15 +183,15 @@ void ebpf_process_thread(void *ptr);
183 void ebpf_socket_thread(void *ptr);
184
185 // Common variables
186 -extern pthread_mutex_t lock;
187 -extern pthread_mutex_t ebpf_exit_cleanup;
186 +extern netdata_mutex_t lock;
187 +extern netdata_mutex_t ebpf_exit_cleanup;
188 extern int ebpf_nprocs;
189 extern int running_on_kernel;
190 extern int isrh;
191 extern char *ebpf_plugin_dir;
192 extern int process_pid_fd;
193
194 -extern pthread_mutex_t collect_data_mutex;
194 +extern netdata_mutex_t collect_data_mutex;
195
196 // Common functions
197 void ebpf_global_labels(
src/collectors/ebpf.plugin/ebpf_cachestat.c
+26 -26
@@ -415,7 +415,7 @@ static void ebpf_obsolete_cachestat_services(ebpf_module_t *em, char *id)
415 */
416 static inline void ebpf_obsolete_cachestat_cgroup_charts(ebpf_module_t *em)
417 {
418 - pthread_mutex_lock(&mutex_cgroup_shm);
418 + netdata_mutex_lock(&mutex_cgroup_shm);
419
420 ebpf_cgroup_target_t *ect;
421 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -427,7 +427,7 @@ static inline void ebpf_obsolete_cachestat_cgroup_charts(ebpf_module_t *em)
427
428 ebpf_obsolete_specific_cachestat_charts(ect->name, em->update_every);
429 }
430 - pthread_mutex_unlock(&mutex_cgroup_shm);
430 + netdata_mutex_unlock(&mutex_cgroup_shm);
431 }
432
433 /**
@@ -499,7 +499,7 @@ void ebpf_obsolete_cachestat_apps_charts(struct ebpf_module *em)
499 {
500 struct ebpf_target *w;
501 int update_every = em->update_every;
502 - pthread_mutex_lock(&collect_data_mutex);
502 + netdata_mutex_lock(&collect_data_mutex);
503 for (w = apps_groups_root_target; w; w = w->next) {
504 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_CACHESTAT_IDX))))
505 continue;
@@ -553,7 +553,7 @@ void ebpf_obsolete_cachestat_apps_charts(struct ebpf_module *em)
553 update_every);
554 w->charts_created &= ~(1 << EBPF_MODULE_CACHESTAT_IDX);
555 }
556 - pthread_mutex_unlock(&collect_data_mutex);
556 + netdata_mutex_unlock(&collect_data_mutex);
557 }
558
559 /**
@@ -570,15 +570,15 @@ static void ebpf_cachestat_exit(void *pptr)
570 if (!em)
571 return;
572
573 - pthread_mutex_lock(&lock);
573 + netdata_mutex_lock(&lock);
574 collect_pids &= ~(1 << EBPF_MODULE_CACHESTAT_IDX);
575 - pthread_mutex_unlock(&lock);
575 + netdata_mutex_unlock(&lock);
576
577 if (ebpf_read_cachestat.thread)
578 nd_thread_signal_cancel(ebpf_read_cachestat.thread);
579
580 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
581 - pthread_mutex_lock(&lock);
581 + netdata_mutex_lock(&lock);
582 if (em->cgroup_charts) {
583 ebpf_obsolete_cachestat_cgroup_charts(em);
584 fflush(stdout);
@@ -591,7 +591,7 @@ static void ebpf_cachestat_exit(void *pptr)
591 ebpf_obsolete_cachestat_global(em);
592
593 fflush(stdout);
594 - pthread_mutex_unlock(&lock);
594 + netdata_mutex_unlock(&lock);
595 }
596
597 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -609,10 +609,10 @@ static void ebpf_cachestat_exit(void *pptr)
609 em->probe_links = NULL;
610 }
611
612 - pthread_mutex_lock(&ebpf_exit_cleanup);
612 + netdata_mutex_lock(&ebpf_exit_cleanup);
613 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
614 ebpf_update_stats(&plugin_statistics, em);
615 - pthread_mutex_unlock(&ebpf_exit_cleanup);
615 + netdata_mutex_unlock(&ebpf_exit_cleanup);
616 }
617
618 /*****************************************************************
@@ -806,7 +806,7 @@ static void ebpf_read_cachestat_apps_table(int maps_per_core)
806 static void ebpf_update_cachestat_cgroup()
807 {
808 ebpf_cgroup_target_t *ect;
809 - pthread_mutex_lock(&mutex_cgroup_shm);
809 + netdata_mutex_lock(&mutex_cgroup_shm);
810 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
811 struct pid_on_target2 *pids;
812 for (pids = ect->pids; pids; pids = pids->next) {
@@ -822,7 +822,7 @@ static void ebpf_update_cachestat_cgroup()
822 memcpy(&out->current, &in->current, sizeof(netdata_cachestat_t));
823 }
824 }
825 - pthread_mutex_unlock(&mutex_cgroup_shm);
825 + netdata_mutex_unlock(&mutex_cgroup_shm);
826 }
827
828 /**
@@ -861,14 +861,14 @@ void ebpf_cachestat_resume_apps_data()
861 {
862 struct ebpf_target *w;
863
864 - pthread_mutex_lock(&collect_data_mutex);
864 + netdata_mutex_lock(&collect_data_mutex);
865 for (w = apps_groups_root_target; w; w = w->next) {
866 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_CACHESTAT_IDX))))
867 continue;
868
869 ebpf_cachestat_sum_pids(&w->cachestat, w->root_pid);
870 }
871 - pthread_mutex_unlock(&collect_data_mutex);
871 + netdata_mutex_unlock(&collect_data_mutex);
872 }
873
874 /**
@@ -912,14 +912,14 @@ void ebpf_read_cachestat_thread(void *ptr)
912
913 counter = 0;
914
915 - pthread_mutex_lock(&ebpf_exit_cleanup);
915 + netdata_mutex_lock(&ebpf_exit_cleanup);
916 if (running_time && !em->running_time)
917 running_time = update_every;
918 else
919 running_time += update_every;
920
921 em->running_time = running_time;
922 - pthread_mutex_unlock(&ebpf_exit_cleanup);
922 + netdata_mutex_unlock(&ebpf_exit_cleanup);
923 }
924 }
925
@@ -1083,7 +1083,7 @@ void ebpf_cache_send_apps_data(struct ebpf_target *root)
1083 struct ebpf_target *w;
1084 collected_number value;
1085
1086 - pthread_mutex_lock(&collect_data_mutex);
1086 + netdata_mutex_lock(&collect_data_mutex);
1087 for (w = root; w; w = w->next) {
1088 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_CACHESTAT_IDX))))
1089 continue;
@@ -1119,7 +1119,7 @@ void ebpf_cache_send_apps_data(struct ebpf_target *root)
1119 write_chart_dimension("misses", value);
1120 ebpf_write_end_chart();
1121 }
1122 - pthread_mutex_unlock(&collect_data_mutex);
1122 + netdata_mutex_unlock(&collect_data_mutex);
1123 }
1124
1125 /**
@@ -1457,7 +1457,7 @@ static void ebpf_obsolete_specific_cachestat_charts(char *type, int update_every
1457 */
1458 void ebpf_cachestat_send_cgroup_data(int update_every)
1459 {
1460 - pthread_mutex_lock(&mutex_cgroup_shm);
1460 + netdata_mutex_lock(&mutex_cgroup_shm);
1461 ebpf_cgroup_target_t *ect;
1462 ebpf_cachestat_calc_chart_values();
1463
@@ -1488,7 +1488,7 @@ void ebpf_cachestat_send_cgroup_data(int update_every)
1488 }
1489 }
1490
1491 - pthread_mutex_unlock(&mutex_cgroup_shm);
1491 + netdata_mutex_unlock(&mutex_cgroup_shm);
1492 }
1493
1494 /**
@@ -1519,7 +1519,7 @@ static void cachestat_collector(ebpf_module_t *em)
1519 netdata_apps_integration_flags_t apps = em->apps_charts;
1520 ebpf_cachestat_read_global_tables(stats, maps_per_core);
1521
1522 - pthread_mutex_lock(&lock);
1522 + netdata_mutex_lock(&lock);
1523
1524 cachestat_send_global(&publish);
1525
@@ -1529,16 +1529,16 @@ static void cachestat_collector(ebpf_module_t *em)
1529 if (cgroups && shm_ebpf_cgroup.header)
1530 ebpf_cachestat_send_cgroup_data(update_every);
1531
1532 - pthread_mutex_unlock(&lock);
1532 + netdata_mutex_unlock(&lock);
1533
1534 - pthread_mutex_lock(&ebpf_exit_cleanup);
1534 + netdata_mutex_lock(&ebpf_exit_cleanup);
1535 if (running_time && !em->running_time)
1536 running_time = update_every;
1537 else
1538 running_time += update_every;
1539
1540 em->running_time = running_time;
1541 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1541 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1542 }
1543 }
1544
@@ -1750,12 +1750,12 @@ void ebpf_cachestat_thread(void *ptr)
1750 algorithms,
1751 NETDATA_CACHESTAT_END);
1752
1753 - pthread_mutex_lock(&lock);
1753 + netdata_mutex_lock(&lock);
1754 ebpf_update_stats(&plugin_statistics, em);
1755 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
1756 ebpf_create_memory_charts(em);
1757
1758 - pthread_mutex_unlock(&lock);
1758 + netdata_mutex_unlock(&lock);
1759
1760 ebpf_read_cachestat.thread =
1761 nd_thread_create(ebpf_read_cachestat.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_cachestat_thread, em);
src/collectors/ebpf.plugin/ebpf_cgroup.c
+2 -2
@@ -287,7 +287,7 @@ void ebpf_parse_cgroup_shm_data()
287 return;
288 }
289
290 - pthread_mutex_lock(&mutex_cgroup_shm);
290 + netdata_mutex_lock(&mutex_cgroup_shm);
291 ebpf_remove_cgroup_target_update_list();
292
293 ebpf_reset_updated_var();
@@ -302,7 +302,7 @@ void ebpf_parse_cgroup_shm_data()
302 send_cgroup_chart = previous != shm_ebpf_cgroup.header->cgroup_root_count;
303 previous = shm_ebpf_cgroup.header->cgroup_root_count;
304 sem_post(shm_sem_ebpf_cgroup);
305 - pthread_mutex_unlock(&mutex_cgroup_shm);
305 + netdata_mutex_unlock(&mutex_cgroup_shm);
306 #ifdef NETDATA_DEV_MODE
307 netdata_log_info(
308 "Updating cgroup %d (Previous: %d, Current: %d)",
src/collectors/ebpf.plugin/ebpf_dcstat.c
+26 -26
@@ -340,7 +340,7 @@ static void ebpf_obsolete_dc_services(ebpf_module_t *em, char *id)
340 */
341 static inline void ebpf_obsolete_dc_cgroup_charts(ebpf_module_t *em)
342 {
343 - pthread_mutex_lock(&mutex_cgroup_shm);
343 + netdata_mutex_lock(&mutex_cgroup_shm);
344
345 ebpf_cgroup_target_t *ect;
346 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -352,7 +352,7 @@ static inline void ebpf_obsolete_dc_cgroup_charts(ebpf_module_t *em)
352
353 ebpf_obsolete_specific_dc_charts(ect->name, em->update_every);
354 }
355 - pthread_mutex_unlock(&mutex_cgroup_shm);
355 + netdata_mutex_unlock(&mutex_cgroup_shm);
356 }
357
358 /**
@@ -366,7 +366,7 @@ void ebpf_obsolete_dc_apps_charts(struct ebpf_module *em)
366 {
367 struct ebpf_target *w;
368 int update_every = em->update_every;
369 - pthread_mutex_lock(&collect_data_mutex);
369 + netdata_mutex_lock(&collect_data_mutex);
370 for (w = apps_groups_root_target; w; w = w->next) {
371 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_DCSTAT_IDX))))
372 continue;
@@ -421,7 +421,7 @@ void ebpf_obsolete_dc_apps_charts(struct ebpf_module *em)
421
422 w->charts_created &= ~(1 << EBPF_MODULE_DCSTAT_IDX);
423 }
424 - pthread_mutex_unlock(&collect_data_mutex);
424 + netdata_mutex_unlock(&collect_data_mutex);
425 }
426
427 /**
@@ -472,15 +472,15 @@ static void ebpf_dcstat_exit(void *pptr)
472 if (!em)
473 return;
474
475 - pthread_mutex_lock(&lock);
475 + netdata_mutex_lock(&lock);
476 collect_pids &= ~(1 << EBPF_MODULE_DCSTAT_IDX);
477 - pthread_mutex_unlock(&lock);
477 + netdata_mutex_unlock(&lock);
478
479 if (ebpf_read_dcstat.thread)
480 nd_thread_signal_cancel(ebpf_read_dcstat.thread);
481
482 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
483 - pthread_mutex_lock(&lock);
483 + netdata_mutex_lock(&lock);
484 if (em->cgroup_charts) {
485 ebpf_obsolete_dc_cgroup_charts(em);
486 fflush(stdout);
@@ -493,7 +493,7 @@ static void ebpf_dcstat_exit(void *pptr)
493 ebpf_obsolete_dc_global(em);
494
495 fflush(stdout);
496 - pthread_mutex_unlock(&lock);
496 + netdata_mutex_unlock(&lock);
497 }
498
499 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -511,10 +511,10 @@ static void ebpf_dcstat_exit(void *pptr)
511 em->probe_links = NULL;
512 }
513
514 - pthread_mutex_lock(&ebpf_exit_cleanup);
514 + netdata_mutex_lock(&ebpf_exit_cleanup);
515 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
516 ebpf_update_stats(&plugin_statistics, em);
517 - pthread_mutex_unlock(&ebpf_exit_cleanup);
517 + netdata_mutex_unlock(&ebpf_exit_cleanup);
518 }
519
520 /*****************************************************************
@@ -628,7 +628,7 @@ void ebpf_dc_resume_apps_data()
628 {
629 struct ebpf_target *w;
630
631 - pthread_mutex_lock(&collect_data_mutex);
631 + netdata_mutex_lock(&collect_data_mutex);
632 for (w = apps_groups_root_target; w; w = w->next) {
633 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_DCSTAT_IDX))))
634 continue;
@@ -640,7 +640,7 @@ void ebpf_dc_resume_apps_data()
640
641 dcstat_update_publish(&w->dcstat, cache, not_found);
642 }
643 - pthread_mutex_unlock(&collect_data_mutex);
643 + netdata_mutex_unlock(&collect_data_mutex);
644 }
645
646 /**
@@ -653,7 +653,7 @@ void ebpf_dc_resume_apps_data()
653 static void ebpf_update_dc_cgroup()
654 {
655 ebpf_cgroup_target_t *ect;
656 - pthread_mutex_lock(&mutex_cgroup_shm);
656 + netdata_mutex_lock(&mutex_cgroup_shm);
657 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
658 struct pid_on_target2 *pids;
659 for (pids = ect->pids; pids; pids = pids->next) {
@@ -668,7 +668,7 @@ static void ebpf_update_dc_cgroup()
668 memcpy(out, &in->curr, sizeof(netdata_publish_dcstat_pid_t));
669 }
670 }
671 - pthread_mutex_unlock(&mutex_cgroup_shm);
671 + netdata_mutex_unlock(&mutex_cgroup_shm);
672 }
673
674 /**
@@ -713,14 +713,14 @@ void ebpf_read_dcstat_thread(void *ptr)
713
714 counter = 0;
715
716 - pthread_mutex_lock(&ebpf_exit_cleanup);
716 + netdata_mutex_lock(&ebpf_exit_cleanup);
717 if (running_time && !em->running_time)
718 running_time = update_every;
719 else
720 running_time += update_every;
721
722 em->running_time = running_time;
723 - pthread_mutex_unlock(&ebpf_exit_cleanup);
723 + netdata_mutex_unlock(&ebpf_exit_cleanup);
724 }
725 }
726
@@ -853,7 +853,7 @@ void ebpf_dcache_send_apps_data(struct ebpf_target *root)
853 struct ebpf_target *w;
854 collected_number value;
855
856 - pthread_mutex_lock(&collect_data_mutex);
856 + netdata_mutex_lock(&collect_data_mutex);
857 for (w = root; w; w = w->next) {
858 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_DCSTAT_IDX))))
859 continue;
@@ -896,7 +896,7 @@ void ebpf_dcache_send_apps_data(struct ebpf_target *root)
896 ebpf_write_end_chart();
897 w->dcstat.prev.not_found = w->dcstat.curr.not_found;
898 }
899 - pthread_mutex_unlock(&collect_data_mutex);
899 + netdata_mutex_unlock(&collect_data_mutex);
900 }
901
902 /**
@@ -1292,7 +1292,7 @@ static void ebpf_send_specific_dc_data(char *type, netdata_publish_dcstat_t *pdc
1292 */
1293 void ebpf_dc_send_cgroup_data(int update_every)
1294 {
1295 - pthread_mutex_lock(&mutex_cgroup_shm);
1295 + netdata_mutex_lock(&mutex_cgroup_shm);
1296 ebpf_cgroup_target_t *ect;
1297 ebpf_dc_calc_chart_values();
1298
@@ -1323,7 +1323,7 @@ void ebpf_dc_send_cgroup_data(int update_every)
1323 }
1324 }
1325
1326 - pthread_mutex_unlock(&mutex_cgroup_shm);
1326 + netdata_mutex_unlock(&mutex_cgroup_shm);
1327 }
1328
1329 /**
@@ -1353,7 +1353,7 @@ static void dcstat_collector(ebpf_module_t *em)
1353 netdata_apps_integration_flags_t apps = em->apps_charts;
1354 ebpf_dc_read_global_tables(stats, maps_per_core);
1355
1356 - pthread_mutex_lock(&lock);
1356 + netdata_mutex_lock(&lock);
1357
1358 dcstat_send_global(&publish);
1359
@@ -1363,16 +1363,16 @@ static void dcstat_collector(ebpf_module_t *em)
1363 if (cgroups && shm_ebpf_cgroup.header)
1364 ebpf_dc_send_cgroup_data(update_every);
1365
1366 - pthread_mutex_unlock(&lock);
1366 + netdata_mutex_unlock(&lock);
1367
1368 - pthread_mutex_lock(&ebpf_exit_cleanup);
1368 + netdata_mutex_lock(&ebpf_exit_cleanup);
1369 if (running_time && !em->running_time)
1370 running_time = update_every;
1371 else
1372 running_time += update_every;
1373
1374 em->running_time = running_time;
1375 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1375 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1376 }
1377 }
1378
@@ -1522,12 +1522,12 @@ void ebpf_dcstat_thread(void *ptr)
1522 algorithms,
1523 NETDATA_DCSTAT_IDX_END);
1524
1525 - pthread_mutex_lock(&lock);
1525 + netdata_mutex_lock(&lock);
1526 ebpf_create_dc_global_charts(em->update_every);
1527 ebpf_update_stats(&plugin_statistics, em);
1528 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
1529
1530 - pthread_mutex_unlock(&lock);
1530 + netdata_mutex_unlock(&lock);
1531
1532 ebpf_read_dcstat.thread =
1533 nd_thread_create(ebpf_read_dcstat.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_dcstat_thread, em);
src/collectors/ebpf.plugin/ebpf_disk.c
+21 -21
@@ -53,7 +53,7 @@ static netdata_publish_syscall_t disk_publish_aggregated[NETDATA_EBPF_HIST_MAX_B
53 static netdata_idx_t *disk_hash_values = NULL;
54
55 ebpf_publish_disk_t *plot_disks = NULL;
56 -pthread_mutex_t plot_mutex;
56 +netdata_mutex_t plot_mutex;
57
58 #ifdef LIBBPF_MAJOR_VERSION
59 /**
@@ -519,11 +519,11 @@ static void ebpf_disk_exit(void *pptr)
519 return;
520
521 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
522 - pthread_mutex_lock(&lock);
522 + netdata_mutex_lock(&lock);
523
524 ebpf_obsolete_disk_global(em);
525
526 - pthread_mutex_unlock(&lock);
526 + netdata_mutex_unlock(&lock);
527 fflush(stdout);
528 }
529 ebpf_disk_disable_tracepoints();
@@ -541,15 +541,15 @@ static void ebpf_disk_exit(void *pptr)
541
542 freez(disk_hash_values);
543 disk_hash_values = NULL;
544 - pthread_mutex_destroy(&plot_mutex);
544 + netdata_mutex_destroy(&plot_mutex);
545
546 ebpf_cleanup_plot_disks();
547 ebpf_cleanup_disk_list();
548
549 - pthread_mutex_lock(&ebpf_exit_cleanup);
549 + netdata_mutex_lock(&ebpf_exit_cleanup);
550 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
551 ebpf_update_stats(&plugin_statistics, em);
552 - pthread_mutex_unlock(&ebpf_exit_cleanup);
552 + netdata_mutex_unlock(&ebpf_exit_cleanup);
553 }
554
555 /*****************************************************************
@@ -565,13 +565,13 @@ static void ebpf_disk_exit(void *pptr)
565 */
566 static void ebpf_fill_plot_disks(netdata_ebpf_disks_t *ptr)
567 {
568 - pthread_mutex_lock(&plot_mutex);
568 + netdata_mutex_lock(&plot_mutex);
569 ebpf_publish_disk_t *w;
570 if (likely(plot_disks)) {
571 ebpf_publish_disk_t *move = plot_disks, *store = plot_disks;
572 while (move) {
573 if (move->plot == ptr) {
574 - pthread_mutex_unlock(&plot_mutex);
574 + netdata_mutex_unlock(&plot_mutex);
575 return;
576 }
577
@@ -586,7 +586,7 @@ static void ebpf_fill_plot_disks(netdata_ebpf_disks_t *ptr)
586 plot_disks = callocz(1, sizeof(ebpf_publish_disk_t));
587 plot_disks->plot = ptr;
588 }
589 - pthread_mutex_unlock(&plot_mutex);
589 + netdata_mutex_unlock(&plot_mutex);
590
591 ptr->flags |= NETDATA_DISK_ADDED_TO_PLOT_LIST;
592 }
@@ -726,7 +726,7 @@ static void ebpf_remove_pointer_from_plot_disk(ebpf_module_t *em)
726 {
727 time_t current_time = now_realtime_sec();
728 time_t limit = 10 * em->update_every;
729 - pthread_mutex_lock(&plot_mutex);
729 + netdata_mutex_lock(&plot_mutex);
730 ebpf_publish_disk_t *move = plot_disks, *prev = plot_disks;
731 int update_every = em->update_every;
732 while (move) {
@@ -753,7 +753,7 @@ static void ebpf_remove_pointer_from_plot_disk(ebpf_module_t *em)
753 prev = move;
754 move = move->next;
755 }
756 - pthread_mutex_unlock(&plot_mutex);
756 + netdata_mutex_unlock(&plot_mutex);
757 }
758
759 /**
@@ -765,9 +765,9 @@ static void ebpf_remove_pointer_from_plot_disk(ebpf_module_t *em)
765 */
766 static void ebpf_latency_send_hd_data(int update_every)
767 {
768 - pthread_mutex_lock(&plot_mutex);
768 + netdata_mutex_lock(&plot_mutex);
769 if (!plot_disks) {
770 - pthread_mutex_unlock(&plot_mutex);
770 + netdata_mutex_unlock(&plot_mutex);
771 return;
772 }
773
@@ -788,7 +788,7 @@ static void ebpf_latency_send_hd_data(int update_every)
788
789 move = move->next;
790 }
791 - pthread_mutex_unlock(&plot_mutex);
791 + netdata_mutex_unlock(&plot_mutex);
792 }
793
794 /**
@@ -813,22 +813,22 @@ static void disk_collector(ebpf_module_t *em)
813
814 counter = 0;
815 read_hard_disk_tables(disk_maps[NETDATA_DISK_IO].map_fd, maps_per_core);
816 - pthread_mutex_lock(&lock);
816 + netdata_mutex_lock(&lock);
817 ebpf_remove_pointer_from_plot_disk(em);
818 ebpf_latency_send_hd_data(update_every);
819
820 - pthread_mutex_unlock(&lock);
820 + netdata_mutex_unlock(&lock);
821
822 ebpf_update_disks(em);
823
824 - pthread_mutex_lock(&ebpf_exit_cleanup);
824 + netdata_mutex_lock(&ebpf_exit_cleanup);
825 if (running_time && !em->running_time)
826 running_time = update_every;
827 else
828 running_time += update_every;
829
830 em->running_time = running_time;
831 - pthread_mutex_unlock(&ebpf_exit_cleanup);
831 + netdata_mutex_unlock(&ebpf_exit_cleanup);
832 }
833 }
834
@@ -931,7 +931,7 @@ void ebpf_disk_thread(void *ptr)
931 goto enddisk;
932 }
933
934 - if (pthread_mutex_init(&plot_mutex, NULL)) {
934 + if (netdata_mutex_init(&plot_mutex)) {
935 netdata_log_error("Cannot initialize local mutex");
936 goto enddisk;
937 }
@@ -951,10 +951,10 @@ void ebpf_disk_thread(void *ptr)
951 ebpf_global_labels(
952 disk_aggregated_data, disk_publish_aggregated, dimensions, dimensions, algorithms, NETDATA_EBPF_HIST_MAX_BINS);
953
954 - pthread_mutex_lock(&lock);
954 + netdata_mutex_lock(&lock);
955 ebpf_update_stats(&plugin_statistics, em);
956 ebpf_update_kernel_memory_with_vector(&plugin_statistics, disk_maps, EBPF_ACTION_STAT_ADD);
957 - pthread_mutex_unlock(&lock);
957 + netdata_mutex_unlock(&lock);
958
959 disk_collector(em);
960
src/collectors/ebpf.plugin/ebpf_fd.c
+26 -26
@@ -428,7 +428,7 @@ static void ebpf_obsolete_fd_services(ebpf_module_t *em, char *id)
428 */
429 static inline void ebpf_obsolete_fd_cgroup_charts(ebpf_module_t *em)
430 {
431 - pthread_mutex_lock(&mutex_cgroup_shm);
431 + netdata_mutex_lock(&mutex_cgroup_shm);
432
433 ebpf_cgroup_target_t *ect;
434 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -440,7 +440,7 @@ static inline void ebpf_obsolete_fd_cgroup_charts(ebpf_module_t *em)
440
441 ebpf_obsolete_specific_fd_charts(ect->name, em);
442 }
443 - pthread_mutex_unlock(&mutex_cgroup_shm);
443 + netdata_mutex_unlock(&mutex_cgroup_shm);
444 }
445
446 /**
@@ -454,7 +454,7 @@ void ebpf_obsolete_fd_apps_charts(struct ebpf_module *em)
454 {
455 struct ebpf_target *w;
456 int update_every = em->update_every;
457 - pthread_mutex_lock(&collect_data_mutex);
457 + netdata_mutex_lock(&collect_data_mutex);
458 for (w = apps_groups_root_target; w; w = w->next) {
459 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_FD_IDX))))
460 continue;
@@ -512,7 +512,7 @@ void ebpf_obsolete_fd_apps_charts(struct ebpf_module *em)
512 }
513 w->charts_created &= ~(1 << EBPF_MODULE_FD_IDX);
514 }
515 - pthread_mutex_unlock(&collect_data_mutex);
515 + netdata_mutex_unlock(&collect_data_mutex);
516 }
517
518 /**
@@ -565,15 +565,15 @@ static void ebpf_fd_exit(void *pptr)
565 if (!em)
566 return;
567
568 - pthread_mutex_lock(&lock);
568 + netdata_mutex_lock(&lock);
569 collect_pids &= ~(1 << EBPF_MODULE_FD_IDX);
570 - pthread_mutex_unlock(&lock);
570 + netdata_mutex_unlock(&lock);
571
572 if (ebpf_read_fd.thread)
573 nd_thread_signal_cancel(ebpf_read_fd.thread);
574
575 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
576 - pthread_mutex_lock(&lock);
576 + netdata_mutex_lock(&lock);
577 if (em->cgroup_charts) {
578 ebpf_obsolete_fd_cgroup_charts(em);
579 fflush(stdout);
@@ -586,7 +586,7 @@ static void ebpf_fd_exit(void *pptr)
586 ebpf_obsolete_fd_global(em);
587
588 fflush(stdout);
589 - pthread_mutex_unlock(&lock);
589 + netdata_mutex_unlock(&lock);
590 }
591
592 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -603,10 +603,10 @@ static void ebpf_fd_exit(void *pptr)
603 em->probe_links = NULL;
604 }
605
606 - pthread_mutex_lock(&ebpf_exit_cleanup);
606 + netdata_mutex_lock(&ebpf_exit_cleanup);
607 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
608 ebpf_update_stats(&plugin_statistics, em);
609 - pthread_mutex_unlock(&ebpf_exit_cleanup);
609 + netdata_mutex_unlock(&ebpf_exit_cleanup);
610 }
611
612 /*****************************************************************
@@ -773,14 +773,14 @@ void ebpf_fd_resume_apps_data()
773 {
774 struct ebpf_target *w;
775
776 - pthread_mutex_lock(&collect_data_mutex);
776 + netdata_mutex_lock(&collect_data_mutex);
777 for (w = apps_groups_root_target; w; w = w->next) {
778 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_FD_IDX))))
779 continue;
780
781 ebpf_fd_sum_pids(&w->fd, w->root_pid);
782 }
783 - pthread_mutex_unlock(&collect_data_mutex);
783 + netdata_mutex_unlock(&collect_data_mutex);
784 }
785
786 /**
@@ -794,7 +794,7 @@ static void ebpf_update_fd_cgroup()
794 {
795 ebpf_cgroup_target_t *ect;
796
797 - pthread_mutex_lock(&mutex_cgroup_shm);
797 + netdata_mutex_lock(&mutex_cgroup_shm);
798 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
799 struct pid_on_target2 *pids;
800 for (pids = ect->pids; pids; pids = pids->next) {
@@ -810,7 +810,7 @@ static void ebpf_update_fd_cgroup()
810 memcpy(out, in, sizeof(netdata_publish_fd_stat_t));
811 }
812 }
813 - pthread_mutex_unlock(&mutex_cgroup_shm);
813 + netdata_mutex_unlock(&mutex_cgroup_shm);
814 }
815
816 /**
@@ -856,14 +856,14 @@ void ebpf_read_fd_thread(void *ptr)
856
857 counter = 0;
858
859 - pthread_mutex_lock(&ebpf_exit_cleanup);
859 + netdata_mutex_lock(&ebpf_exit_cleanup);
860 if (running_time && !em->running_time)
861 running_time = update_every;
862 else
863 running_time += update_every;
864
865 em->running_time = running_time;
866 - pthread_mutex_unlock(&ebpf_exit_cleanup);
866 + netdata_mutex_unlock(&ebpf_exit_cleanup);
867 }
868 }
869
@@ -876,7 +876,7 @@ void ebpf_read_fd_thread(void *ptr)
876 void ebpf_fd_send_apps_data(ebpf_module_t *em, struct ebpf_target *root)
877 {
878 struct ebpf_target *w;
879 - pthread_mutex_lock(&collect_data_mutex);
879 + netdata_mutex_lock(&collect_data_mutex);
880 for (w = root; w; w = w->next) {
881 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_FD_IDX))))
882 continue;
@@ -901,7 +901,7 @@ void ebpf_fd_send_apps_data(ebpf_module_t *em, struct ebpf_target *root)
901 ebpf_write_end_chart();
902 }
903 }
904 - pthread_mutex_unlock(&collect_data_mutex);
904 + netdata_mutex_unlock(&collect_data_mutex);
905 }
906
907 /**
@@ -1239,7 +1239,7 @@ static void ebpf_send_systemd_fd_charts(ebpf_module_t *em)
1239 */
1240 static void ebpf_fd_send_cgroup_data(ebpf_module_t *em)
1241 {
1242 - pthread_mutex_lock(&mutex_cgroup_shm);
1242 + netdata_mutex_lock(&mutex_cgroup_shm);
1243 ebpf_cgroup_target_t *ect;
1244 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
1245 ebpf_fd_sum_cgroup_pids(&ect->publish_systemd_fd, ect->pids);
@@ -1272,7 +1272,7 @@ static void ebpf_fd_send_cgroup_data(ebpf_module_t *em)
1272 }
1273 }
1274
1275 - pthread_mutex_unlock(&mutex_cgroup_shm);
1275 + netdata_mutex_unlock(&mutex_cgroup_shm);
1276 }
1277
1278 /**
@@ -1300,7 +1300,7 @@ static void fd_collector(ebpf_module_t *em)
1300 netdata_apps_integration_flags_t apps = em->apps_charts;
1301 ebpf_fd_read_global_tables(stats, maps_per_core);
1302
1303 - pthread_mutex_lock(&lock);
1303 + netdata_mutex_lock(&lock);
1304
1305 ebpf_fd_send_data(em);
1306
@@ -1310,16 +1310,16 @@ static void fd_collector(ebpf_module_t *em)
1310 if (cgroups && shm_ebpf_cgroup.header)
1311 ebpf_fd_send_cgroup_data(em);
1312
1313 - pthread_mutex_unlock(&lock);
1313 + netdata_mutex_unlock(&lock);
1314
1315 - pthread_mutex_lock(&ebpf_exit_cleanup);
1315 + netdata_mutex_lock(&ebpf_exit_cleanup);
1316 if (running_time && !em->running_time)
1317 running_time = update_every;
1318 else
1319 running_time += update_every;
1320
1321 em->running_time = running_time;
1322 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1322 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1323 }
1324 }
1325
@@ -1549,12 +1549,12 @@ void ebpf_fd_thread(void *ptr)
1549 ebpf_global_labels(
1550 fd_aggregated_data, fd_publish_aggregated, fd_dimension_names, fd_id_names, algorithms, NETDATA_FD_SYSCALL_END);
1551
1552 - pthread_mutex_lock(&lock);
1552 + netdata_mutex_lock(&lock);
1553 ebpf_create_fd_global_charts(em);
1554 ebpf_update_stats(&plugin_statistics, em);
1555 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
1556
1557 - pthread_mutex_unlock(&lock);
1557 + netdata_mutex_unlock(&lock);
1558
1559 ebpf_read_fd.thread = nd_thread_create(ebpf_read_fd.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_fd_thread, em);
1560
src/collectors/ebpf.plugin/ebpf_filesystem.c
+15 -15
@@ -596,7 +596,7 @@ static void ebpf_create_fs_charts(int update_every)
596 */
597 int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em)
598 {
599 - pthread_mutex_lock(&lock);
599 + netdata_mutex_lock(&lock);
600 int i;
601 const char *saved_name = em->info.thread_name;
602 uint64_t kernels = em->kernels;
@@ -615,7 +615,7 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em)
615 em->info.thread_name = saved_name;
616 em->kernels = kernels;
617 em->maps = NULL;
618 - pthread_mutex_unlock(&lock);
618 + netdata_mutex_unlock(&lock);
619 return -1;
620 }
621 }
@@ -625,12 +625,12 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em)
625 if (!efp->fs_obj) {
626 em->info.thread_name = saved_name;
627 em->kernels = kernels;
628 - pthread_mutex_unlock(&lock);
628 + netdata_mutex_unlock(&lock);
629 return -1;
630 } else if (ebpf_fs_load_and_attach(em->maps, efp->fs_obj, efp->functions, NULL)) {
631 em->info.thread_name = saved_name;
632 em->kernels = kernels;
633 - pthread_mutex_unlock(&lock);
633 + netdata_mutex_unlock(&lock);
634 return -1;
635 }
636 }
@@ -646,7 +646,7 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em)
646 efp->flags &= ~NETDATA_FILESYSTEM_LOAD_EBPF_PROGRAM;
647 }
648 em->info.thread_name = saved_name;
649 - pthread_mutex_unlock(&lock);
649 + netdata_mutex_unlock(&lock);
650 em->kernels = kernels;
651 em->maps = NULL;
652
@@ -889,11 +889,11 @@ static void ebpf_filesystem_exit(void *pptr)
889 return;
890
891 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
892 - pthread_mutex_lock(&lock);
892 + netdata_mutex_lock(&lock);
893 ebpf_obsolete_filesystem_global(em);
894
895 fflush(stdout);
896 - pthread_mutex_unlock(&lock);
896 + netdata_mutex_unlock(&lock);
897 }
898
899 ebpf_filesystem_cleanup_ebpf_data();
@@ -916,10 +916,10 @@ static void ebpf_filesystem_exit(void *pptr)
916 efp->flags = NETDATA_FILESYSTEM_FLAG_NO_PARTITION;
917 }
918
919 - pthread_mutex_lock(&ebpf_exit_cleanup);
919 + netdata_mutex_lock(&ebpf_exit_cleanup);
920 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
921 ebpf_update_stats(&plugin_statistics, em);
922 - pthread_mutex_unlock(&ebpf_exit_cleanup);
922 + netdata_mutex_unlock(&ebpf_exit_cleanup);
923 }
924
925 /*****************************************************************
@@ -1099,21 +1099,21 @@ static void filesystem_collector(ebpf_module_t *em)
1099
1100 counter = 0;
1101 ebpf_filesystem_read_hash(em);
1102 - pthread_mutex_lock(&lock);
1102 + netdata_mutex_lock(&lock);
1103
1104 ebpf_create_fs_charts(update_every);
1105 ebpf_histogram_send_data();
1106
1107 - pthread_mutex_unlock(&lock);
1107 + netdata_mutex_unlock(&lock);
1108
1109 - pthread_mutex_lock(&ebpf_exit_cleanup);
1109 + netdata_mutex_lock(&ebpf_exit_cleanup);
1110 if (running_time && !em->running_time)
1111 running_time = update_every;
1112 else
1113 running_time += update_every;
1114
1115 em->running_time = running_time;
1116 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1116 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1117 }
1118 }
1119
@@ -1196,10 +1196,10 @@ void ebpf_filesystem_thread(void *ptr)
1196 algorithms,
1197 NETDATA_EBPF_HIST_MAX_BINS);
1198
1199 - pthread_mutex_lock(&lock);
1199 + netdata_mutex_lock(&lock);
1200 ebpf_create_fs_charts(em->update_every);
1201 ebpf_update_stats(&plugin_statistics, em);
1202 - pthread_mutex_unlock(&lock);
1202 + netdata_mutex_unlock(&lock);
1203
1204 filesystem_collector(em);
1205
src/collectors/ebpf.plugin/ebpf_functions.c
+8 -8
@@ -357,7 +357,7 @@ static void ebpf_function_socket_manipulation(
357 }
358 } else if (strncmp(keyword, EBPF_FUNCTION_SOCKET_PERIOD, sizeof(EBPF_FUNCTION_SOCKET_PERIOD) - 1) == 0) {
359 name = &keyword[sizeof(EBPF_FUNCTION_SOCKET_PERIOD) - 1];
360 - pthread_mutex_lock(&ebpf_exit_cleanup);
360 + netdata_mutex_lock(&ebpf_exit_cleanup);
361 period = str2i(name);
362 if (period > 0) {
363 em->lifetime = period;
@@ -367,7 +367,7 @@ static void ebpf_function_socket_manipulation(
367 #ifdef NETDATA_DEV_MODE
368 collector_info("Lifetime modified for %u", em->lifetime);
369 #endif
370 - pthread_mutex_unlock(&ebpf_exit_cleanup);
370 + netdata_mutex_unlock(&ebpf_exit_cleanup);
371 } else if (strncmp(keyword, EBPF_FUNCTION_SOCKET_RESOLVE, sizeof(EBPF_FUNCTION_SOCKET_RESOLVE) - 1) == 0) {
372 previous = network_viewer_opt.service_resolution_enabled;
373 uint32_t resolution;
@@ -433,19 +433,19 @@ static void ebpf_function_socket_manipulation(
433 rw_spinlock_write_unlock(&ebpf_judy_pid.index.rw_spinlock);
434
435 collect_pids |= 1 << EBPF_MODULE_SOCKET_IDX;
436 - pthread_mutex_lock(&ebpf_exit_cleanup);
436 + netdata_mutex_lock(&ebpf_exit_cleanup);
437 if (ebpf_function_start_thread(em, period)) {
438 ebpf_function_error(transaction, HTTP_RESP_INTERNAL_SERVER_ERROR, "Cannot start thread.");
439 - pthread_mutex_unlock(&ebpf_exit_cleanup);
439 + netdata_mutex_unlock(&ebpf_exit_cleanup);
440 return;
441 }
442 } else {
443 - pthread_mutex_lock(&ebpf_exit_cleanup);
443 + netdata_mutex_lock(&ebpf_exit_cleanup);
444 if (period < 0)
445 em->lifetime = (em->enabled != NETDATA_THREAD_EBPF_FUNCTION_RUNNING) ? EBPF_NON_FUNCTION_LIFE_TIME :
446 EBPF_DEFAULT_LIFETIME;
447 }
448 - pthread_mutex_unlock(&ebpf_exit_cleanup);
448 + netdata_mutex_unlock(&ebpf_exit_cleanup);
449
450 BUFFER *wb = buffer_create(4096, NULL);
451 buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_NEWLINE_ON_ARRAY_ITEMS);
@@ -810,7 +810,7 @@ void ebpf_function_thread(void *ptr)
810 functions_evloop_add_function(
811 wg, EBPF_FUNCTION_SOCKET, ebpf_function_socket_manipulation, PLUGINS_FUNCTIONS_TIMEOUT_DEFAULT, NULL);
812
813 - pthread_mutex_lock(&lock);
813 + netdata_mutex_lock(&lock);
814 int i;
815 for (i = 0; i < EBPF_MODULE_FUNCTION_IDX; i++) {
816 ebpf_module_t *em = &ebpf_modules[i];
@@ -819,7 +819,7 @@ void ebpf_function_thread(void *ptr)
819
820 EBPF_PLUGIN_FUNCTIONS(em->functions.fcnt_name, em->functions.fcnt_desc, em->update_every);
821 }
822 - pthread_mutex_unlock(&lock);
822 + netdata_mutex_unlock(&lock);
823
824 heartbeat_t hb;
825 heartbeat_init(&hb, USEC_PER_SEC);
src/collectors/ebpf.plugin/ebpf_hardirq.c
+10 -10
@@ -198,11 +198,11 @@ static void hardirq_exit(void *pptr)
198 return;
199
200 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
201 - pthread_mutex_lock(&lock);
201 + netdata_mutex_lock(&lock);
202
203 ebpf_obsolete_hardirq_global(em);
204
205 - pthread_mutex_unlock(&lock);
205 + netdata_mutex_unlock(&lock);
206 fflush(stdout);
207 }
208
@@ -218,10 +218,10 @@ static void hardirq_exit(void *pptr)
218 ebpf_disable_tracepoint(&hardirq_tracepoints[i]);
219 }
220
221 - pthread_mutex_lock(&ebpf_exit_cleanup);
221 + netdata_mutex_lock(&ebpf_exit_cleanup);
222 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
223 ebpf_update_stats(&plugin_statistics, em);
224 - pthread_mutex_unlock(&ebpf_exit_cleanup);
224 + netdata_mutex_unlock(&ebpf_exit_cleanup);
225 }
226
227 /*****************************************************************
@@ -508,12 +508,12 @@ static void hardirq_collector(ebpf_module_t *em)
508 ebpf_hardirq_aral_init();
509
510 // create chart and static dims.
511 - pthread_mutex_lock(&lock);
511 + netdata_mutex_lock(&lock);
512 hardirq_create_charts(em->update_every);
513 hardirq_create_static_dims();
514 ebpf_update_stats(&plugin_statistics, em);
515 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
516 - pthread_mutex_unlock(&lock);
516 + netdata_mutex_unlock(&lock);
517
518 // loop and read from published data until ebpf plugin is closed.
519 int update_every = em->update_every;
@@ -533,7 +533,7 @@ static void hardirq_collector(ebpf_module_t *em)
533 if (hardirq_reader())
534 break;
535
536 - pthread_mutex_lock(&lock);
536 + netdata_mutex_lock(&lock);
537
538 // write dims now for all hitherto discovered IRQs.
539 ebpf_write_begin_chart(NETDATA_EBPF_SYSTEM_GROUP, "hardirq_latency", "");
@@ -541,16 +541,16 @@ static void hardirq_collector(ebpf_module_t *em)
541 hardirq_write_static_dims();
542 ebpf_write_end_chart();
543
544 - pthread_mutex_unlock(&lock);
544 + netdata_mutex_unlock(&lock);
545
546 - pthread_mutex_lock(&ebpf_exit_cleanup);
546 + netdata_mutex_lock(&ebpf_exit_cleanup);
547 if (running_time && !em->running_time)
548 running_time = update_every;
549 else
550 running_time += update_every;
551
552 em->running_time = running_time;
553 - pthread_mutex_unlock(&ebpf_exit_cleanup);
553 + netdata_mutex_unlock(&ebpf_exit_cleanup);
554 }
555 }
556
src/collectors/ebpf.plugin/ebpf_mdflush.c
+10 -10
@@ -156,11 +156,11 @@ static void mdflush_exit(void *pptr)
156 return;
157
158 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
159 - pthread_mutex_lock(&lock);
159 + netdata_mutex_lock(&lock);
160
161 ebpf_obsolete_mdflush_global(em);
162
163 - pthread_mutex_unlock(&lock);
163 + netdata_mutex_unlock(&lock);
164 fflush(stdout);
165 }
166
@@ -172,10 +172,10 @@ static void mdflush_exit(void *pptr)
172 em->probe_links = NULL;
173 }
174
175 - pthread_mutex_lock(&ebpf_exit_cleanup);
175 + netdata_mutex_lock(&ebpf_exit_cleanup);
176 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
177 ebpf_update_stats(&plugin_statistics, em);
178 - pthread_mutex_unlock(&ebpf_exit_cleanup);
178 + netdata_mutex_unlock(&ebpf_exit_cleanup);
179 }
180
181 /**
@@ -321,11 +321,11 @@ static void mdflush_collector(ebpf_module_t *em)
321 avl_init_lock(&mdflush_pub, mdflush_val_cmp);
322
323 // create chart and static dims.
324 - pthread_mutex_lock(&lock);
324 + netdata_mutex_lock(&lock);
325 mdflush_create_charts(update_every);
326 ebpf_update_stats(&plugin_statistics, em);
327 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
328 - pthread_mutex_unlock(&lock);
328 + netdata_mutex_unlock(&lock);
329
330 // loop and read from published data until ebpf plugin is closed.
331 int counter = update_every - 1;
@@ -342,22 +342,22 @@ static void mdflush_collector(ebpf_module_t *em)
342
343 counter = 0;
344 mdflush_read_count_map(maps_per_core);
345 - pthread_mutex_lock(&lock);
345 + netdata_mutex_lock(&lock);
346 // write dims now for all hitherto discovered devices.
347 ebpf_write_begin_chart("mdstat", "mdstat_flush", "");
348 avl_traverse_lock(&mdflush_pub, mdflush_write_dims, NULL);
349 ebpf_write_end_chart();
350
351 - pthread_mutex_unlock(&lock);
351 + netdata_mutex_unlock(&lock);
352
353 - pthread_mutex_lock(&ebpf_exit_cleanup);
353 + netdata_mutex_lock(&ebpf_exit_cleanup);
354 if (running_time && !em->running_time)
355 running_time = update_every;
356 else
357 running_time += update_every;
358
359 em->running_time = running_time;
360 - pthread_mutex_unlock(&ebpf_exit_cleanup);
360 + netdata_mutex_unlock(&ebpf_exit_cleanup);
361 }
362 }
363
src/collectors/ebpf.plugin/ebpf_mount.c
+10 -10
@@ -265,12 +265,12 @@ static void ebpf_mount_exit(void *pptr)
265 return;
266
267 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
268 - pthread_mutex_lock(&lock);
268 + netdata_mutex_lock(&lock);
269
270 ebpf_obsolete_mount_global(em);
271
272 fflush(stdout);
273 - pthread_mutex_unlock(&lock);
273 + netdata_mutex_unlock(&lock);
274 }
275
276 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -287,10 +287,10 @@ static void ebpf_mount_exit(void *pptr)
287 em->probe_links = NULL;
288 }
289
290 - pthread_mutex_lock(&ebpf_exit_cleanup);
290 + netdata_mutex_lock(&ebpf_exit_cleanup);
291 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
292 ebpf_update_stats(&plugin_statistics, em);
293 - pthread_mutex_unlock(&ebpf_exit_cleanup);
293 + netdata_mutex_unlock(&ebpf_exit_cleanup);
294 }
295
296 /*****************************************************************
@@ -381,20 +381,20 @@ static void mount_collector(ebpf_module_t *em)
381
382 counter = 0;
383 ebpf_mount_read_global_table(maps_per_core);
384 - pthread_mutex_lock(&lock);
384 + netdata_mutex_lock(&lock);
385
386 ebpf_mount_send_data();
387
388 - pthread_mutex_unlock(&lock);
388 + netdata_mutex_unlock(&lock);
389
390 - pthread_mutex_lock(&ebpf_exit_cleanup);
390 + netdata_mutex_lock(&ebpf_exit_cleanup);
391 if (running_time && !em->running_time)
392 running_time = update_every;
393 else
394 running_time += update_every;
395
396 em->running_time = running_time;
397 - pthread_mutex_unlock(&ebpf_exit_cleanup);
397 + netdata_mutex_unlock(&ebpf_exit_cleanup);
398 }
399 }
400
@@ -521,11 +521,11 @@ void ebpf_mount_thread(void *ptr)
521 algorithms,
522 NETDATA_EBPF_MOUNT_SYSCALL);
523
524 - pthread_mutex_lock(&lock);
524 + netdata_mutex_lock(&lock);
525 ebpf_create_mount_charts(em->update_every);
526 ebpf_update_stats(&plugin_statistics, em);
527 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
528 - pthread_mutex_unlock(&lock);
528 + netdata_mutex_unlock(&lock);
529
530 mount_collector(em);
531
src/collectors/ebpf.plugin/ebpf_oomkill.c
+26 -26
@@ -68,7 +68,7 @@ static void ebpf_obsolete_oomkill_services(ebpf_module_t *em, char *id)
68 */
69 static inline void ebpf_obsolete_oomkill_cgroup_charts(ebpf_module_t *em)
70 {
71 - pthread_mutex_lock(&mutex_cgroup_shm);
71 + netdata_mutex_lock(&mutex_cgroup_shm);
72
73 ebpf_cgroup_target_t *ect;
74 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -80,7 +80,7 @@ static inline void ebpf_obsolete_oomkill_cgroup_charts(ebpf_module_t *em)
80
81 ebpf_obsolete_specific_oomkill_charts(ect->name, em->update_every);
82 }
83 - pthread_mutex_unlock(&mutex_cgroup_shm);
83 + netdata_mutex_unlock(&mutex_cgroup_shm);
84 }
85
86 /**
@@ -94,7 +94,7 @@ static void ebpf_obsolete_oomkill_apps(ebpf_module_t *em)
94 {
95 struct ebpf_target *w;
96 int update_every = em->update_every;
97 - pthread_mutex_lock(&collect_data_mutex);
97 + netdata_mutex_lock(&collect_data_mutex);
98 for (w = apps_groups_root_target; w; w = w->next) {
99 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_OOMKILL_IDX))))
100 continue;
@@ -113,7 +113,7 @@ static void ebpf_obsolete_oomkill_apps(ebpf_module_t *em)
113
114 w->charts_created &= ~(1 << EBPF_MODULE_OOMKILL_IDX);
115 }
116 - pthread_mutex_unlock(&collect_data_mutex);
116 + netdata_mutex_unlock(&collect_data_mutex);
117 }
118
119 /**
@@ -127,12 +127,12 @@ static void oomkill_cleanup(void *pptr)
127 if (!em)
128 return;
129
130 - pthread_mutex_lock(&lock);
130 + netdata_mutex_lock(&lock);
131 collect_pids &= ~(1 << EBPF_MODULE_OOMKILL_IDX);
132 - pthread_mutex_unlock(&lock);
132 + netdata_mutex_unlock(&lock);
133
134 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
135 - pthread_mutex_lock(&lock);
135 + netdata_mutex_lock(&lock);
136
137 if (em->cgroup_charts) {
138 ebpf_obsolete_oomkill_cgroup_charts(em);
@@ -141,7 +141,7 @@ static void oomkill_cleanup(void *pptr)
141 ebpf_obsolete_oomkill_apps(em);
142
143 fflush(stdout);
144 - pthread_mutex_unlock(&lock);
144 + netdata_mutex_unlock(&lock);
145 }
146
147 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -152,10 +152,10 @@ static void oomkill_cleanup(void *pptr)
152 em->probe_links = NULL;
153 }
154
155 - pthread_mutex_lock(&ebpf_exit_cleanup);
155 + netdata_mutex_lock(&ebpf_exit_cleanup);
156 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
157 ebpf_update_stats(&plugin_statistics, em);
158 - pthread_mutex_unlock(&ebpf_exit_cleanup);
158 + netdata_mutex_unlock(&ebpf_exit_cleanup);
159 }
160
161 static void oomkill_write_data(int32_t *keys, uint32_t total)
@@ -163,7 +163,7 @@ static void oomkill_write_data(int32_t *keys, uint32_t total)
163 // for each app, see if it was OOM killed. record as 1 if so otherwise 0.
164 struct ebpf_target *w;
165 uint32_t used_pid = 0;
166 - pthread_mutex_lock(&collect_data_mutex);
166 + netdata_mutex_lock(&collect_data_mutex);
167 for (w = apps_groups_root_target; w != NULL; w = w->next) {
168 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_OOMKILL_IDX))))
169 continue;
@@ -203,7 +203,7 @@ static void oomkill_write_data(int32_t *keys, uint32_t total)
203 ebpf_write_end_chart();
204 }
205
206 - pthread_mutex_unlock(&collect_data_mutex);
206 + netdata_mutex_unlock(&collect_data_mutex);
207 }
208
209 /**
@@ -333,7 +333,7 @@ static void ebpf_obsolete_specific_oomkill_charts(char *type, int update_every)
333 */
334 void ebpf_oomkill_send_cgroup_data(int update_every)
335 {
336 - pthread_mutex_lock(&mutex_cgroup_shm);
336 + netdata_mutex_lock(&mutex_cgroup_shm);
337 ebpf_cgroup_target_t *ect;
338
339 if (shm_ebpf_cgroup.header->systemd_enabled) {
@@ -362,7 +362,7 @@ void ebpf_oomkill_send_cgroup_data(int update_every)
362 }
363 }
364
365 - pthread_mutex_unlock(&mutex_cgroup_shm);
365 + netdata_mutex_unlock(&mutex_cgroup_shm);
366 }
367
368 /**
@@ -416,7 +416,7 @@ static uint32_t oomkill_read_data(int32_t *keys)
416 static void ebpf_update_oomkill_cgroup(int32_t *keys, uint32_t total)
417 {
418 ebpf_cgroup_target_t *ect;
419 - pthread_mutex_lock(&mutex_cgroup_shm);
419 + netdata_mutex_lock(&mutex_cgroup_shm);
420 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
421 ect->oomkill = 0;
422 struct pid_on_target2 *pids;
@@ -431,7 +431,7 @@ static void ebpf_update_oomkill_cgroup(int32_t *keys, uint32_t total)
431 }
432 }
433 }
434 - pthread_mutex_unlock(&mutex_cgroup_shm);
434 + netdata_mutex_unlock(&mutex_cgroup_shm);
435 }
436
437 /**
@@ -446,14 +446,14 @@ static void ebpf_update_oomkill_cgroup(int32_t *keys, uint32_t total)
446 */
447 static int ebpf_update_oomkill_period(int running_time, ebpf_module_t *em)
448 {
449 - pthread_mutex_lock(&ebpf_exit_cleanup);
449 + netdata_mutex_lock(&ebpf_exit_cleanup);
450 if (running_time && !em->running_time)
451 running_time = em->update_every;
452 else
453 running_time += em->update_every;
454
455 em->running_time = running_time;
456 - pthread_mutex_unlock(&ebpf_exit_cleanup);
456 + netdata_mutex_unlock(&ebpf_exit_cleanup);
457
458 return running_time;
459 }
@@ -493,7 +493,7 @@ static void oomkill_collector(ebpf_module_t *em)
493 ebpf_update_oomkill_cgroup(keys, count);
494
495 netdata_apps_integration_flags_t apps = em->apps_charts;
496 - pthread_mutex_lock(&lock);
496 + netdata_mutex_lock(&lock);
497 // write everything from the ebpf map.
498 if (cgroups && shm_ebpf_cgroup.header)
499 ebpf_oomkill_send_cgroup_data(update_every);
@@ -501,7 +501,7 @@ static void oomkill_collector(ebpf_module_t *em)
501 if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
502 oomkill_write_data(keys, count);
503
504 - pthread_mutex_unlock(&lock);
504 + netdata_mutex_unlock(&lock);
505
506 running_time = ebpf_update_oomkill_period(running_time, em);
507 }
@@ -567,17 +567,17 @@ void ebpf_oomkill_thread(void *ptr)
567 if (unlikely(!em->apps_charts)) {
568 // When we are not running integration with apps, we won't fill necessary variables for this thread to run, so
569 // we need to disable it.
570 - pthread_mutex_lock(&ebpf_exit_cleanup);
570 + netdata_mutex_lock(&ebpf_exit_cleanup);
571 if (em->enabled)
572 netdata_log_info("%s apps integration is completely disabled.", NETDATA_DEFAULT_OOM_DISABLED_MSG);
573 - pthread_mutex_unlock(&ebpf_exit_cleanup);
573 + netdata_mutex_unlock(&ebpf_exit_cleanup);
574
575 goto endoomkill;
576 } else if (running_on_kernel < NETDATA_EBPF_KERNEL_4_14) {
577 - pthread_mutex_lock(&ebpf_exit_cleanup);
577 + netdata_mutex_lock(&ebpf_exit_cleanup);
578 if (em->enabled)
579 netdata_log_info("%s kernel does not have necessary tracepoints.", NETDATA_DEFAULT_OOM_DISABLED_MSG);
580 - pthread_mutex_unlock(&ebpf_exit_cleanup);
580 + netdata_mutex_unlock(&ebpf_exit_cleanup);
581
582 goto endoomkill;
583 }
@@ -594,10 +594,10 @@ void ebpf_oomkill_thread(void *ptr)
594 goto endoomkill;
595 }
596
597 - pthread_mutex_lock(&lock);
597 + netdata_mutex_lock(&lock);
598 ebpf_update_stats(&plugin_statistics, em);
599 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
600 - pthread_mutex_unlock(&lock);
600 + netdata_mutex_unlock(&lock);
601
602 oomkill_collector(em);
603
src/collectors/ebpf.plugin/ebpf_process.c
+28 -28
@@ -240,7 +240,7 @@ static void ebpf_read_process_hash_global_tables(netdata_idx_t *stats, int maps_
240 static void ebpf_update_process_cgroup()
241 {
242 ebpf_cgroup_target_t *ect;
243 - pthread_mutex_lock(&mutex_cgroup_shm);
243 + netdata_mutex_lock(&mutex_cgroup_shm);
244 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
245 struct pid_on_target2 *pids;
246 for (pids = ect->pids; pids; pids = pids->next) {
@@ -256,7 +256,7 @@ static void ebpf_update_process_cgroup()
256 memcpy(out, in, sizeof(ebpf_publish_process_t));
257 }
258 }
259 - pthread_mutex_unlock(&mutex_cgroup_shm);
259 + netdata_mutex_unlock(&mutex_cgroup_shm);
260 }
261
262 /*****************************************************************
@@ -552,7 +552,7 @@ static void ebpf_obsolete_process_services(ebpf_module_t *em, char *id)
552 */
553 static inline void ebpf_obsolete_process_cgroup_charts(ebpf_module_t *em)
554 {
555 - pthread_mutex_lock(&mutex_cgroup_shm);
555 + netdata_mutex_lock(&mutex_cgroup_shm);
556
557 ebpf_cgroup_target_t *ect;
558 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -564,7 +564,7 @@ static inline void ebpf_obsolete_process_cgroup_charts(ebpf_module_t *em)
564
565 ebpf_obsolete_specific_process_charts(ect->name, em);
566 }
567 - pthread_mutex_unlock(&mutex_cgroup_shm);
567 + netdata_mutex_unlock(&mutex_cgroup_shm);
568 }
569
570 /**
@@ -746,12 +746,12 @@ static void ebpf_process_exit(void *pptr)
746 if (!em)
747 return;
748
749 - pthread_mutex_lock(&lock);
749 + netdata_mutex_lock(&lock);
750 collect_pids &= ~(1 << EBPF_MODULE_PROCESS_IDX);
751 - pthread_mutex_unlock(&lock);
751 + netdata_mutex_unlock(&lock);
752
753 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
754 - pthread_mutex_lock(&lock);
754 + netdata_mutex_lock(&lock);
755 if (em->cgroup_charts) {
756 ebpf_obsolete_process_cgroup_charts(em);
757 fflush(stdout);
@@ -764,7 +764,7 @@ static void ebpf_process_exit(void *pptr)
764 ebpf_obsolete_process_global(em);
765
766 fflush(stdout);
767 - pthread_mutex_unlock(&lock);
767 + netdata_mutex_unlock(&lock);
768 }
769
770 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -780,11 +780,11 @@ static void ebpf_process_exit(void *pptr)
780
781 ebpf_process_disable_tracepoints();
782
783 - pthread_mutex_lock(&ebpf_exit_cleanup);
783 + netdata_mutex_lock(&ebpf_exit_cleanup);
784 process_pid_fd = -1;
785 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
786 ebpf_update_stats(&plugin_statistics, em);
787 - pthread_mutex_unlock(&ebpf_exit_cleanup);
787 + netdata_mutex_unlock(&ebpf_exit_cleanup);
788 }
789
790 /*****************************************************************
@@ -1185,7 +1185,7 @@ static void ebpf_send_systemd_process_charts(ebpf_module_t *em)
1185 */
1186 static void ebpf_process_send_cgroup_data(ebpf_module_t *em)
1187 {
1188 - pthread_mutex_lock(&mutex_cgroup_shm);
1188 + netdata_mutex_lock(&mutex_cgroup_shm);
1189 ebpf_cgroup_target_t *ect;
1190 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
1191 ebpf_process_sum_cgroup_pids(&ect->publish_systemd_ps, ect->pids);
@@ -1218,7 +1218,7 @@ static void ebpf_process_send_cgroup_data(ebpf_module_t *em)
1218 }
1219 }
1220
1221 - pthread_mutex_unlock(&mutex_cgroup_shm);
1221 + netdata_mutex_unlock(&mutex_cgroup_shm);
1222 }
1223
1224 /**
@@ -1361,9 +1361,9 @@ static void process_collector(ebpf_module_t *em)
1361 {
1362 int publish_global = em->global_charts;
1363 int cgroups = em->cgroup_charts;
1364 - pthread_mutex_lock(&ebpf_exit_cleanup);
1364 + netdata_mutex_lock(&ebpf_exit_cleanup);
1365 process_pid_fd = process_maps[NETDATA_PROCESS_PID_TABLE].map_fd;
1366 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1366 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1367 if (cgroups)
1368 ebpf_process_update_cgroup_algorithm();
1369
@@ -1392,23 +1392,23 @@ static void process_collector(ebpf_module_t *em)
1392
1393 if (ebpf_all_pids_count > 0) {
1394 sem_wait(shm_mutex_ebpf_integration);
1395 - pthread_mutex_lock(&collect_data_mutex);
1395 + netdata_mutex_lock(&collect_data_mutex);
1396 collect_data_for_all_processes(process_pid_fd, process_maps_per_core);
1397
1398 if (cgroups && shm_ebpf_cgroup.header) {
1399 ebpf_update_process_cgroup();
1400 }
1401 - pthread_mutex_unlock(&collect_data_mutex);
1401 + netdata_mutex_unlock(&collect_data_mutex);
1402 sem_post(shm_mutex_ebpf_integration);
1403 }
1404
1405 - pthread_mutex_lock(&lock);
1405 + netdata_mutex_lock(&lock);
1406
1407 if (publish_global) {
1408 ebpf_process_send_data(em);
1409 }
1410
1411 - pthread_mutex_lock(&collect_data_mutex);
1411 + netdata_mutex_lock(&collect_data_mutex);
1412 if (apps_enabled & NETDATA_EBPF_APPS_FLAG_CHART_CREATED) {
1413 ebpf_process_send_apps_data(apps_groups_root_target, em);
1414 }
@@ -1417,17 +1417,17 @@ static void process_collector(ebpf_module_t *em)
1417 ebpf_process_send_cgroup_data(em);
1418 }
1419
1420 - pthread_mutex_unlock(&collect_data_mutex);
1421 - pthread_mutex_unlock(&lock);
1420 + netdata_mutex_unlock(&collect_data_mutex);
1421 + netdata_mutex_unlock(&lock);
1422
1423 - pthread_mutex_lock(&ebpf_exit_cleanup);
1423 + netdata_mutex_lock(&ebpf_exit_cleanup);
1424 if (running_time && !em->running_time)
1425 running_time = update_every;
1426 else
1427 running_time += update_every;
1428
1429 em->running_time = running_time;
1430 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1430 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1431 }
1432
1433 fflush(stdout);
@@ -1533,13 +1533,13 @@ void ebpf_process_thread(void *ptr)
1533
1534 em->maps = process_maps;
1535
1536 - pthread_mutex_lock(&ebpf_exit_cleanup);
1536 + netdata_mutex_lock(&ebpf_exit_cleanup);
1537 if (ebpf_process_enable_tracepoints()) {
1538 em->enabled = em->global_charts = em->apps_charts = em->cgroup_charts = NETDATA_THREAD_EBPF_STOPPING;
1539 }
1540 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1540 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1541
1542 - pthread_mutex_lock(&lock);
1542 + netdata_mutex_lock(&lock);
1543 ebpf_process_allocate_global_vectors(NETDATA_KEY_PUBLISH_PROCESS_END);
1544
1545 ebpf_update_pid_table(&process_maps[0], em);
@@ -1566,11 +1566,11 @@ void ebpf_process_thread(void *ptr)
1566 ebpf_update_stats(&plugin_statistics, em);
1567 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
1568
1569 - pthread_mutex_unlock(&lock);
1569 + netdata_mutex_unlock(&lock);
1570
1571 process_collector(em);
1572
1573 - pthread_mutex_lock(&ebpf_exit_cleanup);
1573 + netdata_mutex_lock(&ebpf_exit_cleanup);
1574 ebpf_update_disabled_plugin_stats(em);
1575 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1575 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1576 }
src/collectors/ebpf.plugin/ebpf_shm.c
+26 -26
@@ -337,7 +337,7 @@ static void ebpf_obsolete_shm_services(ebpf_module_t *em, char *id)
337 */
338 static inline void ebpf_obsolete_shm_cgroup_charts(ebpf_module_t *em)
339 {
340 - pthread_mutex_lock(&mutex_cgroup_shm);
340 + netdata_mutex_lock(&mutex_cgroup_shm);
341
342 ebpf_cgroup_target_t *ect;
343 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -349,7 +349,7 @@ static inline void ebpf_obsolete_shm_cgroup_charts(ebpf_module_t *em)
349
350 ebpf_obsolete_specific_shm_charts(ect->name, em->update_every);
351 }
352 - pthread_mutex_unlock(&mutex_cgroup_shm);
352 + netdata_mutex_unlock(&mutex_cgroup_shm);
353 }
354
355 /**
@@ -363,7 +363,7 @@ void ebpf_obsolete_shm_apps_charts(struct ebpf_module *em)
363 {
364 struct ebpf_target *w;
365 int update_every = em->update_every;
366 - pthread_mutex_lock(&collect_data_mutex);
366 + netdata_mutex_lock(&collect_data_mutex);
367 for (w = apps_groups_root_target; w; w = w->next) {
368 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SHM_IDX))))
369 continue;
@@ -418,7 +418,7 @@ void ebpf_obsolete_shm_apps_charts(struct ebpf_module *em)
418
419 w->charts_created &= ~(1 << EBPF_MODULE_SHM_IDX);
420 }
421 - pthread_mutex_unlock(&collect_data_mutex);
421 + netdata_mutex_unlock(&collect_data_mutex);
422 }
423
424 /**
@@ -456,15 +456,15 @@ static void ebpf_shm_exit(void *pptr)
456 if (!em)
457 return;
458
459 - pthread_mutex_lock(&lock);
459 + netdata_mutex_lock(&lock);
460 collect_pids &= ~(1 << EBPF_MODULE_SHM_IDX);
461 - pthread_mutex_unlock(&lock);
461 + netdata_mutex_unlock(&lock);
462
463 if (ebpf_read_shm.thread)
464 nd_thread_signal_cancel(ebpf_read_shm.thread);
465
466 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
467 - pthread_mutex_lock(&lock);
467 + netdata_mutex_lock(&lock);
468 if (em->cgroup_charts) {
469 ebpf_obsolete_shm_cgroup_charts(em);
470 fflush(stdout);
@@ -477,7 +477,7 @@ static void ebpf_shm_exit(void *pptr)
477 ebpf_obsolete_shm_global(em);
478
479 fflush(stdout);
480 - pthread_mutex_unlock(&lock);
480 + netdata_mutex_unlock(&lock);
481 }
482
483 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -495,10 +495,10 @@ static void ebpf_shm_exit(void *pptr)
495 em->probe_links = NULL;
496 }
497
498 - pthread_mutex_lock(&ebpf_exit_cleanup);
498 + netdata_mutex_lock(&ebpf_exit_cleanup);
499 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
500 ebpf_update_stats(&plugin_statistics, em);
501 - pthread_mutex_unlock(&ebpf_exit_cleanup);
501 + netdata_mutex_unlock(&ebpf_exit_cleanup);
502 }
503
504 /*****************************************************************
@@ -549,7 +549,7 @@ static void ebpf_update_shm_cgroup()
549
550 memset(cv, 0, length);
551
552 - pthread_mutex_lock(&mutex_cgroup_shm);
552 + netdata_mutex_lock(&mutex_cgroup_shm);
553 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
554 struct pid_on_target2 *pids;
555 for (pids = ect->pids; pids; pids = pids->next) {
@@ -564,7 +564,7 @@ static void ebpf_update_shm_cgroup()
564 memcpy(out, in, sizeof(netdata_publish_shm_t));
565 }
566 }
567 - pthread_mutex_unlock(&mutex_cgroup_shm);
567 + netdata_mutex_unlock(&mutex_cgroup_shm);
568 }
569
570 /**
@@ -686,7 +686,7 @@ static void ebpf_shm_sum_pids(netdata_publish_shm_t *shm, struct ebpf_pid_on_tar
686 void ebpf_shm_send_apps_data(struct ebpf_target *root)
687 {
688 struct ebpf_target *w;
689 - pthread_mutex_lock(&collect_data_mutex);
689 + netdata_mutex_lock(&collect_data_mutex);
690 for (w = root; w; w = w->next) {
691 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SHM_IDX))))
692 continue;
@@ -707,7 +707,7 @@ void ebpf_shm_send_apps_data(struct ebpf_target *root)
707 write_chart_dimension("calls", (long long)w->shm.ctl);
708 ebpf_write_end_chart();
709 }
710 - pthread_mutex_unlock(&collect_data_mutex);
710 + netdata_mutex_unlock(&collect_data_mutex);
711 }
712
713 /**
@@ -1017,7 +1017,7 @@ static void ebpf_send_specific_shm_data(char *type, netdata_publish_shm_t *value
1017 */
1018 void ebpf_shm_send_cgroup_data(int update_every)
1019 {
1020 - pthread_mutex_lock(&mutex_cgroup_shm);
1020 + netdata_mutex_lock(&mutex_cgroup_shm);
1021 ebpf_cgroup_target_t *ect;
1022 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
1023 ebpf_shm_sum_cgroup_pids(&ect->publish_shm, ect->pids);
@@ -1050,7 +1050,7 @@ void ebpf_shm_send_cgroup_data(int update_every)
1050 }
1051 }
1052
1053 - pthread_mutex_unlock(&mutex_cgroup_shm);
1053 + netdata_mutex_unlock(&mutex_cgroup_shm);
1054 }
1055
1056 /**
@@ -1059,14 +1059,14 @@ void ebpf_shm_send_cgroup_data(int update_every)
1059 void ebpf_shm_resume_apps_data()
1060 {
1061 struct ebpf_target *w;
1062 - pthread_mutex_lock(&collect_data_mutex);
1062 + netdata_mutex_lock(&collect_data_mutex);
1063 for (w = apps_groups_root_target; w; w = w->next) {
1064 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SHM_IDX))))
1065 continue;
1066
1067 ebpf_shm_sum_pids(&w->shm, w->root_pid);
1068 }
1069 - pthread_mutex_unlock(&collect_data_mutex);
1069 + netdata_mutex_unlock(&collect_data_mutex);
1070 }
1071
1072 /**
@@ -1111,14 +1111,14 @@ void ebpf_read_shm_thread(void *ptr)
1111
1112 counter = 0;
1113
1114 - pthread_mutex_lock(&ebpf_exit_cleanup);
1114 + netdata_mutex_lock(&ebpf_exit_cleanup);
1115 if (running_time && !em->running_time)
1116 running_time = update_every;
1117 else
1118 running_time += update_every;
1119
1120 em->running_time = running_time;
1121 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1121 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1122 }
1123 }
1124
@@ -1146,7 +1146,7 @@ static void shm_collector(ebpf_module_t *em)
1146 counter = 0;
1147 netdata_apps_integration_flags_t apps = em->apps_charts;
1148 ebpf_shm_read_global_table(stats, maps_per_core);
1149 - pthread_mutex_lock(&lock);
1149 + netdata_mutex_lock(&lock);
1150
1151 shm_send_global();
1152
@@ -1158,16 +1158,16 @@ static void shm_collector(ebpf_module_t *em)
1158 ebpf_shm_send_cgroup_data(update_every);
1159 }
1160
1161 - pthread_mutex_unlock(&lock);
1161 + netdata_mutex_unlock(&lock);
1162
1163 - pthread_mutex_lock(&ebpf_exit_cleanup);
1163 + netdata_mutex_lock(&ebpf_exit_cleanup);
1164 if (running_time && !em->running_time)
1165 running_time = update_every;
1166 else
1167 running_time += update_every;
1168
1169 em->running_time = running_time;
1170 - pthread_mutex_unlock(&ebpf_exit_cleanup);
1170 + netdata_mutex_unlock(&ebpf_exit_cleanup);
1171 }
1172 }
1173
@@ -1386,11 +1386,11 @@ void ebpf_shm_thread(void *ptr)
1386 algorithms,
1387 NETDATA_SHM_END);
1388
1389 - pthread_mutex_lock(&lock);
1389 + netdata_mutex_lock(&lock);
1390 ebpf_create_shm_charts(em->update_every);
1391 ebpf_update_stats(&plugin_statistics, em);
1392 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
1393 - pthread_mutex_unlock(&lock);
1393 + netdata_mutex_unlock(&lock);
1394
1395 ebpf_read_shm.thread =
1396 nd_thread_create(ebpf_read_shm.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_shm_thread, em);
src/collectors/ebpf.plugin/ebpf_socket.c
+24 -24
@@ -493,15 +493,15 @@ static inline int ebpf_socket_load_and_attach(struct socket_bpf *obj, ebpf_modul
493 */
494 static void ebpf_socket_free(ebpf_module_t *em)
495 {
496 - pthread_mutex_lock(&ebpf_exit_cleanup);
496 + netdata_mutex_lock(&ebpf_exit_cleanup);
497 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
498 ebpf_update_stats(&plugin_statistics, em);
499 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
500 - pthread_mutex_unlock(&ebpf_exit_cleanup);
500 + netdata_mutex_unlock(&ebpf_exit_cleanup);
501
502 - pthread_mutex_lock(&lock);
502 + netdata_mutex_lock(&lock);
503 collect_pids &= ~(1 << EBPF_MODULE_SOCKET_IDX);
504 - pthread_mutex_unlock(&lock);
504 + netdata_mutex_unlock(&lock);
505 }
506
507 /**
@@ -623,7 +623,7 @@ static void ebpf_obsolete_specific_socket_charts(char *type, int update_every);
623 */
624 static inline void ebpf_obsolete_socket_cgroup_charts(ebpf_module_t *em)
625 {
626 - pthread_mutex_lock(&mutex_cgroup_shm);
626 + netdata_mutex_lock(&mutex_cgroup_shm);
627
628 ebpf_cgroup_target_t *ect;
629 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -635,7 +635,7 @@ static inline void ebpf_obsolete_socket_cgroup_charts(ebpf_module_t *em)
635
636 ebpf_obsolete_specific_socket_charts(ect->name, em->update_every);
637 }
638 - pthread_mutex_unlock(&mutex_cgroup_shm);
638 + netdata_mutex_unlock(&mutex_cgroup_shm);
639 }
640
641 /**
@@ -650,7 +650,7 @@ void ebpf_socket_obsolete_apps_charts(struct ebpf_module *em)
650 int order = 20130;
651 struct ebpf_target *w;
652 int update_every = em->update_every;
653 - pthread_mutex_lock(&collect_data_mutex);
653 + netdata_mutex_lock(&collect_data_mutex);
654 for (w = apps_groups_root_target; w; w = w->next) {
655 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SOCKET_IDX))))
656 continue;
@@ -755,7 +755,7 @@ void ebpf_socket_obsolete_apps_charts(struct ebpf_module *em)
755
756 w->charts_created &= ~(1 << EBPF_MODULE_SOCKET_IDX);
757 }
758 - pthread_mutex_unlock(&collect_data_mutex);
758 + netdata_mutex_unlock(&collect_data_mutex);
759 }
760
761 /**
@@ -899,7 +899,7 @@ static void ebpf_socket_exit(void *pptr)
899 nd_thread_signal_cancel(ebpf_read_socket.thread);
900
901 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
902 - pthread_mutex_lock(&lock);
902 + netdata_mutex_lock(&lock);
903
904 if (em->cgroup_charts) {
905 ebpf_obsolete_socket_cgroup_charts(em);
@@ -913,7 +913,7 @@ static void ebpf_socket_exit(void *pptr)
913
914 ebpf_socket_obsolete_global_charts(em);
915
916 - pthread_mutex_unlock(&lock);
916 + netdata_mutex_unlock(&lock);
917 }
918
919 ebpf_socket_free(em);
@@ -1067,7 +1067,7 @@ static void ebpf_socket_send_data(ebpf_module_t *em)
1067 void ebpf_socket_send_apps_data()
1068 {
1069 struct ebpf_target *w;
1070 - pthread_mutex_lock(&collect_data_mutex);
1070 + netdata_mutex_lock(&collect_data_mutex);
1071 for (w = apps_groups_root_target; w; w = w->next) {
1072 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SOCKET_IDX))))
1073 continue;
@@ -1109,7 +1109,7 @@ void ebpf_socket_send_apps_data()
1109 write_chart_dimension("calls", (collected_number)values->call_udp_received);
1110 ebpf_write_end_chart();
1111 }
1112 - pthread_mutex_unlock(&collect_data_mutex);
1112 + netdata_mutex_unlock(&collect_data_mutex);
1113 }
1114
1115 /*****************************************************************
@@ -1874,7 +1874,7 @@ void ebpf_socket_resume_apps_data()
1874 {
1875 struct ebpf_target *w;
1876
1877 - pthread_mutex_lock(&collect_data_mutex);
1877 + netdata_mutex_lock(&collect_data_mutex);
1878 for (w = apps_groups_root_target; w; w = w->next) {
1879 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SOCKET_IDX))))
1880 continue;
@@ -1903,7 +1903,7 @@ void ebpf_socket_resume_apps_data()
1903 values->call_udp_received = ws->call_udp_received;
1904 }
1905 }
1906 - pthread_mutex_unlock(&collect_data_mutex);
1906 + netdata_mutex_unlock(&collect_data_mutex);
1907 }
1908
1909 /**
@@ -1915,7 +1915,7 @@ static void ebpf_update_socket_cgroup()
1915 {
1916 ebpf_cgroup_target_t *ect;
1917
1918 - pthread_mutex_lock(&mutex_cgroup_shm);
1918 + netdata_mutex_lock(&mutex_cgroup_shm);
1919 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
1920 struct pid_on_target2 *pids;
1921 for (pids = ect->pids; pids; pids = pids->next) {
@@ -1940,7 +1940,7 @@ static void ebpf_update_socket_cgroup()
1940 publish->call_tcp_v6_connection = in->call_tcp_v6_connection;
1941 }
1942 }
1943 - pthread_mutex_unlock(&mutex_cgroup_shm);
1943 + netdata_mutex_unlock(&mutex_cgroup_shm);
1944 }
1945
1946 /**
@@ -2718,7 +2718,7 @@ void ebpf_socket_update_cgroup_algorithm()
2718 */
2719 static void ebpf_socket_send_cgroup_data(int update_every)
2720 {
2721 - pthread_mutex_lock(&mutex_cgroup_shm);
2721 + netdata_mutex_lock(&mutex_cgroup_shm);
2722 ebpf_cgroup_target_t *ect;
2723 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
2724 ebpf_socket_sum_cgroup_pids(&ect->publish_socket, ect->pids);
@@ -2748,7 +2748,7 @@ static void ebpf_socket_send_cgroup_data(int update_every)
2748 }
2749 }
2750
2751 - pthread_mutex_unlock(&mutex_cgroup_shm);
2751 + netdata_mutex_unlock(&mutex_cgroup_shm);
2752 }
2753
2754 /*****************************************************************
@@ -2790,7 +2790,7 @@ static void socket_collector(ebpf_module_t *em)
2790 ebpf_socket_read_hash_global_tables(stats, maps_per_core);
2791 }
2792
2793 - pthread_mutex_lock(&lock);
2793 + netdata_mutex_lock(&lock);
2794 if (socket_global_enabled)
2795 ebpf_socket_send_data(em);
2796
@@ -2802,16 +2802,16 @@ static void socket_collector(ebpf_module_t *em)
2802
2803 fflush(stdout);
2804
2805 - pthread_mutex_unlock(&lock);
2805 + netdata_mutex_unlock(&lock);
2806
2807 - pthread_mutex_lock(&ebpf_exit_cleanup);
2807 + netdata_mutex_lock(&ebpf_exit_cleanup);
2808 if (running_time && !em->running_time)
2809 running_time = update_every;
2810 else
2811 running_time += update_every;
2812
2813 em->running_time = running_time;
2814 - pthread_mutex_unlock(&ebpf_exit_cleanup);
2814 + netdata_mutex_unlock(&ebpf_exit_cleanup);
2815 }
2816 }
2817
@@ -3051,13 +3051,13 @@ void ebpf_socket_thread(void *ptr)
3051 ebpf_read_socket.thread =
3052 nd_thread_create(ebpf_read_socket.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_socket_thread, em);
3053
3054 - pthread_mutex_lock(&lock);
3054 + netdata_mutex_lock(&lock);
3055 ebpf_socket_create_global_charts(em);
3056
3057 ebpf_update_stats(&plugin_statistics, em);
3058 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
3059
3060 - pthread_mutex_unlock(&lock);
3060 + netdata_mutex_unlock(&lock);
3061
3062 socket_collector(em);
3063
src/collectors/ebpf.plugin/ebpf_softirq.c
+10 -10
@@ -88,11 +88,11 @@ static void softirq_cleanup(void *pptr)
88 return;
89
90 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
91 - pthread_mutex_lock(&lock);
91 + netdata_mutex_lock(&lock);
92
93 ebpf_obsolete_softirq_global(em);
94
95 - pthread_mutex_unlock(&lock);
95 + netdata_mutex_unlock(&lock);
96 fflush(stdout);
97 }
98
@@ -110,10 +110,10 @@ static void softirq_cleanup(void *pptr)
110 freez(softirq_ebpf_vals);
111 softirq_ebpf_vals = NULL;
112
113 - pthread_mutex_lock(&ebpf_exit_cleanup);
113 + netdata_mutex_lock(&ebpf_exit_cleanup);
114 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
115 ebpf_update_stats(&plugin_statistics, em);
116 - pthread_mutex_unlock(&ebpf_exit_cleanup);
116 + netdata_mutex_unlock(&ebpf_exit_cleanup);
117 }
118
119 /*****************************************************************
@@ -198,12 +198,12 @@ static void softirq_collector(ebpf_module_t *em)
198 softirq_ebpf_vals = callocz(ebpf_nprocs, sizeof(softirq_ebpf_val_t));
199
200 // create chart and static dims.
201 - pthread_mutex_lock(&lock);
201 + netdata_mutex_lock(&lock);
202 softirq_create_charts(em->update_every);
203 softirq_create_dims();
204 ebpf_update_stats(&plugin_statistics, em);
205 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
206 - pthread_mutex_unlock(&lock);
206 + netdata_mutex_unlock(&lock);
207
208 // loop and read from published data until ebpf plugin is closed.
209 heartbeat_t hb;
@@ -221,23 +221,23 @@ static void softirq_collector(ebpf_module_t *em)
221
222 counter = 0;
223 softirq_read_latency_map(maps_per_core);
224 - pthread_mutex_lock(&lock);
224 + netdata_mutex_lock(&lock);
225
226 // write dims now for all hitherto discovered IRQs.
227 ebpf_write_begin_chart(NETDATA_EBPF_SYSTEM_GROUP, "softirq_latency", "");
228 softirq_write_dims();
229 ebpf_write_end_chart();
230
231 - pthread_mutex_unlock(&lock);
231 + netdata_mutex_unlock(&lock);
232
233 - pthread_mutex_lock(&ebpf_exit_cleanup);
233 + netdata_mutex_lock(&ebpf_exit_cleanup);
234 if (running_time && !em->running_time)
235 running_time = update_every;
236 else
237 running_time += update_every;
238
239 em->running_time = running_time;
240 - pthread_mutex_unlock(&ebpf_exit_cleanup);
240 + netdata_mutex_unlock(&ebpf_exit_cleanup);
241 }
242 }
243
src/collectors/ebpf.plugin/ebpf_swap.c
+26 -26
@@ -303,7 +303,7 @@ static void ebpf_obsolete_swap_services(ebpf_module_t *em, char *id)
303 */
304 static inline void ebpf_obsolete_swap_cgroup_charts(ebpf_module_t *em)
305 {
306 - pthread_mutex_lock(&mutex_cgroup_shm);
306 + netdata_mutex_lock(&mutex_cgroup_shm);
307
308 ebpf_cgroup_target_t *ect;
309 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -315,7 +315,7 @@ static inline void ebpf_obsolete_swap_cgroup_charts(ebpf_module_t *em)
315
316 ebpf_obsolete_specific_swap_charts(ect->name, em->update_every);
317 }
318 - pthread_mutex_unlock(&mutex_cgroup_shm);
318 + netdata_mutex_unlock(&mutex_cgroup_shm);
319 }
320
321 /**
@@ -329,7 +329,7 @@ void ebpf_obsolete_swap_apps_charts(struct ebpf_module *em)
329 {
330 struct ebpf_target *w;
331 int update_every = em->update_every;
332 - pthread_mutex_lock(&collect_data_mutex);
332 + netdata_mutex_lock(&collect_data_mutex);
333 for (w = apps_groups_root_target; w; w = w->next) {
334 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SWAP_IDX))))
335 continue;
@@ -359,7 +359,7 @@ void ebpf_obsolete_swap_apps_charts(struct ebpf_module *em)
359 update_every);
360 w->charts_created &= ~(1 << EBPF_MODULE_SWAP_IDX);
361 }
362 - pthread_mutex_unlock(&collect_data_mutex);
362 + netdata_mutex_unlock(&collect_data_mutex);
363 }
364
365 /**
@@ -396,15 +396,15 @@ static void ebpf_swap_exit(void *ptr)
396 pids_fd[NETDATA_EBPF_PIDS_SWAP_IDX] = -1;
397 ebpf_module_t *em = (ebpf_module_t *)ptr;
398
399 - pthread_mutex_lock(&lock);
399 + netdata_mutex_lock(&lock);
400 collect_pids &= ~(1 << EBPF_MODULE_SWAP_IDX);
401 - pthread_mutex_unlock(&lock);
401 + netdata_mutex_unlock(&lock);
402
403 if (ebpf_read_swap.thread)
404 nd_thread_signal_cancel(ebpf_read_swap.thread);
405
406 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
407 - pthread_mutex_lock(&lock);
407 + netdata_mutex_lock(&lock);
408 if (em->cgroup_charts) {
409 ebpf_obsolete_swap_cgroup_charts(em);
410 fflush(stdout);
@@ -417,7 +417,7 @@ static void ebpf_swap_exit(void *ptr)
417 ebpf_obsolete_swap_global(em);
418
419 fflush(stdout);
420 - pthread_mutex_unlock(&lock);
420 + netdata_mutex_unlock(&lock);
421 }
422
423 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -434,10 +434,10 @@ static void ebpf_swap_exit(void *ptr)
434 em->probe_links = NULL;
435 }
436
437 - pthread_mutex_lock(&ebpf_exit_cleanup);
437 + netdata_mutex_lock(&ebpf_exit_cleanup);
438 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
439 ebpf_update_stats(&plugin_statistics, em);
440 - pthread_mutex_unlock(&ebpf_exit_cleanup);
440 + netdata_mutex_unlock(&ebpf_exit_cleanup);
441 }
442
443 /*****************************************************************
@@ -480,7 +480,7 @@ static void swap_apps_accumulator(netdata_ebpf_swap_t *out, int maps_per_core)
480 static void ebpf_update_swap_cgroup()
481 {
482 ebpf_cgroup_target_t *ect;
483 - pthread_mutex_lock(&mutex_cgroup_shm);
483 + netdata_mutex_lock(&mutex_cgroup_shm);
484 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
485 struct pid_on_target2 *pids;
486 for (pids = ect->pids; pids; pids = pids->next) {
@@ -494,7 +494,7 @@ static void ebpf_update_swap_cgroup()
494 memcpy(out, in, sizeof(netdata_publish_swap_t));
495 }
496 }
497 - pthread_mutex_unlock(&mutex_cgroup_shm);
497 + netdata_mutex_unlock(&mutex_cgroup_shm);
498 }
499
500 /**
@@ -532,14 +532,14 @@ static void ebpf_swap_sum_pids(netdata_publish_swap_t *swap, struct ebpf_pid_on_
532 void ebpf_swap_resume_apps_data()
533 {
534 struct ebpf_target *w;
535 - pthread_mutex_lock(&collect_data_mutex);
535 + netdata_mutex_lock(&collect_data_mutex);
536 for (w = apps_groups_root_target; w; w = w->next) {
537 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SWAP_IDX))))
538 continue;
539
540 ebpf_swap_sum_pids(&w->swap, w->root_pid);
541 }
542 - pthread_mutex_unlock(&collect_data_mutex);
542 + netdata_mutex_unlock(&collect_data_mutex);
543 }
544
545 /**
@@ -629,14 +629,14 @@ void ebpf_read_swap_thread(void *ptr)
629
630 counter = 0;
631
632 - pthread_mutex_lock(&ebpf_exit_cleanup);
632 + netdata_mutex_lock(&ebpf_exit_cleanup);
633 if (running_time && !em->running_time)
634 running_time = update_every;
635 else
636 running_time += update_every;
637
638 em->running_time = running_time;
639 - pthread_mutex_unlock(&ebpf_exit_cleanup);
639 + netdata_mutex_unlock(&ebpf_exit_cleanup);
640 }
641 }
642
@@ -691,7 +691,7 @@ static void ebpf_swap_read_global_table(netdata_idx_t *stats, int maps_per_core)
691 void ebpf_swap_send_apps_data(struct ebpf_target *root)
692 {
693 struct ebpf_target *w;
694 - pthread_mutex_lock(&collect_data_mutex);
694 + netdata_mutex_lock(&collect_data_mutex);
695 for (w = root; w; w = w->next) {
696 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_SWAP_IDX))))
697 continue;
@@ -704,7 +704,7 @@ void ebpf_swap_send_apps_data(struct ebpf_target *root)
704 write_chart_dimension("calls", (long long)w->swap.write);
705 ebpf_write_end_chart();
706 }
707 - pthread_mutex_unlock(&collect_data_mutex);
707 + netdata_mutex_unlock(&collect_data_mutex);
708 }
709
710 /**
@@ -915,7 +915,7 @@ static void ebpf_create_systemd_swap_charts(int update_every)
915 */
916 void ebpf_swap_send_cgroup_data(int update_every)
917 {
918 - pthread_mutex_lock(&mutex_cgroup_shm);
918 + netdata_mutex_lock(&mutex_cgroup_shm);
919 ebpf_cgroup_target_t *ect;
920 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
921 ebpf_swap_sum_cgroup_pids(&ect->publish_systemd_swap, ect->pids);
@@ -948,7 +948,7 @@ void ebpf_swap_send_cgroup_data(int update_every)
948 }
949 }
950
951 - pthread_mutex_unlock(&mutex_cgroup_shm);
951 + netdata_mutex_unlock(&mutex_cgroup_shm);
952 }
953
954 /**
@@ -976,7 +976,7 @@ static void swap_collector(ebpf_module_t *em)
976 netdata_apps_integration_flags_t apps = em->apps_charts;
977 ebpf_swap_read_global_table(stats, maps_per_core);
978
979 - pthread_mutex_lock(&lock);
979 + netdata_mutex_lock(&lock);
980
981 swap_send_global();
982
@@ -986,16 +986,16 @@ static void swap_collector(ebpf_module_t *em)
986 if (cgroup && shm_ebpf_cgroup.header)
987 ebpf_swap_send_cgroup_data(update_every);
988
989 - pthread_mutex_unlock(&lock);
989 + netdata_mutex_unlock(&lock);
990
991 - pthread_mutex_lock(&ebpf_exit_cleanup);
991 + netdata_mutex_lock(&ebpf_exit_cleanup);
992 if (running_time && !em->running_time)
993 running_time = update_every;
994 else
995 running_time += update_every;
996
997 em->running_time = running_time;
998 - pthread_mutex_unlock(&ebpf_exit_cleanup);
998 + netdata_mutex_unlock(&ebpf_exit_cleanup);
999 }
1000 }
1001
@@ -1212,11 +1212,11 @@ void ebpf_swap_thread(void *ptr)
1212 algorithms,
1213 NETDATA_SWAP_END);
1214
1215 - pthread_mutex_lock(&lock);
1215 + netdata_mutex_lock(&lock);
1216 ebpf_create_swap_charts(em->update_every);
1217 ebpf_update_stats(&plugin_statistics, em);
1218 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
1219 - pthread_mutex_unlock(&lock);
1219 + netdata_mutex_unlock(&lock);
1220
1221 ebpf_read_swap.thread =
1222 nd_thread_create(ebpf_read_swap.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_swap_thread, em);
src/collectors/ebpf.plugin/ebpf_sync.c
+10 -10
@@ -386,17 +386,17 @@ static void ebpf_sync_exit(void *pptr)
386 return;
387
388 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
389 - pthread_mutex_lock(&lock);
389 + netdata_mutex_lock(&lock);
390 ebpf_obsolete_sync_global(em);
391 - pthread_mutex_unlock(&lock);
391 + netdata_mutex_unlock(&lock);
392 }
393
394 ebpf_sync_cleanup_objects();
395
396 - pthread_mutex_lock(&ebpf_exit_cleanup);
396 + netdata_mutex_lock(&ebpf_exit_cleanup);
397 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
398 ebpf_update_stats(&plugin_statistics, em);
399 - pthread_mutex_unlock(&ebpf_exit_cleanup);
399 + netdata_mutex_unlock(&ebpf_exit_cleanup);
400 }
401
402 /*****************************************************************
@@ -603,20 +603,20 @@ static void sync_collector(ebpf_module_t *em)
603
604 counter = 0;
605 ebpf_sync_read_global_table(maps_per_core);
606 - pthread_mutex_lock(&lock);
606 + netdata_mutex_lock(&lock);
607
608 sync_send_data();
609
610 - pthread_mutex_unlock(&lock);
610 + netdata_mutex_unlock(&lock);
611
612 - pthread_mutex_lock(&ebpf_exit_cleanup);
612 + netdata_mutex_lock(&ebpf_exit_cleanup);
613 if (running_time && !em->running_time)
614 running_time = update_every;
615 else
616 running_time += update_every;
617
618 em->running_time = running_time;
619 - pthread_mutex_unlock(&ebpf_exit_cleanup);
619 + netdata_mutex_unlock(&ebpf_exit_cleanup);
620 }
621 }
622
@@ -786,10 +786,10 @@ void ebpf_sync_thread(void *ptr)
786 algorithms,
787 NETDATA_SYNC_IDX_END);
788
789 - pthread_mutex_lock(&lock);
789 + netdata_mutex_lock(&lock);
790 ebpf_create_sync_charts(em->update_every);
791 ebpf_update_stats(&plugin_statistics, em);
792 - pthread_mutex_unlock(&lock);
792 + netdata_mutex_unlock(&lock);
793
794 sync_collector(em);
795
src/collectors/ebpf.plugin/ebpf_vfs.c
+26 -26
@@ -574,7 +574,7 @@ static void ebpf_obsolete_vfs_services(ebpf_module_t *em, char *id)
574 */
575 static inline void ebpf_obsolete_vfs_cgroup_charts(ebpf_module_t *em)
576 {
577 - pthread_mutex_lock(&mutex_cgroup_shm);
577 + netdata_mutex_lock(&mutex_cgroup_shm);
578
579 ebpf_cgroup_target_t *ect;
580 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
@@ -586,7 +586,7 @@ static inline void ebpf_obsolete_vfs_cgroup_charts(ebpf_module_t *em)
586
587 ebpf_obsolete_specific_vfs_charts(ect->name, em);
588 }
589 - pthread_mutex_unlock(&mutex_cgroup_shm);
589 + netdata_mutex_unlock(&mutex_cgroup_shm);
590 }
591
592 /**
@@ -601,7 +601,7 @@ void ebpf_obsolete_vfs_apps_charts(struct ebpf_module *em)
601 int order = 20275;
602 struct ebpf_target *w;
603 int update_every = em->update_every;
604 - pthread_mutex_lock(&collect_data_mutex);
604 + netdata_mutex_lock(&collect_data_mutex);
605 for (w = apps_groups_root_target; w; w = w->next) {
606 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_VFS_IDX))))
607 continue;
@@ -773,7 +773,7 @@ void ebpf_obsolete_vfs_apps_charts(struct ebpf_module *em)
773 }
774 w->charts_created &= ~(1 << EBPF_MODULE_VFS_IDX);
775 }
776 - pthread_mutex_unlock(&collect_data_mutex);
776 + netdata_mutex_unlock(&collect_data_mutex);
777 }
778
779 /**
@@ -921,15 +921,15 @@ static void ebpf_vfs_exit(void *pptr)
921 if (!em)
922 return;
923
924 - pthread_mutex_lock(&lock);
924 + netdata_mutex_lock(&lock);
925 collect_pids &= ~(1 << EBPF_MODULE_VFS_IDX);
926 - pthread_mutex_unlock(&lock);
926 + netdata_mutex_unlock(&lock);
927
928 if (ebpf_read_vfs.thread)
929 nd_thread_signal_cancel(ebpf_read_vfs.thread);
930
931 if (em->enabled == NETDATA_THREAD_EBPF_FUNCTION_RUNNING) {
932 - pthread_mutex_lock(&lock);
932 + netdata_mutex_lock(&lock);
933 if (em->cgroup_charts) {
934 ebpf_obsolete_vfs_cgroup_charts(em);
935 fflush(stdout);
@@ -942,7 +942,7 @@ static void ebpf_vfs_exit(void *pptr)
942 ebpf_obsolete_vfs_global(em);
943
944 fflush(stdout);
945 - pthread_mutex_unlock(&lock);
945 + netdata_mutex_unlock(&lock);
946 }
947
948 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_REMOVE);
@@ -959,10 +959,10 @@ static void ebpf_vfs_exit(void *pptr)
959 em->probe_links = NULL;
960 }
961
962 - pthread_mutex_lock(&ebpf_exit_cleanup);
962 + netdata_mutex_lock(&ebpf_exit_cleanup);
963 em->enabled = NETDATA_THREAD_EBPF_STOPPED;
964 ebpf_update_stats(&plugin_statistics, em);
965 - pthread_mutex_unlock(&ebpf_exit_cleanup);
965 + netdata_mutex_unlock(&ebpf_exit_cleanup);
966 }
967
968 /*****************************************************************
@@ -1186,7 +1186,7 @@ static void ebpf_vfs_sum_pids(netdata_publish_vfs_t *vfs, struct ebpf_pid_on_tar
1186 void ebpf_vfs_send_apps_data(ebpf_module_t *em, struct ebpf_target *root)
1187 {
1188 struct ebpf_target *w;
1189 - pthread_mutex_lock(&collect_data_mutex);
1189 + netdata_mutex_lock(&collect_data_mutex);
1190 for (w = root; w; w = w->next) {
1191 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_VFS_IDX))))
1192 continue;
@@ -1253,7 +1253,7 @@ void ebpf_vfs_send_apps_data(ebpf_module_t *em, struct ebpf_target *root)
1253 ebpf_write_end_chart();
1254 }
1255 }
1256 - pthread_mutex_unlock(&collect_data_mutex);
1256 + netdata_mutex_unlock(&collect_data_mutex);
1257 }
1258
1259 /**
@@ -1346,7 +1346,7 @@ static void ebpf_vfs_read_apps(int maps_per_core)
1346 static void read_update_vfs_cgroup()
1347 {
1348 ebpf_cgroup_target_t *ect;
1349 - pthread_mutex_lock(&mutex_cgroup_shm);
1349 + netdata_mutex_lock(&mutex_cgroup_shm);
1350 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
1351 struct pid_on_target2 *pids;
1352 for (pids = ect->pids; pids; pids = pids->next) {
@@ -1362,7 +1362,7 @@ static void read_update_vfs_cgroup()
1362 vfs_aggregate_publish_vfs(out, in);
1363 }
1364 }
1365 - pthread_mutex_unlock(&mutex_cgroup_shm);
1365 + netdata_mutex_unlock(&mutex_cgroup_shm);
1366 }
1367
1368 /**
@@ -2244,7 +2244,7 @@ static void ebpf_send_systemd_vfs_charts(ebpf_module_t *em)
2244 */
2245 static void ebpf_vfs_send_cgroup_data(ebpf_module_t *em)
2246 {
2247 - pthread_mutex_lock(&mutex_cgroup_shm);
2247 + netdata_mutex_lock(&mutex_cgroup_shm);
2248 ebpf_cgroup_target_t *ect;
2249 for (ect = ebpf_cgroup_pids; ect; ect = ect->next) {
2250 ebpf_vfs_sum_cgroup_pids(&ect->publish_systemd_vfs, ect->pids);
@@ -2276,7 +2276,7 @@ static void ebpf_vfs_send_cgroup_data(ebpf_module_t *em)
2276 }
2277 }
2278
2279 - pthread_mutex_unlock(&mutex_cgroup_shm);
2279 + netdata_mutex_unlock(&mutex_cgroup_shm);
2280 }
2281
2282 /**
@@ -2285,14 +2285,14 @@ static void ebpf_vfs_send_cgroup_data(ebpf_module_t *em)
2285 void ebpf_vfs_resume_apps_data()
2286 {
2287 struct ebpf_target *w;
2288 - pthread_mutex_lock(&collect_data_mutex);
2288 + netdata_mutex_lock(&collect_data_mutex);
2289 for (w = apps_groups_root_target; w; w = w->next) {
2290 if (unlikely(!(w->charts_created & (1 << EBPF_MODULE_VFS_IDX))))
2291 continue;
2292
2293 ebpf_vfs_sum_pids(&w->vfs, w->root_pid);
2294 }
2295 - pthread_mutex_unlock(&collect_data_mutex);
2295 + netdata_mutex_unlock(&collect_data_mutex);
2296 }
2297
2298 /**
@@ -2337,14 +2337,14 @@ void ebpf_read_vfs_thread(void *ptr)
2337
2338 counter = 0;
2339
2340 - pthread_mutex_lock(&ebpf_exit_cleanup);
2340 + netdata_mutex_lock(&ebpf_exit_cleanup);
2341 if (running_time && !em->running_time)
2342 running_time = update_every;
2343 else
2344 running_time += update_every;
2345
2346 em->running_time = running_time;
2347 - pthread_mutex_unlock(&ebpf_exit_cleanup);
2347 + netdata_mutex_unlock(&ebpf_exit_cleanup);
2348 }
2349 }
2350
@@ -2375,7 +2375,7 @@ static void vfs_collector(ebpf_module_t *em)
2375 netdata_apps_integration_flags_t apps = em->apps_charts;
2376 ebpf_vfs_read_global_table(stats, maps_per_core);
2377
2378 - pthread_mutex_lock(&lock);
2378 + netdata_mutex_lock(&lock);
2379
2380 ebpf_vfs_send_data(em);
2381 fflush(stdout);
@@ -2386,16 +2386,16 @@ static void vfs_collector(ebpf_module_t *em)
2386 if (cgroups && shm_ebpf_cgroup.header)
2387 ebpf_vfs_send_cgroup_data(em);
2388
2389 - pthread_mutex_unlock(&lock);
2389 + netdata_mutex_unlock(&lock);
2390
2391 - pthread_mutex_lock(&ebpf_exit_cleanup);
2391 + netdata_mutex_lock(&ebpf_exit_cleanup);
2392 if (running_time && !em->running_time)
2393 running_time = update_every;
2394 else
2395 running_time += update_every;
2396
2397 em->running_time = running_time;
2398 - pthread_mutex_unlock(&ebpf_exit_cleanup);
2398 + netdata_mutex_unlock(&ebpf_exit_cleanup);
2399 }
2400 }
2401
@@ -2948,12 +2948,12 @@ void ebpf_vfs_thread(void *ptr)
2948 algorithms,
2949 NETDATA_KEY_PUBLISH_VFS_END);
2950
2951 - pthread_mutex_lock(&lock);
2951 + netdata_mutex_lock(&lock);
2952 ebpf_create_global_charts(em);
2953 ebpf_update_stats(&plugin_statistics, em);
2954 ebpf_update_kernel_memory_with_vector(&plugin_statistics, em->maps, EBPF_ACTION_STAT_ADD);
2955
2956 - pthread_mutex_unlock(&lock);
2956 + netdata_mutex_unlock(&lock);
2957
2958 ebpf_read_vfs.thread =
2959 nd_thread_create(ebpf_read_vfs.name, NETDATA_THREAD_OPTION_DEFAULT, ebpf_read_vfs_thread, em);
src/database/rrdfunctions-inflight.c
+7 -7
@@ -135,7 +135,7 @@ struct rrd_function_call_wait {
135 bool free_with_signal;
136 bool data_are_ready;
137 netdata_mutex_t mutex;
138 - pthread_cond_t cond;
138 + netdata_cond_t cond;
139 int code;
140 };
141
@@ -148,7 +148,7 @@ static void rrd_function_call_wait_free(struct rrd_function_call_wait *tmp) {
148 rrd_inflight_function_cleanup(tmp->host, tmp->transaction);
149 freez(tmp->transaction);
150
151 - pthread_cond_destroy(&tmp->cond);
151 + netdata_cond_destroy(&tmp->cond);
152 netdata_mutex_destroy(&tmp->mutex);
153 freez(tmp);
154 }
@@ -160,7 +160,7 @@ static void rrd_async_function_signal_when_ready(BUFFER *temp_wb __maybe_unused,
160 netdata_mutex_lock(&tmp->mutex);
161
162 // since we got the mutex,
163 - // the waiting thread is either in pthread_cond_timedwait()
163 + // the waiting thread is either in cond_timedwait()
164 // or gave up and left.
165
166 tmp->code = code;
@@ -169,7 +169,7 @@ static void rrd_async_function_signal_when_ready(BUFFER *temp_wb __maybe_unused,
169 if(tmp->free_with_signal)
170 we_should_free = true;
171
172 - pthread_cond_signal(&tmp->cond);
172 + netdata_cond_signal(&tmp->cond);
173
174 netdata_mutex_unlock(&tmp->mutex);
175
@@ -236,7 +236,7 @@ static int rrd_call_function_async_and_wait(struct rrd_function_inflight *r) {
236 tmp->host_function_acquired = r->host_function_acquired;
237 tmp->transaction = strdupz(r->transaction);
238 netdata_mutex_init(&tmp->mutex);
239 - pthread_cond_init(&tmp->cond, NULL);
239 + netdata_cond_init(&tmp->cond);
240
241 // we need a temporary BUFFER, because we may time out and the caller supplied one may vanish,
242 // so we create a new one we guarantee will survive until the collector finishes...
@@ -303,8 +303,8 @@ static int rrd_call_function_async_and_wait(struct rrd_function_inflight *r) {
303 tp.tv_nsec -= 1 * NSEC_PER_SEC;
304 }
305
306 - // the mutex is unlocked within pthread_cond_timedwait()
307 - rc = pthread_cond_timedwait(&tmp->cond, &tmp->mutex, &tp);
306 + // the mutex is unlocked within cond_timedwait()
307 + rc = netdata_cond_timedwait(&tmp->cond, &tmp->mutex, &tp);
308 // the mutex is again ours
309
310 if(rc == ETIMEDOUT) {
src/libnetdata/functions_evloop/functions_evloop.c
+14 -14
@@ -43,8 +43,8 @@ struct functions_evloop_globals {
43 const char *tag;
44
45 DICTIONARY *worker_queue;
46 - pthread_mutex_t worker_mutex;
47 - pthread_cond_t worker_cond_var;
46 + netdata_mutex_t worker_mutex;
47 + netdata_cond_t worker_cond_var;
48 size_t workers;
49
50 netdata_mutex_t *stdout_mutex;
@@ -77,10 +77,10 @@ struct functions_evloop_globals {
77
78 static void rrd_functions_worker_canceller(void *data) {
79 struct functions_evloop_globals *wg = data;
80 - pthread_mutex_lock(&wg->worker_mutex);
80 + netdata_mutex_lock(&wg->worker_mutex);
81 wg->workers_exit = true;
82 - pthread_cond_signal(&wg->worker_cond_var);
83 - pthread_mutex_unlock(&wg->worker_mutex);
82 + netdata_cond_signal(&wg->worker_cond_var);
83 + netdata_mutex_unlock(&wg->worker_mutex);
84 }
85
86 static void rrd_functions_worker_globals_worker_main(void *arg) {
@@ -90,15 +90,15 @@ static void rrd_functions_worker_globals_worker_main(void *arg) {
90
91 bool last_acquired = true;
92 while (true) {
93 - pthread_mutex_lock(&wg->worker_mutex);
93 + netdata_mutex_lock(&wg->worker_mutex);
94
95 if(wg->workers_exit || nd_thread_signaled_to_cancel()) {
96 - pthread_mutex_unlock(&wg->worker_mutex);
96 + netdata_mutex_unlock(&wg->worker_mutex);
97 break;
98 }
99
100 if(dictionary_entries(wg->worker_queue) == 0 || !last_acquired)
101 - pthread_cond_wait(&wg->worker_cond_var, &wg->worker_mutex);
101 + netdata_cond_wait(&wg->worker_cond_var, &wg->worker_mutex);
102
103 const DICTIONARY_ITEM *acquired = NULL;
104 struct functions_evloop_worker_job *j;
@@ -112,7 +112,7 @@ static void rrd_functions_worker_globals_worker_main(void *arg) {
112 }
113 dfe_done(j);
114
115 - pthread_mutex_unlock(&wg->worker_mutex);
115 + netdata_mutex_unlock(&wg->worker_mutex);
116
117 if(wg->workers_exit || nd_thread_signaled_to_cancel()) {
118 if(acquired)
@@ -185,9 +185,9 @@ static void worker_add_job(struct functions_evloop_globals *wg, const char *keyw
185 else {
186 found = true;
187 j->used = true;
188 - pthread_mutex_lock(&wg->worker_mutex);
189 - pthread_cond_signal(&wg->worker_cond_var);
190 - pthread_mutex_unlock(&wg->worker_mutex);
188 + netdata_mutex_lock(&wg->worker_mutex);
189 + netdata_cond_signal(&wg->worker_cond_var);
190 + netdata_mutex_unlock(&wg->worker_mutex);
191 }
192 }
193 }
@@ -349,8 +349,8 @@ struct functions_evloop_globals *functions_evloop_init(size_t worker_threads, co
349
350 wg->dyncfg.nodes = dyncfg_nodes_dictionary_create();
351
352 - pthread_mutex_init(&wg->worker_mutex, NULL);
353 - pthread_cond_init(&wg->worker_cond_var, NULL);
352 + netdata_mutex_init(&wg->worker_mutex);
353 + netdata_cond_init(&wg->worker_cond_var);
354
355 wg->plugin_should_exit = plugin_should_exit;
356 wg->stdout_mutex = stdout_mutex;
src/libnetdata/locks/benchmark-rw.c
+49 -49
@@ -35,8 +35,8 @@ typedef struct {
35
36 // Per-thread control
37 struct {
38 - pthread_cond_t cond; // Thread start condition
39 - pthread_mutex_t cond_mutex; // Mutex for condition
38 + netdata_cond_t cond; // Thread start condition
39 + netdata_mutex_t cond_mutex; // Mutex for condition
40 uint64_t run_flag; // Thread run control
41 } thread_controls[MAX_THREADS];
42 } rwlock_control_t;
@@ -49,8 +49,8 @@ typedef enum {
49 typedef struct {
50 int thread_id;
51 thread_type_t type;
52 - void *lock; // Points to either pthread_rwlock_t or RW_SPINLOCK
53 - bool is_spinlock; // true for RW_SPINLOCK, false for pthread_rwlock_t
52 + void *lock; // Points to either netdata_rwlock_t or RW_SPINLOCK
53 + bool is_spinlock; // true for RW_SPINLOCK, false for netdata_rwlock_t
54 rwlock_control_t *control;
55 ND_THREAD *thread;
56 } thread_context_t;
@@ -99,11 +99,11 @@ static void release_access(rwlock_control_t *control, thread_type_t type) {
99 }
100 }
101
102 -static void wait_for_start(pthread_cond_t *cond, pthread_mutex_t *mutex, uint64_t *flag) {
103 - pthread_mutex_lock(mutex);
102 +static void wait_for_start(netdata_cond_t *cond, netdata_mutex_t *mutex, uint64_t *flag) {
103 + netdata_mutex_lock(mutex);
104 while (*flag == 0)
105 - pthread_cond_wait(cond, mutex);
106 - pthread_mutex_unlock(mutex);
105 + netdata_cond_wait(cond, mutex);
106 + netdata_mutex_unlock(mutex);
107 }
108
109 static void benchmark_thread(void *arg) {
@@ -141,20 +141,20 @@ static void benchmark_thread(void *arg) {
141 }
142 }
143 else {
144 - pthread_rwlock_t *rwlock = ctx->lock;
144 + netdata_rwlock_t *rwlock = ctx->lock;
145 if(ctx->type == THREAD_READER) {
146 - pthread_rwlock_rdlock(rwlock);
146 + netdata_rwlock_rdlock(rwlock);
147 check_access_safety(control, THREAD_READER);
148 control->counter++;
149 release_access(control, THREAD_READER);
150 - pthread_rwlock_unlock(rwlock);
150 + netdata_rwlock_rdunlock(rwlock);
151 }
152 else {
153 - pthread_rwlock_wrlock(rwlock);
153 + netdata_rwlock_wrlock(rwlock);
154 check_access_safety(control, THREAD_WRITER);
155 control->counter++;
156 release_access(control, THREAD_WRITER);
157 - pthread_rwlock_unlock(rwlock);
157 + netdata_rwlock_rdunlock(rwlock);
158 }
159 }
160 operations++;
@@ -174,7 +174,7 @@ static void print_summary(const summary_stats_t *summary) {
174 "Lock Type", "Readers", "Writers", "Reader Ops/s", "Writer Ops/s");
175 fprintf(stderr, "----------------------------------------------------------------------\n");
176
177 - const char *lock_names[] = {"pthread_rwlock", "rw_spinlock"};
177 + const char *lock_names[] = {"netdata_rwlock", "rw_spinlock"};
178
179 for (int config = 0; config < summary->config_count; config++) {
180 for (int lock_type = 0; lock_type < 2; lock_type++) {
@@ -265,10 +265,10 @@ static void run_test(const char *name, int readers, int writers,
265
266 // Signal threads to start
267 for(int i = 0; i < total_threads; i++) {
268 - pthread_mutex_lock(&control->thread_controls[i].cond_mutex);
268 + netdata_mutex_lock(&control->thread_controls[i].cond_mutex);
269 control->thread_controls[i].run_flag = 1;
270 - pthread_cond_signal(&control->thread_controls[i].cond);
271 - pthread_mutex_unlock(&control->thread_controls[i].cond_mutex);
270 + netdata_cond_signal(&control->thread_controls[i].cond);
271 + netdata_mutex_unlock(&control->thread_controls[i].cond_mutex);
272 }
273
274 // Wait for test duration
@@ -289,30 +289,30 @@ static void run_test(const char *name, int readers, int writers,
289 }
290
291 int rwlocks_stress_test(void) {
292 - pthread_rwlock_t pthread_rwlock;
293 - pthread_rwlock_init(&pthread_rwlock, NULL);
292 + netdata_rwlock_t netdata_rwlock;
293 + netdata_rwlock_init(&netdata_rwlock);
294
295 RW_SPINLOCK rw_spinlock = RW_SPINLOCK_INITIALIZER;
296 summary_stats_t summary = {0};
297
298 // Initialize control structures
299 - rwlock_control_t pthread_control = { 0 };
299 + rwlock_control_t netdata_control = { 0 };
300 rwlock_control_t spinlock_control = { 0 };
301
302 // Initialize per-thread controls for both locks
303 for(int i = 0; i < MAX_THREADS; i++) {
304 - pthread_cond_init(&pthread_control.thread_controls[i].cond, NULL);
305 - pthread_mutex_init(&pthread_control.thread_controls[i].cond_mutex,NULL);
306 - pthread_control.thread_controls[i].run_flag = 0;
304 + netdata_cond_init(&netdata_control.thread_controls[i].cond);
305 + netdata_mutex_init(&netdata_control.thread_controls[i].cond_mutex);
306 + netdata_control.thread_controls[i].run_flag = 0;
307
308 - pthread_cond_init(&spinlock_control.thread_controls[i].cond, NULL);
309 - pthread_mutex_init(&spinlock_control.thread_controls[i].cond_mutex,NULL);
308 + netdata_cond_init(&spinlock_control.thread_controls[i].cond);
309 + netdata_mutex_init(&spinlock_control.thread_controls[i].cond_mutex);
310
311 spinlock_control.thread_controls[i].run_flag = 0;
312 }
313
314 // Create thread contexts
315 - thread_context_t pthread_contexts[MAX_THREADS];
315 + thread_context_t netdata_contexts[MAX_THREADS];
316 thread_context_t spinlock_contexts[MAX_THREADS];
317
318 fprintf(stderr, "\nStarting RW locks benchmark...\n");
@@ -338,17 +338,17 @@ int rwlocks_stress_test(void) {
338 char thr_name[32];
339
340 // Initialize pthread contexts
341 - pthread_contexts[i] = (thread_context_t){
341 + netdata_contexts[i] = (thread_context_t){
342 .thread_id = i,
343 .type = i % 2 == 0 ? THREAD_READER :THREAD_WRITER,
344 - .lock = &pthread_rwlock,
344 + .lock = &netdata_rwlock,
345 .is_spinlock = false,
346 - .control = &pthread_control
346 + .control = &netdata_control
347 };
348
349 - snprintf(thr_name, sizeof(thr_name), "pthread_rw%d", i);
350 - pthread_contexts[i].thread =
351 - nd_thread_create(thr_name, NETDATA_THREAD_OPTION_DONT_LOG, benchmark_thread, &pthread_contexts[i]);
349 + snprintf(thr_name, sizeof(thr_name), "netdata_rw%d", i);
350 + netdata_contexts[i].thread =
351 + nd_thread_create(thr_name, NETDATA_THREAD_OPTION_DONT_LOG, benchmark_thread, &netdata_contexts[i]);
352
353 // Initialize spinlock contexts
354 spinlock_contexts[i] = (thread_context_t){
@@ -374,21 +374,21 @@ int rwlocks_stress_test(void) {
374
375 // First assign reader threads
376 for(int r = 0; r < readers; r++) {
377 - pthread_contexts[thread_idx].type = THREAD_READER;
377 + netdata_contexts[thread_idx].type = THREAD_READER;
378 spinlock_contexts[thread_idx].type = THREAD_READER;
379 thread_idx++;
380 }
381
382 // Then assign writer threads
383 for(int w = 0; w < writers; w++) {
384 - pthread_contexts[thread_idx].type = THREAD_WRITER;
384 + netdata_contexts[thread_idx].type = THREAD_WRITER;
385 spinlock_contexts[thread_idx].type = THREAD_WRITER;
386 thread_idx++;
387 }
388
389 char test_name[64];
390 - snprintf(test_name, sizeof(test_name), "pthread_rwlock %dR/%dW", readers, writers);
391 - run_test(test_name, readers, writers, pthread_contexts, &pthread_control, &summary, i, 0);
390 + snprintf(test_name, sizeof(test_name), "netdata_rwlock %dR/%dW", readers, writers);
391 + run_test(test_name, readers, writers, netdata_contexts, &netdata_control, &summary, i, 0);
392
393 snprintf(test_name, sizeof(test_name), "rw_spinlock %dR/%dW", readers, writers);
394 run_test(test_name, readers, writers, spinlock_contexts, &spinlock_control, &summary, i, 1);
@@ -401,34 +401,34 @@ int rwlocks_stress_test(void) {
401 fprintf(stderr, "\nStopping threads...\n");
402 for(int i = 0; i < MAX_THREADS; i++) {
403 // Signal pthread threads
404 - pthread_mutex_lock(&pthread_control.thread_controls[i].cond_mutex);
405 - pthread_control.thread_controls[i].run_flag = STOP_SIGNAL;
406 - pthread_cond_signal(&pthread_control.thread_controls[i].cond);
407 - pthread_mutex_unlock(&pthread_control.thread_controls[i].cond_mutex);
404 + netdata_mutex_lock(&netdata_control.thread_controls[i].cond_mutex);
405 + netdata_control.thread_controls[i].run_flag = STOP_SIGNAL;
406 + netdata_cond_signal(&netdata_control.thread_controls[i].cond);
407 + netdata_mutex_unlock(&netdata_control.thread_controls[i].cond_mutex);
408
409 // Signal spinlock threads
410 - pthread_mutex_lock(&spinlock_control.thread_controls[i].cond_mutex);
410 + netdata_mutex_lock(&spinlock_control.thread_controls[i].cond_mutex);
411 spinlock_control.thread_controls[i].run_flag = STOP_SIGNAL;
412 - pthread_cond_signal(&spinlock_control.thread_controls[i].cond);
413 - pthread_mutex_unlock(&spinlock_control.thread_controls[i].cond_mutex);
412 + netdata_cond_signal(&spinlock_control.thread_controls[i].cond);
413 + netdata_mutex_unlock(&spinlock_control.thread_controls[i].cond_mutex);
414 }
415
416 // Join all threads
417 fprintf(stderr, "\nWaiting for threads to exit...\n");
418 for(int i = 0; i < MAX_THREADS; i++) {
419 - nd_thread_join(pthread_contexts[i].thread);
419 + nd_thread_join(netdata_contexts[i].thread);
420 nd_thread_join(spinlock_contexts[i].thread);
421 }
422
423 // Cleanup condition variables and mutexes
424 for(int i = 0; i < MAX_THREADS; i++) {
425 - pthread_cond_destroy(&pthread_control.thread_controls[i].cond);
426 - pthread_mutex_destroy(&pthread_control.thread_controls[i].cond_mutex);
427 - pthread_cond_destroy(&spinlock_control.thread_controls[i].cond);
428 - pthread_mutex_destroy(&spinlock_control.thread_controls[i].cond_mutex);
425 + netdata_cond_destroy(&netdata_control.thread_controls[i].cond);
426 + netdata_mutex_destroy(&netdata_control.thread_controls[i].cond_mutex);
427 + netdata_cond_destroy(&spinlock_control.thread_controls[i].cond);
428 + netdata_mutex_destroy(&spinlock_control.thread_controls[i].cond_mutex);
429 }
430
431 - pthread_rwlock_destroy(&pthread_rwlock);
431 + netdata_rwlock_destroy(&netdata_rwlock);
432
433 return 0;
434 }
src/libnetdata/locks/locks.c
+35
@@ -21,6 +21,41 @@
21 // ----------------------------------------------------------------------------
22 // mutex
23
24 +ALWAYS_INLINE int __netdata_cond_init(netdata_cond_t *cond) {
25 + int ret = pthread_cond_init(cond, NULL);
26 + if(unlikely(ret != 0))
27 + netdata_log_error("COND: failed to initialize (code %d).", ret);
28 + return ret;
29 +}
30 +
31 +ALWAYS_INLINE int __netdata_cond_destroy(netdata_cond_t *cond) {
32 + int ret = pthread_cond_destroy(cond);
33 + if(unlikely(ret != 0))
34 + netdata_log_error("COND: failed to destroy (code %d).", ret);
35 + return ret;
36 +}
37 +
38 +ALWAYS_INLINE int __netdata_cond_signal(netdata_cond_t *cond) {
39 + int ret = pthread_cond_signal(cond);
40 + if(unlikely(ret != 0))
41 + netdata_log_error("COND: failed to signal (code %d).", ret);
42 + return ret;
43 +}
44 +
45 +ALWAYS_INLINE int __netdata_cond_wait(netdata_cond_t *cond, netdata_mutex_t *mutex)
46 +{
47 + int ret = pthread_cond_wait(cond, mutex);
48 + if (unlikely(ret != 0))
49 + netdata_log_error("COND: failed to signal (code %d).", ret);
50 + return ret;
51 +}
52 +
53 +ALWAYS_INLINE int __netdata_cond_timedwait(netdata_cond_t *cond, netdata_mutex_t *mutex, struct timespec *tp)
54 +{
55 + int ret = pthread_cond_timedwait(cond, mutex, tp);
56 + return ret;
57 +}
58 +
59 ALWAYS_INLINE int __netdata_mutex_init(netdata_mutex_t *mutex) {
60 int ret = pthread_mutex_init(mutex, NULL);
61 if(unlikely(ret != 0))
src/libnetdata/locks/locks.h
+13
@@ -11,6 +11,7 @@
11 // #endif
12
13 typedef pthread_mutex_t netdata_mutex_t;
14 +typedef pthread_cond_t netdata_cond_t;
15
16 #ifdef NETDATA_TRACE_RWLOCKS
17
@@ -59,6 +60,12 @@ typedef struct netdata_rwlock_t {
60
61 #endif // NETDATA_TRACE_RWLOCKS
62
63 +int __netdata_cond_init(netdata_cond_t *cond);
64 +int __netdata_cond_destroy(netdata_cond_t *cond);
65 +int __netdata_cond_signal(netdata_cond_t *cond);
66 +int __netdata_cond_wait(netdata_cond_t *cond, netdata_mutex_t *mutex);
67 +int __netdata_cond_timedwait(netdata_cond_t *cond, netdata_mutex_t *mutex, struct timespec *tp);
68 +
69 int __netdata_mutex_init(netdata_mutex_t *mutex);
70 int __netdata_mutex_destroy(netdata_mutex_t *mutex);
71 int __netdata_mutex_lock(netdata_mutex_t *mutex);
@@ -125,4 +132,10 @@ int netdata_rwlock_trywrlock_debug( const char *file, const char *function, cons
132
133 #endif // NETDATA_TRACE_RWLOCKS
134
135 +#define netdata_cond_init(cond) __netdata_cond_init(cond)
136 +#define netdata_cond_destroy(cond) __netdata_cond_destroy(cond)
137 +#define netdata_cond_signal(cond) __netdata_cond_signal(cond)
138 +#define netdata_cond_wait(cond, mutex) __netdata_cond_wait(cond, mutex)
139 +#define netdata_cond_timedwait(cond, mutex, tp) __netdata_cond_timedwait(cond, mutex, tp)
140 +
141 #endif //NETDATA_LOCKS_H
src/ml/ml_queue.cc
+5 -5
@@ -8,7 +8,7 @@ ml_queue_t *ml_queue_init()
8 ml_queue_t *q = new ml_queue_t();
9
10 netdata_mutex_init(&q->mutex);
11 - pthread_cond_init(&q->cond_var, NULL);
11 + netdata_cond_init(&q->cond_var);
12 q->exit = false;
13 return q;
14 }
@@ -16,7 +16,7 @@ ml_queue_t *ml_queue_init()
16 void ml_queue_destroy(ml_queue_t *q)
17 {
18 netdata_mutex_destroy(&q->mutex);
19 - pthread_cond_destroy(&q->cond_var);
19 + netdata_cond_destroy(&q->cond_var);
20 delete q;
21 }
22
@@ -40,7 +40,7 @@ void ml_queue_push(ml_queue_t *q, const ml_queue_item_t req)
40 break;
41 }
42
43 - pthread_cond_signal(&q->cond_var);
43 + netdata_cond_signal(&q->cond_var);
44 netdata_mutex_unlock(&q->mutex);
45 }
46
@@ -52,7 +52,7 @@ ml_queue_item_t ml_queue_pop(ml_queue_t *q)
52 req.type = ML_QUEUE_ITEM_STOP_REQUEST;
53
54 while (q->create_model_queue.empty() && q->add_model_queue.empty()) {
55 - pthread_cond_wait(&q->cond_var, &q->mutex);
55 + netdata_cond_wait(&q->cond_var, &q->mutex);
56
57 if (q->exit) {
58 netdata_mutex_unlock(&q->mutex);
@@ -93,7 +93,7 @@ void ml_queue_signal(ml_queue_t *q)
93 {
94 netdata_mutex_lock(&q->mutex);
95 q->exit = true;
96 - pthread_cond_signal(&q->cond_var);
96 + netdata_cond_signal(&q->cond_var);
97 netdata_mutex_unlock(&q->mutex);
98 }
99
src/ml/ml_queue.h
+1 -1
@@ -53,7 +53,7 @@ struct ml_queue_t {
53 ml_queue_stats_t stats;
54
55 netdata_mutex_t mutex;
56 - pthread_cond_t cond_var;
56 + netdata_cond_t cond_var;
57 std::atomic<bool> exit;
58 };
59