Sami Kerola [Mon, 13 Feb 2012 20:21:43 +0000 (21:21 +0100)]
sysctl: deprecate parameters
According to arp(7) manual page base_reachable_time and retrans_time
are obsolete since kernel 2.6.12. Based on that the print all listing
will not show these two parameters, and attempt to set them will fail.
Jim Warner [Tue, 7 Feb 2012 17:11:11 +0000 (11:11 -0600)]
top: standardize names of all 'helper' functions
The top program is carefully organized into sections
and those sections are carefully placed so as to avoid
the need for prototypes. *
Additionally, names of functions are carefully chosen
to maintain alphabetical order within each section.
The names of most 'helper' functions, which are always
placed immediately above the calling functions, often
only met the spirit of the alphabetical law, not the
actual letter of that law.
This commit alters the names of such helper functions
so as to mainatin strict ascii alphabetical order
within each section.
* the single exception to prototypes is find_string,
which calls the task_show function, and would have
prompted a massive reorganization.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Tue, 7 Feb 2012 05:59:59 +0000 (23:59 -0600)]
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, <jcapik@redhat.com>
Sami Kerola [Sat, 11 Feb 2012 19:02:54 +0000 (20:02 +0100)]
pgrep: allow signal definition to be anywhere in command line
I as user often try to pkill something, notice that program did not
die and pkill again with signal -9. Before this commit previous one
could not add signal at the end of command line, as the signal
definition had to be first argument, which was annoying.
Sami Kerola [Thu, 9 Feb 2012 20:18:14 +0000 (21:18 +0100)]
tests: fix dejagnu pwdx and vmstat checks
The pwdx check expected error message, which where in use for only
short period of time. The old message was put in place in commit 9d47cb0c38137581a46951fb7c6fa2a1dc8c24cf
The vmstat issue was triggered by 'sr0' cdrom device, which gives
following unexpected output. Fix simply ignores partitions which has
zero activity. Besides such partitions probably would not apply as
good candidate of -p option anyway.
$ vmstat -p sr0
Partition was not found
Reported-By: Moritz Muehlenhoff <jmm@debian.org>
Bug-Debian: http://bugs.debian.org/656508 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Jim Warner [Thu, 9 Feb 2012 05:59:59 +0000 (23:59 -0600)]
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.
Jim Warner [Tue, 7 Feb 2012 21:15:15 +0000 (15:15 -0600)]
top: reduce use of 'clear_screen' to absolute minimum
Along the way to width override support (-w switch),
this top began clearing the screen far more often
than his predecessor. In fact, it happend with each
user keystroke.
This commit dramatically reduces those occurances.
The screen will now be cleared only when an actual
SIGWINCH is received.
Thanks for identifying this flaw belongs to:
James Cloos, cloos@jhcloos.com
Blame: c2dcbef4826806f85b7ad6de2d9fe99bc390d603
Author: Jim Warner <james.warner@comcast.net>
Date: Thu May 26 11:33:32 2011 +0200
subject: added output width/height override support to top, + misc
Jim Warner [Tue, 7 Feb 2012 16:10:10 +0000 (10:10 -0600)]
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.
Jim Warner [Fri, 3 Feb 2012 06:00:00 +0000 (00:00 -0600)]
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.
Jim Warner [Wed, 1 Feb 2012 06:00:00 +0000 (00:00 -0600)]
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>.
Jim Warner [Mon, 23 Jan 2012 20:44:13 +0000 (14:44 -0600)]
top: treat additional keys like the find_string() keys
With the introduction of the 'locate string' provisions,
the precedent for calling tertiary helper functions from
secondary do_key helper functions was established.
This commit simply migrates some additional keys out of
the do_key function itself and into the more generalized
key table.
Jim Warner [Thu, 19 Jan 2012 20:33:34 +0000 (14:33 -0600)]
top: improve USE_X_COLHDR effect when colors toggled off
Normally, when the chosen sort column is displayed via the
'x' command toggle the entire column is highlighted. And
while this version of top substantially reduced the cost
of such highlighting, a small pathlength increase remained.
The USE_X_COLHDR define was an experimental alternative which
eliminated all recurring runtime costs for such emphasis by
highlighting the column header, not the entire column.
The previous implementation required colors to be turned on
(the 'z' toggle) for such highlighting to be visible. This
commit extends column header emphasis to include monochrome
displays as well.
Jim Warner [Fri, 13 Jan 2012 22:07:40 +0000 (16:07 -0600)]
top: properly handle an improper $HOME environment variable
Since its inception, this top has improperly handled an
empty HOME environment variable. Under those conditions
a path to the root directory would have been constructed.
That caused no real harm upon startup since the display
defaults would have been employed. However, except for
root, it would have been impossible to save the rc file.
This commit keeps the promise made in the documentation.
Sami Kerola [Sun, 5 Feb 2012 20:43:36 +0000 (21:43 +0100)]
pmap: ensure arg1 is not null, and set qualifers to match with usage [smatch scan]
pmap.c:436 main(59) error: we previously assumed 'arg1' could be null (see line 427)
pmap.c:136:3: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:142:4: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:150:2: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:300:8: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
Sami Kerola [Tue, 24 Jan 2012 20:54:01 +0000 (21:54 +0100)]
libprocps: hide private symbols
Clean the global list of symbols contain only functions and variables which
are being called from library. The removed symbols are internal for the
library, which means they can be changed without changes to programs using
the library. This clean up should help incoming libprocps clean up work.
Mike Frysinger [Tue, 24 Jan 2012 05:44:05 +0000 (00:44 -0500)]
ps: include error.h
This code currently uses error_at_line() from error.h, so pull it in.
Long term, this might get moved to c.h as a local helper on err.h,
but I have no idea.
Mike Frysinger [Tue, 24 Jan 2012 05:41:39 +0000 (00:41 -0500)]
proc: pull in ctype.h where needed
Fix the build warnings:
sig.c:227:5: warning: implicit declaration of function 'toupper' [-Wimplicit-function-declaration]
sig.c:231:3: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
Sami Kerola [Sat, 21 Jan 2012 12:24:02 +0000 (13:24 +0100)]
pkill: enable displaying what is killed
Add new command line options -e, --echo to display what is
killed. Cost of this change is greater run time memory footprint,
because an union had to be changed to struct to allow name and
pid printing which what I as an user would expect to see in
verbose kill output.
Sami Kerola [Fri, 13 Jan 2012 21:38:47 +0000 (22:38 +0100)]
ps: unify cases and remove trailing dots in messages
Strings with lower caps & no trailing dots have greater change to
have multiple occurences, meaning less effort for translators, than
strings with them.
Jim Warner [Fri, 6 Jan 2012 14:49:21 +0000 (08:49 -0600)]
vmstat: slabinfo (-m option) test disabled if not readable
The dejagnu tests for slabtop are skipped when "/proc/slabinfo" is
unreadable due to permissions. This commit provides the same check
for vmstat under its -m (slabinfo) option.
Craig Small [Fri, 13 Jan 2012 12:59:26 +0000 (23:59 +1100)]
sysctl -p has no space
The man page has examples like sysctl -p filename. Optional arguments
using getopt cannot have a space between the option and argument.
So the correct format is sysctl -pfilename
Craig Small [Mon, 9 Jan 2012 10:57:44 +0000 (21:57 +1100)]
Linux version for non-linux systems
On non-linux systems, uts.version provides the version of that
specific kernel (FreeBSD or Hurd version, for example) and not the
emulated procfs pseudo version.
On those systems we need to directly read /proc/version and parse the
string. This change replaces Debian patches gnu-kbsd-version and
complain_unmounted_proc patches.
Craig Small [Mon, 9 Jan 2012 10:44:51 +0000 (21:44 +1100)]
Change restrict to __restrict in public includes
procps automake defines restrict which means the binaries for procps
binaries compile. However external programs may not of defined
restrict which means they will not complie if they include files found
in /usr/include/proc.
Includes from libc6 use __restrict and if is good enough for
them, its good enough for us.
Craig Small [Mon, 9 Jan 2012 10:40:53 +0000 (21:40 +1100)]
watch needs a conditonal LDADD
Makes Debian patch makefile_watch_ncurses redundant.
watch was being linked to NCURSES_LIBS when it should of been
WATCH_NCURSES_LIBS which can be ncursesw with 8bit enabled.
Craig Small [Wed, 4 Jan 2012 22:37:58 +0000 (09:37 +1100)]
For free -b make the variable a long long
Bug-Debian: http://bugs.debian.org/654368
On systems with very large amonut of RAM when they use the -b or --bytes
option on free you get overflow and free shows a negative amount of
memory, which is obviously wrong.
Craig Small [Tue, 3 Jan 2012 22:53:51 +0000 (09:53 +1100)]
free -c option uses strutils
The handling of the -c (count) option in free uses the standard string
handling and error utils. The program also checks for negative counts
and errors on these.
Craig Small [Tue, 3 Jan 2012 22:18:16 +0000 (09:18 +1100)]
fixed e and x options in watch
The -e option would print a confusing error message. This is because
most error messages in watch are one word. This fix makes a more
sensible message about what went wrong.
The -x option exited before the endwin() function was called, so if the
child process died the terminal was left in a funky state. endwin is now
called just before the exit(8) for the -x option.
Jim Warner [Mon, 2 Jan 2012 15:08:58 +0000 (09:08 -0600)]
build-sys: correct all Makefile.am files for LOCALEDIR, etc
Some of the latest changes to Makefile.am files are missing.
This patch restores the LOCALEDIR variable, among others,
and dispenses with the include directives in the ps/ and top/
subdirectories since they're no longer needed.
Jim Warner [Thu, 29 Dec 2011 17:50:32 +0000 (11:50 -0600)]
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.
Jim Warner [Mon, 2 Jan 2012 07:33:34 +0000 (01:33 -0600)]
ps: generalize help text logic, add related translator hints
This commit represents an experiment in nls help text support.
The word --help itself been made translatable along with the
help section names and their abbreviations. Thus, the work of
the translators will ultimately alter program run-time behavior.
Perhaps someday all "long" options can behave in a similar way
which could offer a considerable benefit to other languages.
Instead of translationg just option descriptions, the long
forms of those options could also be transalated.
This commit also:
. includes the section abbreviations in --help output
. isolates all --help support in the ps/help.c module
. provides (hopefully) meaningful Translator guidance
. removes --help support from the ps/common.h header
. removes --help support from the ps/parser.c module
. eliminates tabs in line with the style of other ps modules
. eliminates the need for the include/c.h header file
Craig Small [Tue, 3 Jan 2012 07:48:43 +0000 (18:48 +1100)]
Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers. However their consiseness is useful!
The solution is to use some macros that create xerr etc which then
just map to the error() function. The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name
This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.