Commit Graph

1723 Commits

Author SHA1 Message Date
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
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
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
Jim Warner
aab537bc13 library: refactor meminfo providing dynamic allocation
An earlier approach to meminfo chaining, referenced in
the patch shown below, represents the first baby steps
toward the goal of some generalized approach with PIDs
processing. However, statically allocating a chain for
each task or thread is totally impractical. And, while
a single chain could serve all PIDs, that would mean a
separate call to our library for each running process.

This commit is intended as the next evolutionary step,
dynamically allocating some 'result' chains to contain
as many or as few 'items' as a caller wishes. In other
words, holding only those 'items' of current interest.

This is the kind of service useful for both top and ps
programs if we finally get around to /proc/<PID> data.

Reference(s):
commit c3fd7473c5

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-14 22:32:41 +10:00
Craig Small
cf6c2155dc library: rebase & make current initial slabinfo effort
This was Craig's original patch, referenced below, but
it was never pushed to newlib. It has now been rebased
on top of some diskstat stuff to serve as a beginning.

The original effort was perfectly serviceable (after a
memory leak was fixed) but the approach would not have
served future PID needs when that proc_t went bye bye.

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 I wanted to try a different approach that seemed to
hold potential for satisfying future top and ps needs.
Subsequent commits will make that attempt, building on
Craig's original patch whose commit msg appears below.
------------------------------------------------------

All of the /proc/slabinfo related calls have been changed
here. They follow the same procps_slabinfo_* format.

Made both the slabtop and vmstat programs use the new
API as one was using the old one and one was just sort
of trying to do its own thing.

Sorting of slabnodes is also possible via the library.

Reference(s):
http://www.freelists.org/post/procps/Sorting-slabsprocesses,3
http://www.freelists.org/post/procps/library-rework-slabinfo-calls

Signed-off-by: Craig Small <csmall@enc.com.au>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-14 22:31:16 +10:00
Craig Small
e445f7e6c5 library: Update diskstat API
The calls for reading diskstat have been moved out of
sysinfo and into new files diskstat.[ch] These new
library calls follow the standard pattern for the
new libprocps.

vmstat is updated to use the new API and also got
the weighted IO time added.

vmstat -p previously would only show partitions, not
disks. There does not appear to be any good reason to
artifically deny a user to use this command on a disk,
rather than a partition so this restriction was lifted.

I also realised using int for devid means you can send
the library negative numbers, the index uses unsigned int.
Other similiar calls will need to be fixed too.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-07 22:42:06 +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
855a6a7055 library: remove getpartitions_num from library
getpartitions_num was only used in vmstat and basically counted
partitions in disks, this is now moved to vmstat.
2015-07-01 22:14:30 +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
Craig Small
c3e85cef73 library: loadavg change to procps_loadavg 2015-07-01 21:47:30 +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
Jim Warner
336748ecc0 misc: remove yet more darn trailing whitespace buildup
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:28: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
73d7a18d66 library: extend cpu jiff logic beyond cpu summary info
There was not a way I could see to support top's needs
for cpu information with the new 'chained' provisions.
The sheer quantity of such data plus the unpredictable
number of potential processors suggested a totally new
approach was warranted while keeping internals opaque.

So this patch introduces two new structures solely for
use by potential callers (as seen in the API). They're
responsible for providing them to the library which is
then responsible for filling them with requested data.

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:03 +10:00
Jim Warner
74beff80ff library: make reads & unref logic a little more robust
Since we are not using a higher level standard C fopen
all of the read requests were made signal sensitive as
that can result in a 'temporarily' failed i/o request.

Also, protection against some user calling the 'unref'
function on already free memory has been incorporated.
This will protect us from some nasty 'Abort' surprise.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:30:48 +10:00
Jim Warner
0c162f7af0 library: add chaining provisions to readstat cpu & sys
If a caller chooses to reduce the overhead of repeated
function calls, this commit provides for acquiring all
the desired information in just a single library call.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:30:04 +10:00
Jim Warner
6bb1a033b4 library: tweak formatting for readstat header and code
This patch mostly just eliminates darn tab characters.

