Commit Graph

1924 Commits

Author SHA1 Message Date
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
e949b78c30 library: revert changes to 'look_up_our_self' function
The patch below is where most proc_t fixed size arrays
became simple pointers to char. In that commit changes
to the above function were made so that dynamic memory
was freed which included the program name (cmd) field.

That change was prompted by a valgrind reported memory
leak during development that no longer seems to exist.
However, by keeping the look_up_our_self() changes the
ps command without args then fails to report anything.

So this patch just restores the expected old behavior.

Reference(s):
commit 3881a0844a

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
387d4030f4 library: miscellaneous tweaks to pid code and comments
. traded a complex misaligned memory allocation scheme
in the make_hist function for a simple aligned scheme.
plus memory allocation increases are globally defined.

. changed 1 parameter for procps_pids_stacks_sort() to
better reflect the 'array of pointers', not an address
of a pointer as is used with guys such as 'new/unref'.

. the pids_reap struct was changed slightly to make it
more reflective of it's actual implementation details.

. the Item_table member .mustfree is now .needfree and
that .makehist was now made .needhist for consistency.

. reduced the number of separate 'return NULL;' source
statements in that primary procps_pids_reap() routine.

. ensured consistent reference to sizeof(void *) & not
occasional reference to sizeof(void*) without a space.

. rather than enable/disable validate_stacks via a #if
in the function body, it is now handled via a #define.

. some comments in the procps_pids_reset function were
adjusted to reflect this current implementation. shown
originally, they reflected an aborted attempt to avoid
a testing aberration not fully understood at the time.

. added a summary of the memory overhead cost of HST_t
processing to that UNREF_RPTHASH output at unref time.

. a 'PIDs at max depth:' portion of that UNREF_RPTHASH
enabled #define is now published only when the maximum
depth of hash table entry chains exceed depths of one.

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
7e6a371d8a library: implement task/thread support via the new api
This commit is the culmination of efforts to modernize
the library api. It should be treated as a first blush
attempt, especially since I have absolutely no library
design experience. But I did have a very strong desire
to lessen the new library's impact on the top program.

Under this new api, a 'stack' is the equivalent of the
old proc_t. It can be seen as a variable length record
whose contents & order is under complete user control.

That initial stack/record configuration is established
at procps_pids_new() time and will probably serve most
program needs. But, a dynamic & demanding program like
top will later change a stack via procps_pids_reset().

For programs like top & ps, procps_pids_reap() will be
the function that will retrieve all tasks and threads.

Any program that needs to filter / select only certain
processes or users have available other functions that
can be used: procps_pids_stacks_alloc, fill & dealloc.

This implementation attempts to maximize that existing
proven libprocps code base. As we gain more experience
such actual code can be migrated into the pids.c file.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:06 +10:00
Jim Warner
3881a0844a old library: just some tweaks for transition to newlib
A few minor changes are being made to position the old
readproc logic for a transition to the newlib pid api.

These changes will not impact current users beyond the
the need to recompile such code. Hopefully this should
be very last version change to the deprecated library.

. most char arrays were replaced via char * to dynamic
memory. this was done so that newlib could just assume
ownership of such strings without using a strdup call.

. former user and group name arrays also became char *
but here the reason was because pwcache already cached
those names. so, copying to an array never made sense.

. the concept of QUICK_THREADS used to avoid duplicate
overhead for string data was disabled. it could not be
integrated with the newlib design, at least initially.

. any #define which influenced the size of that proc_t
was disable in the header. it was probably a poor idea
to approach optional features in such a manner anyway.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:06 +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
John Keeping
049e206689 configure.ac: do not check for C++ compiler
We do not have any C++ code, so there is no point in checking for C++
tools in the configure script.

Signed-off-by: John Keeping <john@keeping.me.uk>
2015-08-18 12:05:11 +01:00
Craig Small
0ee090ae16 ps: display control group name
The cgroup field while shown as a vector is a concatenated
string, so alot of the complexity of sorting and displaying
has gone.

This change simplifies the cgroup sorting and adds display
and sorting for the name attribute of the cgroup, if found.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-15 17:10:38 +10:00
Craig Small
4bd0e539af ps: sort by cgroup
A rather small fix to sort by cgroup. This sorting function
could be used for other string vector entries, but I can't
see why you want to for, say, environment.

