@cryptotaxi247 / netdata-1 / commits / 549e4621a

added worker jobs for cgroup-rename, cgroup-network and cgroup-first-time (#12910)

Costa Tsaousis committed May 15, 2022 at 15:14 UTC 549e4621a9cd1cbc212ec8620ebd4afcc031fb81
1 file changed +36 -29
collectors/cgroups.plugin/sys_fs_cgroup.c
+36 -29
@@ -6,6 +6,28 @@
6 #define PLUGIN_CGROUPS_MODULE_SYSTEMD_NAME "systemd"
7 #define PLUGIN_CGROUPS_MODULE_CGROUPS_NAME "/sys/fs/cgroup"
8
9 +// main cgroups thread worker jobs
10 +#define WORKER_CGROUPS_LOCK 0
11 +#define WORKER_CGROUPS_READ 1
12 +#define WORKER_CGROUPS_CHART 2
13 +
14 +// discovery cgroup thread worker jobs
15 +#define WORKER_DISCOVERY_INIT 0
16 +#define WORKER_DISCOVERY_FIND 1
17 +#define WORKER_DISCOVERY_PROCESS 2
18 +#define WORKER_DISCOVERY_PROCESS_RENAME 3
19 +#define WORKER_DISCOVERY_PROCESS_NETWORK 4
20 +#define WORKER_DISCOVERY_PROCESS_FIRST_TIME 5
21 +#define WORKER_DISCOVERY_UPDATE 6
22 +#define WORKER_DISCOVERY_CLEANUP 7
23 +#define WORKER_DISCOVERY_COPY 8
24 +#define WORKER_DISCOVERY_SHARE 9
25 +#define WORKER_DISCOVERY_LOCK 10
26 +
27 +#if WORKER_UTILIZATION_MAX_JOB_TYPES < 11
28 +#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 11
29 +#endif
30 +
31 // ----------------------------------------------------------------------------
32 // cgroup globals
33
@@ -2608,6 +2630,7 @@ static inline void discovery_process_cgroup(struct cgroup *cg) {
2630 }
2631
2632 if (cg->first_time_seen) {
2633 + worker_is_busy(WORKER_DISCOVERY_PROCESS_FIRST_TIME);
2634 discovery_process_first_time_seen_cgroup(cg);
2635 if (unlikely(cg->first_time_seen || cg->processed)) {
2636 return;
@@ -2615,6 +2638,7 @@ static inline void discovery_process_cgroup(struct cgroup *cg) {
2638 }
2639
2640 if (cg->pending_renames) {
2641 + worker_is_busy(WORKER_DISCOVERY_PROCESS_RENAME);
2642 discovery_rename_cgroup(cg);
2643 if (unlikely(cg->pending_renames || cg->processed)) {
2644 return;
@@ -2644,22 +2668,10 @@ static inline void discovery_process_cgroup(struct cgroup *cg) {
2668 return;
2669 }
2670
2671 + worker_is_busy(WORKER_DISCOVERY_PROCESS_NETWORK);
2672 read_cgroup_network_interfaces(cg);
2673 }
2674
2650 -#define WORKER_DISCOVERY_INIT 0
2651 -#define WORKER_DISCOVERY_FIND 1
2652 -#define WORKER_DISCOVERY_PROCESS 2
2653 -#define WORKER_DISCOVERY_UPDATE 3
2654 -#define WORKER_DISCOVERY_CLEANUP 4
2655 -#define WORKER_DISCOVERY_COPY 5
2656 -#define WORKER_DISCOVERY_SHARE 6
2657 -#define WORKER_DISCOVERY_LOCK 7
2658 -
2659 -#if WORKER_UTILIZATION_MAX_JOB_TYPES < 8
2660 -#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 8
2661 -#endif
2662 -
2675 static inline void discovery_find_all_cgroups() {
2676 debug(D_CGROUP, "searching for cgroups");
2677
@@ -2704,14 +2716,17 @@ void cgroup_discovery_worker(void *ptr)
2716 UNUSED(ptr);
2717
2718 worker_register("CGROUPSDISC");
2707 - worker_register_job_name(WORKER_DISCOVERY_INIT, "init");
2708 - worker_register_job_name(WORKER_DISCOVERY_FIND, "find");
2709 - worker_register_job_name(WORKER_DISCOVERY_PROCESS, "process");
2710 - worker_register_job_name(WORKER_DISCOVERY_UPDATE, "update");
2711 - worker_register_job_name(WORKER_DISCOVERY_CLEANUP, "cleanup");
2712 - worker_register_job_name(WORKER_DISCOVERY_COPY, "copy");
2713 - worker_register_job_name(WORKER_DISCOVERY_SHARE, "share");
2714 - worker_register_job_name(WORKER_DISCOVERY_LOCK, "lock");
2719 + worker_register_job_name(WORKER_DISCOVERY_INIT, "init");
2720 + worker_register_job_name(WORKER_DISCOVERY_FIND, "find");
2721 + worker_register_job_name(WORKER_DISCOVERY_PROCESS, "process");
2722 + worker_register_job_name(WORKER_DISCOVERY_PROCESS_RENAME, "rename");
2723 + worker_register_job_name(WORKER_DISCOVERY_PROCESS_NETWORK, "network");
2724 + worker_register_job_name(WORKER_DISCOVERY_PROCESS_FIRST_TIME, "new");
2725 + worker_register_job_name(WORKER_DISCOVERY_UPDATE, "update");
2726 + worker_register_job_name(WORKER_DISCOVERY_CLEANUP, "cleanup");
2727 + worker_register_job_name(WORKER_DISCOVERY_COPY, "copy");
2728 + worker_register_job_name(WORKER_DISCOVERY_SHARE, "share");
2729 + worker_register_job_name(WORKER_DISCOVERY_LOCK, "lock");
2730
2731 while (!netdata_exit) {
2732 worker_is_idle();
@@ -4889,14 +4904,6 @@ static void cgroup_main_cleanup(void *ptr) {
4904 static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
4905 }
4906
4892 -#define WORKER_CGROUPS_LOCK 0
4893 -#define WORKER_CGROUPS_READ 1
4894 -#define WORKER_CGROUPS_CHART 2
4895 -
4896 -#if WORKER_UTILIZATION_MAX_JOB_TYPES < 3
4897 -#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 3
4898 -#endif
4899 -
4907 void *cgroups_main(void *ptr) {
4908 worker_register("CGROUPS");
4909 worker_register_job_name(WORKER_CGROUPS_LOCK, "lock");