Plus the library function declarations and definitions
have been standardized. Most visibly, the input params
now have all been indented on their own separate line.

The following names were changed to more closely match
meminfo.c or provide a certain symmetry. Unfortunately
that also impacted some other pgms which were updated.

. 'procps_stat_get' evolved into 'procps_stat_get_sys'
. 'procps_stat_info' is now known as 'procps_statinfo'

[and just a little trailing whitespace was eliminated]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:29:49 +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
Jim Warner
a05084f381 library: add chaining provisions to meminfo and vmstat
If a caller chooses to reduce the overhead of repeated
function calls, this commit provides for acquiring all
the desired information in just a single library call.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:29:29 +10:00
Jim Warner
7a98cab187 library: add missing meminfo logic, improve efficiency
This patch fills in some missing fields which have top
dependencies. Additionally, I've tried to mirror those
calculations Jaromir added for release 3.3.10. The one
calculation that remains missing is 'available' memory
for some kernels. For this API, we'll use a fall-back.

Lastly the lxc safeguards which were recently added to
the old procps library were incorporated here as well.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:29:24 +10:00
Jim Warner
500a901475 library: tweak formatting style for meminfo and vmstat
This patch mostly just eliminates darn tab characters.

Plus the library function declarations and definitions
have been standardized. Most visibly, the input params
now have all been indented on their own separate line.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:29:19 +10:00
Craig Small
7a7cf686ec library: export pwcache functions correctly 2015-06-26 22:37:53 +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
05efbebb66 library: Fix up stat API
Adjusted vmstat to use the new API for memory and CPU statistics
2015-06-26 22:37:28 +10:00
Craig Small
ca4a09c432 library: memory and vmstat API changes
Created new set of functions for meminfo related calls. Liked the
format of that better so changed vmstat around so the look similar.
Missed the makefile change for uptime so added it in now.
2015-06-26 22:37:28 +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
Craig Small
a20e88e4e7 library: Add procps_meminfo_* functions
New set of functions that read the /proc/meminfo file. Still needs
work.
2015-06-26 22:37:28 +10:00
Craig Small
a410e236ab library: sysstat and vmstat api changes
Use the standard libc declarations.
For protecting the headers for C++ procps used to have its
own defines, this change makes them use the standard libc ones.

getstat() -> procps_stat_*
vminfo() -> procps_vmstat_*
These two components of the library now use the newer version of
the API with less exposed global variables. The old methods are
there for now.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-06-26 22:37:28 +10:00
Craig Small
6a0850be7b pwdx: Do not link to libprocps
pwdx doesn't actually use any of the libprocps functions but
it is linked because it is the default.  This specific LDADD
removes that unrequired linking.
2015-06-24 22:27:24 +10:00
Jim Warner
9e85c147b2 build-sys: tweak to prevent dirty tree with every make
Please let's stop the nls translation insanity. With a
one time push we can eliminate the dirty tree syndrome
which surfaces with every local build. Later, before a
release, the translations can be updated in final form
then pushed just 1 more time to the gitlab repository.

I'm tired of having to always re-issue this request in
order to circumvent the problem and thus prevent a too
broad commit (not to mention some nasty side effects).

[ bash$ git update-index --assume-unchanged po/??.po ]

Reference(s):
http://www.freelists.org/post/procps/procpsng-translations

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-21 08:07:51 +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
Yuriy M. Kaminskiy
9ed623780f fix integer overflow on 2GiB+ maps on 32-bit platforms
Signed-off-by: Craig Small <csmall@enc.com.au>
2015-06-20 21:39:41 +10:00
Jim Warner
4129c758ac miscellaneous: remove some trailing whitespace buildup
wish folks (craig) would use these in their .gitconfig

[core]
  whitespace = trailing-space, space-before-tab, blank-at-eof
[apply]
  whitespace = warn

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-20 07:46:23 +10:00
Jim Warner
ad0a0fc138 build-sys: fix oversight for a newly added header file
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-20 07:46:16 +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
Craig Small
94e5ef15fc Update the po files 2015-06-19 20:36:43 +10:00