Reference:
 https://bugs.debian.org/692279

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-15 16:23:37 +10:00
Craig Small
e3d9ee04d9 Update NEWS for next version 2015-08-15 15:42:40 +10:00
Craig Small
de985eced5 RELEASE 3.3.11
Update NEWS file to number this release.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:54:49 +10:00
Craig Small
57396ae39d build-sys: Update Library Version
procps v3.3.11 will bring Library API 5:0:0
The reason for the change is the removal of some calls and
the addition of others. The newlib branch should hopefully
reset some of these changes to a much slower pace.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:45:19 +10:00
Craig Small
a849d85260 translations: Update all and fix Polish
Translation files downloaded from TP.
Polish file fixed for man-po, there were two
bad sequences.

References:
 http://www.freelists.org/post/procps/Bad-sequences-in-the-manpo-translations

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:37:44 +10:00
Craig Small
5686cc5cb5 build-sys: include .version in EXTRA_DIST
.version is created in the top_srdir which when building normally
doesn't present a problem. When make distcheck is run, the source
directory is made read-only and it fails with permission denied.

The version of misc/git-version-gen is old and is missing the
instruction to add .version to EXTRA_DIST. This commit does just
that.

make distcheck now passes.

References:
 https://github.com/gagern/gnulib/blob/master/build-aux/git-version-gen
 https://lists.gnu.org/archive/html/bug-gnulib/2011-08/msg00000.html

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 16:27:37 +10:00
Craig Small
fd007d6d1d free: Parse -s option correctly.
If the -s option was the first option on the command line, free
would report seconds argument failed. This only appeared on the
Debian free, not the one in git.

Closer examination revealed that if a valid float string is
given to strtof() it doesn't set errno to 0, but just leaves it
alone. As we are explicitly testing errno for overflows, this
means the previous errno change is picked up here.

The simple answer is to set errno to 0 before calling strtof().

References:
 https://bugs.debian/org/733758
 https://enc.com.au/2015/08/08/be-careful-with-errno/
2015-08-08 21:04:01 +10:00
Craig Small
1f67b7dc71 Add notice in news about vmstat 2015-08-08 17:14:36 +10:00
Jim Warner
b4923fa745 miscellaneous: a final cleanup prior to release 3.3.11
This patch just eliminates some eol whitespace, adds a
missing eof newline and contributes yet one additional
entry to the NEWS summary regarding saved top rcfiles.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-08 16:56:50 +10:00
Craig Small
871c4a4675 add CI badge 2015-08-06 12:41:44 +00:00
Craig Small
e54b372498 Update NEWS entry 2015-08-06 22:35:02 +10:00
Craig Small
313f936739 ps: enable sort by etimes
ps has two columns showing the same data which is elapsed time, just
the format is changed:
 etimes - elapsed time in seconds
 etime  - elapsed time in DD-hh:mm:ss

ps used to only sort by etime but not etimes, by making etimes
and alias of etime for sorting both flags work.

References:
 https://bugs.debian.org/794619

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-06 22:08:13 +10:00
Jim Warner
3da298c1d6 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-06 21:56:27 +10:00
Jim Warner
8226ca9838 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'.

Reference(s):
commit 709785e20b

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-06 21:56:02 +10:00
Jim Warner
9ba65bad8e 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-06 21:52:11 +10:00
Jim Warner
9cc6ed10c8 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-06 21:50:49 +10:00
Craig Small
a7f0f3d7fe build-sys: Add gitlab CI job file 2015-07-28 22:47:15 +10:00
Craig Small
3178eb54fc Merge branch 'master' into 'master'
Fix readlink anomalies

Noticed minor readlink issues in pidof.c and pwdx.c.

I have fixed them in two separate commits, please see the commit messages for their specific descriptions.

See merge request !5
2015-07-28 12:39:48 +00:00
Jim Warner
63e828fe88 library: minor tweaks of program logic and/or comments
This commit just corrects the oversight wherein 'item'
was being employed when 'these' was actually intended.

Also, it trades some 'item' use for a more descriptive
input parameter which henceforth is known as a 'dest'.

And, there was one leftover 'next' pointer eliminated.

Finally, some logic was made a tad less dependent upon
enumerator names and a few comments were also updated.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-28 21:51:00 +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
ae4b686745 library: eliminate extra stack header space provisions
With the new perspective on potential uses of a 'noop'
enumerator (or whatever we decide to call it) there is
no longer a need to provide for any extra 'user' space
in the stack header structures used by slab & meminfo.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-23 22:31:50 +10:00
Jim Warner
02b25a2eec library: vmstat redesign now 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:

. Standard copyright boilerplate was added in .c file.

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

. 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:44 +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
6aa36717c4 library: slab is 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
several minor changes with lessor impact upon the API:

. A 'read' was added to function procps_slabnode_count
(but only when necessary, i.e. info->nodes_used == 0).

