summaryrefslogtreecommitdiffstats
path: root/collectors/proc.plugin
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2019-11-18 20:17:40 +0200
committerGitHub <noreply@github.com>2019-11-18 20:17:40 +0200
commit872430fe297fa888e101237ea7494d9d8ce337fb (patch)
tree7b625c7a40fbcc7022d811d857259f7ff69b8926 /collectors/proc.plugin
parente70e8c8ccf520c699c2fba458bf7cf48dd21534c (diff)
- 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
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r--collectors/proc.plugin/proc_stat.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/collectors/proc.plugin/proc_stat.c b/collectors/proc.plugin/proc_stat.c
index f98b095619..5e6b79fc8c 100644
--- a/collectors/proc.plugin/proc_stat.c
+++ b/collectors/proc.plugin/proc_stat.c
@@ -993,6 +993,15 @@ int do_proc_stat(int update_every, usec_t dt) {
for(core = 0; core < schedstat_cores_found; core++) {
if(unlikely(!(cpuidle_charts[core].active_time - cpuidle_charts[core].last_active_time))) {
pthread_t thread;
+ cpu_set_t global_cpu_set;
+
+ if (likely(!pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &global_cpu_set))) {
+ if (unlikely(!CPU_ISSET(core, &global_cpu_set))) {
+ continue;
+ }
+ }
+ else
+ error("Cannot read current process affinity");
if(unlikely(pthread_create(&thread, NULL, wake_cpu_thread, (void *)&core)))
error("Cannot create wake_cpu_thread");