@cryptotaxi247 / netdata-1 / commits / 872430fe2

- Retrieve current affinity of the process and make sure not to (#7318)

* - Retrieve current affinity of the process and make sure not to start an idle thread (wake_cpu_thread) if the core is not in the allowed cpu set. * - Use pthread_getaffinity_np to match wake_cpu_thread that uses pthread_setaffinity_np - Add error check + error logging

Stelios Fragkakis committed Nov 18, 2019 at 20:17 UTC 872430fe297fa888e101237ea7494d9d8ce337fb
1 file changed +9
collectors/proc.plugin/proc_stat.c
+9
@@ -993,6 +993,15 @@ int do_proc_stat(int update_every, usec_t dt) {
993 for(core = 0; core < schedstat_cores_found; core++) {
994 if(unlikely(!(cpuidle_charts[core].active_time - cpuidle_charts[core].last_active_time))) {
995 pthread_t thread;
996 + cpu_set_t global_cpu_set;
997 +
998 + if (likely(!pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &global_cpu_set))) {
999 + if (unlikely(!CPU_ISSET(core, &global_cpu_set))) {
1000 + continue;
1001 + }
1002 + }
1003 + else
1004 + error("Cannot read current process affinity");
1005
1006 if(unlikely(pthread_create(&thread, NULL, wake_cpu_thread, (void *)&core)))
1007 error("Cannot create wake_cpu_thread");