. 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:32 +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
Craig Small
151c05b497 w: Adjust command width
w would error out if the window size was smaller than 71 or some
other fields through environment grew too big. The code was a little
convoluted as well. The minimum length for command was 3, which is
pretty useless.

This change does the following:
 w doesn't care by default the window size
 w will adjust the command length up and down, to a minimum of 7
characters.
 if the fields don't fit, w will line-wrap each line.

The idea being its better the line-wrap than it is to error out.

References: https://bugs.debian.org/183394

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-21 22:45:02 +10:00
Craig Small
857bb39d31 w: Fix choice of current process
If there is a PID wrap-around w will choose the wrong process.
For example:
$ ps x -o pgrp,tpgid,start,tty,cmd | grep pts/3
 3834  3834 21:50:26 pts/3    ssh server
 4461  4461 21:57:14 pts/2    grep pts/3
23410  3834 21:07:17 pts/3    mutt
26071  3834   Jul 13 pts/3    /bin/bash

w will show the user as:
csmall   pts/3    my-laptop:S.1   13Jul15  5:54   1.36s  1.13s /bin/bash

So why?
w scans the process table and has two ways of finding the best match.
 #1 match things like terminal,username and process group, find oldest
 #2 match utmp pid to process tgid

The problem is that #2 trumped #1, which is fine when your login process
is numerically lower than your other processes. However in this case
26071 is larger and appears later in the readdir() than the correct
process, which is 3834.

The fix is not not overwrite best if it already exists.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-21 22:25:06 +10:00
Jim Warner
c07f6c5e6d 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-21 21:23:44 +10:00
Craig Small
887f2a81d7 library: tests for sysinfo
First set of tests for the library API, this lot checks the two
functions out of sysinfo.c

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-20 22:23:21 +10:00
Jim Warner
53b33a1ab8 library: ensure the consistent handling of 'noop' enum
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-15 21:27:14 +10:00
Jim Warner
9d1073a22a library: also include a 'read' for slabnode_chain_fill
While meminfo does implement only the singular version
of 'xxxx_chain_fill', it was wrong to limit the 'read'
to the plural version (only) within our new slabs API.

This kind of inconsistency will only spell trouble for
future users of the new libprocps API. So, this commit
will mean that any form of xxxx_chain(s)_fill function
also includes a 'read', whereas xxx_getchain does not.

Reference(s):
commit aab537bc13
http://www.freelists.org/post/procps/newlib-interfaces

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-15 21:26:10 +10:00
Jim Warner
74cb6afcc9 library: tweak new interface code and improve comments
With a little help from smatch, this commit eliminates
some inappropriate code. Also some programmer comments
were (barely) improved (i hope) in some small measure.

Reference(s):
smatch: 406 procps_meminfo_chain_fill() warn: variable dereferenced before check 'chain' (see line 403)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-15 21:25:09 +10:00
Jim Warner
8d9612f782 vmstat: adapted to exploit the alloc & sort interfaces
In addition to exploiting the new interface, a warning
for a meminfo variable 'used uninitialized' was fixed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-14 22:37:09 +10:00
Jim Warner
e044559527 slabtop: adapted to exploit new alloc & sort interface
In addition to the new interface several other changes
were made. In fact, there are so many I must apologize
in advance to Craig, et al. for the hatchet I wielded.

Among the changes was my attempt to shrink the body of
that main() function. It's amazing how some folks must
always cram as code much as possible into  ol' main().

Personally, unless it's a throwaway quick & dirty pgm,
all main function bodies should not exceed one screen.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-14 22:36:48 +10:00
Jim Warner
5c3542c4e1 library: revised sort + new allocate APIs for slabinfo
With this patch, we will be close to an implementation
which will be needed when accommodating tasks/threads.
The following explanation was from an earlier message:

The slabtop requirements are similar to those of PIDs.
One must accommodate the variable number of slab nodes
(PIDs) while also accepting different data (char * and
unsigned long). Furthermore, some generalized means to
sort all that acquired stuff must somehow be provided.
------------------------------------------------------

So this patch expands the API to provide dynamic chain
allocation plus allow sorting of those dynamic chains.
While specific to slab needs (nodes, not global stats)
it is not too early to begin to think of newlib chains
as the opaque replacement for a deprecated old proc_t.

Better yet, any newlib chain is inherently variable in
length, something the old proc_t couldn't claim to be.
Of course, as we get to PIDs we'll want to grow/shrink
chains (easily accomplished with a special item enum).
And we'll want to grow/shrink those **head arrays too.
But these minor details don't seem insurmountable now.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-14 22:36:07 +10:00