procps/src
Jim Warner 7e33fc47c6 top: avoid '%Cpu' distortion resulting from keystrokes
Like a line from the movie Cool Hand Luke: "what we've
got here is failure to communicate"; well that was me!

Finally, I got a handle on the issue referenced below.

At first, it seemed inappropriate to try comparing cpu
percentages as reported by different top versions. And
even more so when they are invoked many seconds apart.

As it turns out, this issue had nothing to do with the
specific processor. Nor did it involve two versions of
top running simultaneously using the same delay value.
Rather, it concerns keyboard input and several changes
which were made last year in commits referenced below.

They were prompted by development of the 'Ctrl' bottom
window feature. Initially, if transitioning from a big
window to a small window portions of the former window
remained visible until the next refresh. A solution to
that led to a flaw when resizing top. Fixing that then
created a race condition with full screen replacement.

The net effect of all those changes was to distort the
cpu percentage value for the processor on which top is
dispatched to service user input. It arose because the
new frame was begun immediately, yielding few 'ticks'.

[ when fewer ticks are accumulated the potential for ]
[ distortion increases. As an example, hold some key ]
[ then watch cpu percentages (works best in graphs). ]

[ while any version of top will show distortions for ]
[ the above experiment, a v4.0.0 top will be greater ]
[ and %cpu is distorted even for a single keystroke. ]

So, to restore proper 3.3.17 keystroke behavior, we'll
revert parts of the first 3 commits shown below. Plus,
the 4th commit will be entirely reversed as redundant.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/274

. Sep, 2022 - avoid potential 'BREAK_screen' race
commit 3e5016c289
. Sep, 2022 - fix improper sigwinch behavior
commit 9d9993708b
. May, 2022 - made more responsive to kdb input
commit 3ea1bc779f
. turn bottom window off with additional key
commit 3f068a66c8

Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-03-09 20:16:47 +11:00
..
ps misc: Update the copyrights for the ps and top sources 2023-02-08 16:53:04 +11:00
tests tests: Dont compare floats with == 2023-03-01 17:20:42 +11:00
top top: avoid '%Cpu' distortion resulting from keystrokes 2023-03-09 20:16:47 +11:00
free.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
kill.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
pgrep.c pgrep: Use only --signal option for signal 2023-03-01 17:35:14 +11:00
pidof.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
pmap.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
pwdx.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
skill.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
slabtop.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
sysctl.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
tload.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
uptime.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
vmstat.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00
w.c w: make sure null terminated ut_* strings are used 2023-03-08 07:30:56 +11:00
watch.c misc: Update the copyrights of files 2023-02-07 21:09:48 +11:00