Commit Graph

13 Commits

Author SHA1 Message Date
Jim Warner
ce1410a51a top: fixup logic for Nehalem cpu 'idle' threshold
Due to a poorly constructed temporary fprintf
used during development, an earlier commit went
a little too far in its computations.  The net
result was the code looked nice but actually
accomplished nothing.

It is the /proc/stat line 1 (summary line)
whose tics must be used in establishing the
threshold boundary.  And that calculation
need be performed just once per frame.

This commit ensures one threshold calculation
per delay interval no matter how many cpus
are ultimately displayed.

It also corrects scalability by factoring in
the total number of online processors.

Reference:
commit 9e7dd43ab7
2012-02-10 07:01:10 +11:00
Jim Warner
9e7dd43ab7 top: tweak the new 'reduce % CPU distortions' algorithm
The original approach to potential % CPU distortion due
to Nehalem type cores being turned off completely when
idle worked ok until the user typed something.

At that point, elapsed tics would no longer equal the
calculated value producing an undesirable 100% idle
condition until the next update or <Enter/Space> key.

This commit employs actual elapsed tics in determining
whether a cpu should be considered idle and thus makes
top's individual cpu display immune to user keystrokes.
2012-02-08 21:00:00 +11:00
Jim Warner
a9041a5526 top: reduce % CPU distortions when a core was turned off
This patch provides for cpu cores which can be turned
off completely when idle (Nehalem, etc.) thus registering
very few or no tics since the last update cycle.

When CPU_ZEROTICS is not defined (the default), any
displayed cpu with less than a certain amount of total
tics will show as 100% idle.  That amount is tempered
by the delay interval and total number of cpus.

This commit also satisfies the Debian 'top_nohz' patch
(11/24/09) in a slightly more efficient manner.  That
patch concerned kernels built with CONFIG_NO_HZ.

Reference:
http://www.freelists.org/post/procps/CStates-handling-new-switch,4
2012-02-08 20:57:58 +11:00
Jim Warner
f348575edc top: tolerate loss of smp cpus, improve CPU_t management
Prior to this patch, top was able to handle any hotplugged
cpus *added* to the system in two distinct ways.

 1) Newly added cpus would be detected by sysinfo_refresh
    calling the library's cpuinfo function, which occurs
    at most every 5 minutes.

 2) The user could force a refresh using either the
    <Enter> or <Space> keys.

Unfortunately, the *loss* of a cpu would produce an early
exit due to a /proc/stat read failure.  Such a failure
can be produced in the following way:
  sudo echo 0 > /sys/devices/system/cpu/cpu??/online

This commit allows top to tolerate the loss of cpus.
It also provides for more efficient CPU_t management,
especially for massively parallel cpu environments.

Note: Changes to the cpu compliment can produce a single
cycle distortion of cpu percentages.  Such distortion is
most visible when each cpu is being displayed.  It can
be eliminated with a forced refresh via <Enter>/<Space>.
2012-02-08 20:57:51 +11:00
Jim Warner
b73a423cc2 top: avoid %cpu distortions when toggling task/thread modes
This commit addresses a long standing buglet (debian #441166) which
surfaces when the display mode is switched between task and threads.

An extra procps refresh is now forced upon such a transition which
parallels the approach used at startup for the exact same reason.

Reference: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441166
2012-01-14 00:04:46 +11:00
Jim Warner
e64b6f70d7 top: update some programmer documentation (no logic, just comments)
This commit corrects some outdated programmer comments.

Additionally, certain nls justifications might become
increasingly obscure with the passage of time so some
previous nls commit text has been added as comments.
2012-01-04 08:58:54 +11:00
Jim Warner
edb71e5044 top: made prolog comments like those in procps:master 2011-12-22 23:48:05 +11:00
Jim Warner
acd73a1365 top: provided for nls table integrity validation 2011-12-22 23:48:05 +11:00
Jim Warner
fe7069dff0 top: corrected double #include missed at rebase 2011-12-22 23:48:05 +11:00
Jim Warner
434198e6e4 top: corrected missed escape seq from redesign 2011-12-22 23:48:05 +11:00
Jim Warner
bc0f73e335 top: added #include of proc/readproc.h to top.h 2011-12-22 23:48:04 +11:00
Jim Warner
3f7468082a top: finalized top nls support (or so he thought)
summary of changes:
. adopted relative paths to 'include' and 'proc'
  dirs so that stand alone compiles are made
  easier and no one need guess their locations

. corrected several names for enums and macro
  usage reflecting fmt vs. txt

. expanded all octal escape sequences to a full
  3 digits since one already required 3 digits

. finalized translator hints (for now)

programming note:
  as an aside, by not including an argument for
  the gettext --add-comments, any preceeding c
  style comment will be propagated to the .pot
  file, if the gettext macro isn't empty.

  /* Need Not Say 'TRANSLATORS' ...
  snprintf(buf, sizeof(buf), "%s", _(   // unseen
  /* Translator Hint: ...
  snprintf(buf, sizeof(buf), "%s", _("" // seen
2011-12-22 23:48:04 +11:00
Jim Warner
32a9adbc13 top: provide extensive, generalized nls support
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2011-12-22 23:48:04 +11:00