X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fsys_fs_cgroup.c;fp=src%2Fsys_fs_cgroup.c;h=faeb7c930c6d8189af7483196a659f07cdb48a1a;hb=32fe91cb025e0f53e9430b4bf55d97f8c6f2a15d;hp=4914b2ed99a839e595d01be6586b1213d5323c85;hpb=187ff150aa6ead4274348d071039abb22313e080;p=netdata.git diff --git a/src/sys_fs_cgroup.c b/src/sys_fs_cgroup.c index 4914b2ed..faeb7c93 100644 --- a/src/sys_fs_cgroup.c +++ b/src/sys_fs_cgroup.c @@ -2082,24 +2082,20 @@ void *cgroups_main(void *ptr) { RRDSET *stcpu_thread = NULL; + heartbeat_t hb; + heartbeat_init(&hb); usec_t step = cgroup_update_every * USEC_PER_SEC; - usec_t find_every = cgroup_check_for_new_every * USEC_PER_SEC, find_next = 0; + usec_t find_every = cgroup_check_for_new_every * USEC_PER_SEC, find_dt = 0; for(;;) { - usec_t now = now_monotonic_usec(); - usec_t next = now - (now % step) + step; - - while(now < next) { - sleep_usec(next - now); - now = now_monotonic_usec(); - } - + usec_t hb_dt = heartbeat_next(&hb, step); if(unlikely(netdata_exit)) break; // BEGIN -- the job to be done - if(unlikely(now >= find_next)) { + find_dt += hb_dt; + if(unlikely(find_dt >= find_every)) { find_all_cgroups(); - find_next = now + find_every; + find_dt = 0; } read_all_cgroups(cgroup_root);