From 282ee362f0e1754604633db5e791266912d7b3ce Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 31 Dec 2016 00:00:00 -0600 Subject: [PATCH] library : improve response to cpu offline/online With the addition of those new derived SUM values, any CPUs taken offline or brought online would distort the historical (delta) results. So this patch just forces a history reset when such transitions are encountered. Reference(s): . derived SUM provisions introduced commit 2c86c4984a15c9ab912402838c6651f466a3d2ed Signed-off-by: Jim Warner --- proc/stat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/proc/stat.c b/proc/stat.c index 758d983a..2e5f84b6 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -76,6 +76,7 @@ struct hist_sys { struct hist_tic { int id; + int id_sav; int numa_node; int count; struct stat_jifs new; @@ -635,14 +636,16 @@ reap_em_again: , &cpu_ptr->new.idle, &cpu_ptr->new.iowait, &cpu_ptr->new.irq , &cpu_ptr->new.sirq, &cpu_ptr->new.stolen , &cpu_ptr->new.guest, &cpu_ptr->new.gnice))) { - int id_sav = cpu_ptr->id; - memmove(cpu_ptr, sum_ptr, sizeof(struct hist_tic)); - cpu_ptr->id = id_sav; + cpu_ptr->id_sav = -1; break; // we must tolerate cpus taken offline } stat_derive_unique(cpu_ptr); - ++i; + // don't distort deltas when a cpu is taken offline or brought online + if (cpu_ptr->id != cpu_ptr->id_sav) + memcpy(&cpu_ptr->old, &cpu_ptr->new, sizeof(struct stat_jifs)); + cpu_ptr->id_sav = cpu_ptr->id; ++cpu_ptr; + ++i; } while (i < info->cpus.hist.n_alloc); if (i == info->cpus.hist.n_alloc && rc >= 8) {