Commit Graph

332 Commits

Author SHA1 Message Date
Jim Warner
3a00c7e499 top: exploit <pids> enhancement for control group name
[ but stay tuned! there is a commit coming soon that ]
[ represents a rather major internal redesign, which ]
[ was prompted by the ps and top adaptation testing. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-14 21:49:08 +11:00
Jim Warner
d53e98ff97 misc: adapt ps & top to procps_pids_stacks_sort rename
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-14 21:47:19 +11:00
Jim Warner
657ac2e0c7 top: extend '=' key to include active 'locate' request
It is documented behavior that when certain other keys
are active, sorts column highlighting will temporarily
be disabled. Among those keys is the 'L' (locate/find)
provision. The equals ('=') key can be used to restore
column highlighting by resetting other keys, except 1.

When a locate/find is active, the '=' key will have no
effect on 'x' column highlighting, which still remains
disabled. Further, when 'L' is active an 'x' keystroke
is processed changing the state of column highlighting
but without any visual clue (since it's yet disabled).

So this commit just extends the '=' key to embrace 'L'
processing resets, just like other highlight disabling
keys while avoiding 'x' state changes if approproiate.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-14 21:35:35 +11:00
Jim Warner
41e7510333 top: correct a flaw in the support for pids monitoring
Ever since top was adapted to the new <pids> interface
there has been a bug that would cause an abnormal exit
when the '-p' argument contained *no* valid pids. This
was never revealed until now since the QA folks tested
only with valid, existing pids. (bunch of morons, eh?)

And even though the program author is blameless he has
taken it upon himself to clean up after the QA jokers.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-09 21:35:28 +11:00
Jim Warner
468c15caa6 top: adapt for normailzed <pids> select/fill interface
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-05 21:50:23 +11:00
Jim Warner
683b3fd4f2 top: streamline the approach to tracking relative enum
Two separate entries under the Fieldstab were employed
to manage 'relative' enumerators under that new <pids>
interface. However, just a single entry could actually
serve both needs with a negative 'not selected' value.

So this commit just borrows the approach used with the
ps conversion where -1 is now representing unselected.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-05 21:30:53 +11:00
Jim Warner
f7fcb33652 top: eliminate an unused error message and its support
This commit just eliminates an error message no longer
needed under that newlib <pids> interface. Plus, a few
enumerators in the header weren't in alphabetic order.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-05 21:28:39 +11:00
Jim Warner
872be3a3a2 top: trade 'look_up_our_self' for a new API equivalent
With the advent of the 'fatal_proc_unmounted' function
in the <pids.h> API to ensure the /proc filesystem was
mounted, we will finally get rid of the last remaining
vestiges of the former libprocps <readproc> interface.

[ also play a little catch up and whack some headers ]
[ that are not necessary now, beyond that readproc.h ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-21 22:39:10 +10:00
Jim Warner
105c69164b top: update the man document reporting bugs suggestion
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-21 22:35:23 +10:00
Jim Warner
efcbbe93ea top: plug a rather big hole in the display fields dike
Whoa, guess what field got overlooked in that march to
the newlib conversion? It was the TTY guy. However, it
wasn't completely top's fault - that newlib must share
at least some responsibility, for only offering a num.

[ and while we're at it, let's touch up the man page ]
[ to agree with ol' newlib's current implementation. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-09 21:22:44 +10:00
Jim Warner
bb04019510 top: utilize a library result struct for 'forest view'
When top was originally adapted to use that <pids> API,
the forest view support was redesigned since the proc_t
pad_3 byte could no longer be employed to hold a task's
nesting level. The redesign required additional arrays.

Now that the dust is settling on those initial efforts,
that PROCPS_PIDS_noop item was used as a substitute for
the old pad_3 along with a return to the former design.
But, while it proved adequate, the invariant nature for
that item required of top an extra initialization step.

So the library was coaxed into adding one more pid_item
(PROCPS_PIDS_extra) which will, unlike that 'noop' guy,
be reset with each reap. Everybody should be happy now.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-06 21:58:27 +10:00
Jim Warner
b2853ed117 top: do not co-mingle strings/numbers under namespaces
Craig's recent commit under that newlib branch dealing
with namespace support has prompted me to review top's
handling of those fields. Currently, when such a field
is zero, top displays a dash ('-'). This will mean the
justification toggles ('j/J') will behave incorrectly.

This patch simply allows the potential zero to display
or be suppressed with the already existing '0' toggle.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-06 21:57:09 +10:00
Jim Warner
f1bd82ff07 top: still more tidying up after <pids> implementation
A patch containing the following miscellaneous tweaks:

. remove a function that handled former library errors
[ that function should have gone bye-bye with 3.3.11 ]
[ when those 'wchan' provisions were much simplified ]

. make clearer a distinction between 'new' and 'reset'
[ use PROCPS_PIDS_noop when procps_pids_new() called ]
[ since at that point we are only establishing depth ]

Reference(s):
http://www.freelists.org/post/procps/newlib-for-pgrep,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-03 22:37:54 +10:00
Jim Warner
1c597b58ef top: polish some things related to the pids adaptation
A patch containing the following miscellaneous tweaks:

. exploit (actually adapt) a pids.h provided VAL macro
. remove some obsolete, now unused, sort related items
. clarify the comment for specialized extractor macros

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-31 17:47:23 +10:00
Jim Warner
66cd99270d top: respond to library changes regarding self lookups
Just in case, make the old proc_t used in the before()
function static so valgrind doesn't get his panties in
a bunch over the fact the 'cmd' is now dynamic memory.

[ Shouldn't that function, or an equivalent, also be ]
[ part of our new library's implementation? However, ]
[ is it proper for a brand new library to abnormally ]
[ terminate a calling process with a stderr message? ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-26 22:42:02 +10:00
Jim Warner
64238730fa build, library & top: make OOMEM options unconditional
It was probably always wrong to have a variable length
proc_t structure. This patch takes all remaining oomem
former suse only options and makes them unconditional.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:08:18 +10:00
Jim Warner
f0c23e51ec top: misc tweaks to code/comments after pid adaptation
. didn't need a separate table for enum pids_reap_type
since top's 'Thread_mode' itself can be used directly.

. with pids support & the loss of forest_based(), that
forest_adds() function had to be renamed so the prolog
comment regarding naming convention was still honored.

. adapted to a library change to the pids_reap struct.

Signed-off-by: Jim Warner <james.warner@comcast.net>

TOP, respond to library change to the pids_reap struct ...

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:08:18 +10:00
Jim Warner
f937ff8238 top: eliminated old kernel-2.4 & 2.5 support (man too)
The newlib informal cutoff for kernel support seems to
be around release 2.6. This commit eliminates any such
support for really old 2.4 and 2.5 kernels within top.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:07 +10:00
Jim Warner
77dc22b910 top: exploit those new library task/threads provisions
This patch adapts top to exploit the new <proc/pids.h>
interface. And it appears to have reduced top's weight
by a considerable margin. Gone were the sort callbacks
and manipulation of those library flags. Gosh, all top
needs to do now is track some enumerators of interest.

[ whoa, wait just a damn minute. it now appears some ]
[ that weight loss was solely the result of a theft. ]

[ jeeze, we turn our back for just a minute & newlib ]
[ up & steals our pids hashing logic for his history ]
[ needs. oh well, i guess life's just not that fair. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:07 +10:00
Jim Warner
180bbb4032 top: fix unlikely edge case wherein all fields are off
While testing a newlib interface for pids acquisitions
I encountered some unexpected results if an idiot user
(me) turns off all displayable fields. So, this commit
ensures that the PID field will be shown as a minimum.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:01:37 +10:00
Jim Warner
b7fe46a815 top: avoid an unnecessary conversion for 'USED' column
When the USED column was introduced the proc_t.vm_swap
& proc_t.resident values were added together. However,
using 'resident' required an additional PROC_FILL flag
not to mention extra conversion of pages to kibibytes.

So now we'll use an already present vm_rss value which
removes any special handling for top's derived column.

And while we're at it we'll trade some more 'resident'
field uses with that more immediately usable 'vm_rss'.

[ this commit has been adapted for the newlib branch ]

Reference(s):
commit 709785e20b

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:01:21 +10:00
Jim Warner
479845d4f0 top: miscellaneous accumulated tweaks to code/comments
Jeeze, to correct spelling on one single word (incure)
you had to go and align the entire comments paragraph?

[ well, at least there's one other minor code change ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:00:34 +10:00
Jim Warner
cca63f2f66 top: eliminate 'user' from the inspection view headers
Since it's possible that euser name is not being shown
or the horizontal position had been scrolled past that
USER column, then part of those headers will be blank.

So it doesn't make sense to try and show the USER that
is associated with a process at all. Thus, this commit
simply removes the 'user' provision from both headers.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:00:15 +10:00
Jim Warner
aa7ff688db top: improve vertical scroll management for 'i' toggle
When a user is taking advantage of the scroll features
it is likely a scrolled vertical position is well past
the first displayable task. That is especially true of
top's forest view ('V') mode where those early systemd
attached processes are generally not very interesting.

As such, should the idle mode toggle ('i') be employed
a distorted display is almost guaranteed because tasks
that have used some cpu, and thus should be displayed,
have already been skipped by virtue of their position.

So this patch temporarily nullifies vertical scrolling
during the period when idle tasks are not being shown.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-24 06:51:40 +10:00
Jim Warner
2ceb4c31da library: readstat redesigned using 'stack' vs. 'chain'
In addition to that text shown below the line which is
common to several commit messages, this patch contains
several minor changes with lessor impact upon the API:

. A call to procps_stat_read_jiffs() has been added to
those jiffs functions carrying the 'fill' nomenclature
to parallel like functions in some of our other files.

. The #include header files are ordered alphabetically
now, with all those <sys/??> types separately grouped.

. Standard copyright boilerplate was added in .c file.

. The header file follows the conventions of indenting
(by 4 spaces) those parameters too lengthy for 1 line.

------------------------------------------------------
. The former 'chains' have now become 'stacks' without
the 'next' pointer in each result struct. The pointers
initially seemed to offer some flexibility with memory
allocations and benefits for the library access logic.
However, user access was always via displacement and a
a statically allocated chain was cumbersome to define.

. An enumerator ending in '_noop' will no longer serve
as a fencepost delimiter. Rather, it has become a much
more important and flexible user oriented tool. Adding
one or more such 'items' in any items list passed into
the library becomes the means of extending the 'stack'
to also include user (not just library) data. Any such
data is guaranteed to never be altered by the library.

. Anticipating PID support, where many different types
must be represented in a result structure, we'll adopt
a common naming standard. And, while not every results
structure currently needs to reflect disparate types a
union will be employed so the same dot qualifier ('.')
can be used consistently when accessing all such data.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-23 22:31:39 +10:00
Jim Warner
b8c688fb36 library: meminfo redesigned to use 'stack' vs. 'chain'
In addition to that text shown below the line which is
common to several commit messages, this patch contains
the following additional change without an API impact:

. The #include header files are ordered alphabetically
now, with all those <sys/??> types separately grouped.

------------------------------------------------------
. The former 'chains' have now become 'stacks' without
the 'next' pointer in each result struct. The pointers
initially seemed to offer some flexibility with memory
allocations and benefits for the library access logic.
However, user access was always via displacement and a
a statically allocated chain was cumbersome to define.

. An enumerator ending in '_noop' will no longer serve
as a fencepost delimiter. Rather, it has become a much
more important and flexible user oriented tool. Adding
one or more such 'items' in any items list passed into
the library becomes the means of extending the 'stack'
to also include user (not just library) data. Any such
data is guaranteed to never be altered by the library.

. Anticipating PID support, where many different types
must be represented in a result structure, we'll adopt
a common naming standard. And, while not every results
structure currently needs to reflect disparate types a
union will be employed so the same dot qualifier ('.')
can be used consistently when accessing all such data.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-23 22:31:24 +10:00
Jim Warner
4dea69067e top: exploit that meminfo dynamic chain allocation API
The commit msg summary says it all (well, not really).

The previous statically allocated results chain served
the top program perfectly in all its lib memory needs.
But, someone needs to try out the brand new interface.

Besides, there were a few other changes which I wanted
to make. And among them were the following miscellany:

. some names were changed, like 'context' became 'ctx'

. an unnecessary redundant library call was eliminated

. the placement of a few globals was made more logical
( thanks Craig for following the capitalization rule )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-14 22:33:33 +10:00
Craig Small
62f9a51532 library: remove procps_pagesize_get()
This is actually a systemcall getpagesize(2) or it is defined
in configure using a variety of methods, including a default
hard coded value as a last resort.

There is no need to have this in libprocps
2015-07-02 20:54:11 +10:00
Craig Small
161e06465b library: cleanup unused old functions
The old getstat and meminfo functions and their globals are
removed.

Also page_size is now a function, procps_pagesize_get()
2015-07-01 22:08:02 +10:00
Jim Warner
9830fdf0ae top: tweak newlib interface, as more experience gained
Now that the dust is settling following an initial API
library effort, it is apparent my naming standards may
not have always been observed. This was a minor crime,
since those standards are unwritten (& not apparent?).

Basically, top has always capitalized the first letter
of global variables in an effort to distinguish global
definitions from local variables later in the program.

So this patch alters the new API variables to conform,
while also explicitly using 'context' for key structs.

Lastly, top now employs the new '#include <proc/name>'
conventions for the new/converted module header files.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:32:16 +10:00
Jim Warner
e88b11f176 library: normalize the readstat context structure name
The new library meminfo & vmstat modules use structure
names for their context which exactly mirror the names
of the very /proc/ files whose particulars they yield.

The one exception to this rule was the readstat module
whose struct was named statinfo yet the file was stat.

This commit simply renames that structure (only) so as
to hopefully establish such a naming convention as our
standard going forward. And, it's makes good symmetry.

[ this module's name itself is just perfect as it is ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:30:58 +10:00
Jim Warner
faf6d4dc93 library: the uref functions were insufficiently robust
The earlier attempt at protecting these functions from
already freed memory worked just fine until the memory
was, in fact, reused by the OS. At that point, the ref
count would most likely fail an existing a test for 0.

So this commit will take control of the 'info' pointer
and force it to NULL when a reference count reaches 0.

Plus, since it makes little sense returning an address
that a caller already has, henceforth we will return a
reference count out of the 'ref' and 'unref functions.

Reference(s):
commit 74beff80ff

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:30:17 +10:00
Jim Warner
ff852103f8 top: make recently added variable name more conforming
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:29:22 +10:00
Craig Small
c183b18301 library: Replace smp_num_cpu with function
Instead of exposing a variable smp_num_cpus that is updated
with cpuinfo, use procps_cpu_count() which returns the same
value.
2015-06-29 22:31:36 +10:00
Craig Small
639daf5468 library: Update uptime calls to standard format
Changed all the uptime related functions to use the
standard naming procps_uptime_*
2015-06-29 22:09:59 +10:00
Craig Small
56399212c8 library: Remove signal name from library
Procps library previously held functions that were about either
listing or finding signal names. These are not really the right
location for a library about reading procfs.

This patch handles signal related functions in two ways:

For functions purely found in skill, these have been moved back
into this binary as they are used nowhere else.

For functions used across the binaries, these have been moved
into include/signals.h and lib/signals.c. Besides formatting,
these functions are largely the same.

To assist the skill functions, two functions to access the
signal map array have been added to lib/signals.c
2015-06-29 21:52:51 +10:00
Jim Warner
8ded6c5739 top: exploit the new library API for cpu display needs
This commit is mostly about eliminating code, now that
a library is responsible for the cpu tics maintenance.

The top program will continue to provide numa support,
without involving the library in any of those details.
[ not to mention all the 'dl' and 'stderr' numa crap ]

With this transfer of the cpu tics duty to our library
the provision associated with the CPU_ZEROTICS #define
could not initially be migrated. The commit referenced
below suggests it may have lost its importance. In any
case such logic may yet be incorporated in the future.
But for now, that #define has been completely removed.

Reference(s):
commit ee3ed4b45e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:31:16 +10:00
Jim Warner
c3fd7473c5 top: exploit the new library API for memory statistics
This commit represents the pioneering attempt at using
the concept of 'chained' library requests in an effort
to reduce function call overhead. It required exposing
no more implementation details than were already shown
through the individual calls, yet is satisfied in one.

It is just such an approach that will prove invaluable
when it comes time to access individual /proc/##/data.
Programs could 'chain' only those 'results' structures
representing their current view independent of all the
fields any such programs might be prepared to display.

Thus the standard 'read', which wouldn't apply to task
level data very well (or efficiently), can now become
a 'read_chain' whereby the former PROC_FILL flags need
can be satisfied & yield the minimum open/close calls.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:29:33 +10:00
Craig Small
cbf25b93e3 library: more mem and stat fixes
Make distcheck now succeeds.
Changed some of the binaries to use the new API.
2015-06-26 22:37:29 +10:00
Craig Small
d7932b9a13 library: uptime API changes
Removed the printf_uptime, binaries can do printf easily enough.
sprint_uptime split into two as there wasn't a lot of common
code
 sprint_uptime(): old style uptime line
 sprint_uptime_short(): short new style "uptime -p"

Hertz_hack needed this, no sane system uses the code (I think)
so just assume 100 like we do in FreeBSD.
2015-06-26 22:37:28 +10:00
Jim Warner
88fe45ef68 top: sacrifice a redundant procps_linux_version() call
With the commit referenced below, the linux version is
no longer available via an external variable. So we'll
eliminate the extra superficial function call employed
at program end as part of a debugging (only) o/p spew.

[ the user will soon be returned to the command line ]
[ & he/she can run their own 'uname -r' if in doubt! ]

Reference(s):
commit 56d9d5e7e7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-21 08:05:59 +10:00
Craig Small
56d9d5e7e7 library: Change linux version
Added function procps_linux_version() which used to be an
exported integer instead.  Also changed the method of obtaining
the linux version (more correctly the os release) to use a specific
procfs entry. This works for both Linux and FreeBSD.
2015-06-19 21:00:46 +10:00
Jim Warner
3600f652e8 documentation: fix man pages due to refactor for wchan
This patch will bring three of our man pages into line
with the recent refactor of the libprocps wchan logic.

[ and also eliminates more damn eol whitespace which ]
[ snuck in our repo with the commit referenced below ]

Reference(s):
http://www.freelists.org/post/procps/WCHAN,11
commit cf4788c28d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:21 +10:00
Jim Warner
93666da62c top: adapt to a simplified library interface for wchan
This patch was made necessary by those library changes
in support of recently revised/simplified wchan logic.

Reference(s):
http://www.freelists.org/post/procps/WCHAN,11

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00
Jim Warner
932f54b19d top: correct an alphabetic field error in man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00
Craig Small
505f257a8c library: remove procps_version functions
It doesn't make any sense to have the binary version strings
embedded into the library. The version strings are defined
already either in the Makefile or in include/c.h
2015-06-18 22:37:24 +10:00
Jim Warner
d8aee1a809 top: update man document to support the LXC containers
[ in addition to the primary 'lxc' business, i found ]
[ numerous apostrophes used instead of that back-tic ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-14 15:36:06 +10:00
Jim Warner
2ba7aa8b7d top: add support exploiting new library LXC containers
Reference(s):
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1424253
https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1424253

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-14 15:36:06 +10:00
Filipe Brandenburger
c1c73c0d00 build-sys: merge automake subdirs into toplevel
This will be required for subdir-objects, otherwise automake will have
problems with more than one Makefile.am having rules to build the same
files.

Tested that it builds and both `make check` and `make distcheck` work.

Tested `make install` and compared the tree with the one installed
before this commit, both installed the binaries to the same locations.
The binaries are also in the same location in the build tree (for
instance, ps/pscommand is still there.)

Checked the binaries for the correct libraries linked into them. Binary
sizes matched before and after this change.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 23:19:31 -07:00
Filipe Brandenburger
90cc5460aa build-sys: add $(top_srcdir) to include search dir
This is required for out-of-tree build to work, since many source files
include e.g. proc/*.h which is not under the include/ directory.

Tested that `make distcheck` starts working after this patch.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 17:09:55 -07:00