From 02508b3d76af5bc33c7e559b84d3e5e123cdf2ac Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 6 Feb 2012 23:59:59 -0600 Subject: [PATCH] top: use CPU_ZEROTICS to embrace the Nehalem logic The recently added logic dealing with "missing" tics is mutually exclusive with logic associated with a define called CPU_ZEROTICS. This commit expands the use of that define to exclude such Nehalem logic as appropriate. It also extends programmer notes in top.h to include an attribution for initiating the topic of potential Nehalem type % CPU distortions, acknowledging: Jaromir Capik, References commit ce1410a51a624a91816fcc8c232c8a4d60b09638 commit 9e7dd43ab7b2e68177cefd49b3c07311ea79bc1a commit a9041a5526eddc631b94bac86c09a47e60a3b4e1 --- top/top.c | 5 ++++- top/top.h | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/top/top.c b/top/top.c index 0baa0274..7ae94dac 100644 --- a/top/top.c +++ b/top/top.c @@ -1826,13 +1826,14 @@ static CPU_t *cpus_refresh (CPU_t *cpus) { cpus[Cpu_faux_tot].cur.tot = cpus[Cpu_faux_tot].cur.u + cpus[Cpu_faux_tot].cur.s + cpus[Cpu_faux_tot].cur.n + cpus[Cpu_faux_tot].cur.i + cpus[Cpu_faux_tot].cur.w + cpus[Cpu_faux_tot].cur.x + cpus[Cpu_faux_tot].cur.y + cpus[Cpu_faux_tot].cur.z; +#ifndef CPU_ZEROTICS /* if a Nehalem type cpu has been turned off completely, and thus registers very few total tics, we'll force it to be treated as idle when that total falls below a % of those expected -- other cpus will register their full number of expected tics as 'idle' and thus won't be effected */ cpus[Cpu_faux_tot].edge = ((cpus[Cpu_faux_tot].cur.tot - cpus[Cpu_faux_tot].sav.tot) / smp_num_cpus) / (100 / TICS_EDGE); - +#endif // now value each separate cpu's tics, maybe for (i = 0; i < Cpu_faux_tot && i < Screen_rows; i++) { #ifdef PRETEND4CPUS @@ -1850,7 +1851,9 @@ static CPU_t *cpus_refresh (CPU_t *cpus) { memmove(&cpus[i], &cpus[Cpu_faux_tot], sizeof(CPU_t)); break; // tolerate cpus taken offline } +#ifndef CPU_ZEROTICS cpus[i].edge = cpus[Cpu_faux_tot].edge; +#endif // this is for symmetry only, it's not currently required cpus[i].cur.tot = cpus[Cpu_faux_tot].cur.tot; #ifdef PRETEND4CPUS diff --git a/top/top.h b/top/top.h index e8606878..22a7a073 100644 --- a/top/top.h +++ b/top/top.h @@ -56,12 +56,16 @@ Jan Gorig - April, 2011 */ /* For the motivation and path to nls support, thanks to: - Sami Kerola, */ + Sami Kerola, - December, 2011 */ /* There are still some short strings that may yet be candidates for nls support inclusion. They're identified with: // nls_maybe */ + /* For initiating the topic of potential % CPU distortions due + to Nehalem type processors (see CPU_ZEROTICS), thanks to: + Jaromir Capik, - February, 2012 */ + #ifdef PRETEND2_5_X #define linux_version_code LINUX_VERSION(2,5,43) #endif @@ -225,7 +229,9 @@ typedef struct CT_t { typedef struct CPU_t { CT_t cur; // current frame's cpu tics CT_t sav; // prior frame's cpu tics +#ifndef CPU_ZEROTICS SIC_t edge; // tics adjustment threshold boundary +#endif int id; // the cpu id number (0 - nn) } CPU_t;