top: snapshot /proc/stat reads to minimize distortions
Almost forever, top has been accessing the /proc/stat/
directory one line at a time until either smp_num_cpus
was reached or (more recently) Screen_rows is reached.
When NUMA/Nodes support is enabled screen rows will no
longer serve as a limit because all cpus must be read.
With this commit, the entire /proc/stat/ directory can
be read at once so all statistics will be frozen. Thus
individual cpus will no longer keep "ticing" until top
gets around to accessing them via some separate fgets.
The distortion this commit eliminates was quite easily
seen when comparing old/new tops using: individual cpu
stats vs. cpu summary; a healthy delay interval of 3-5
seconds; manually synchronized update cycles (the hard
part); some system loading (maybe another top at -d0).
Additionally, this patch eliminates some long standing
unnecessary initialization made possible because of an
allocation via calloc. If some parts are never touched
by sscanf due to a kernel version, it's unnecessary to
repeatedly re-initialize those portions to zero again.
Reference(s):
. numa extensions added
commit
8d989c68c068541a814bf0d2340ac9b0373f24b5
. useless initialization evolution (old to new)
commit
e54c8239b1c46cf7b99dd6120c9090303fa969c8
commit
9278134e49b6bf4d6e05c40f63cc6d6d6936e01b
commit
fd62123562c2b71f292d3d3ee1a085709048b11a
commit
f348575edc915db9df89acfb3f292920726ffe9a
Signed-off-by: Jim Warner <james.warner@comcast.net>