]> granicus.if.org Git - procps-ng/log
procps-ng
3 years agops: ignore SIGURG
Tommi Rantala [Mon, 11 Oct 2021 10:33:18 +0000 (13:33 +0300)]
ps: ignore SIGURG

Stop registering signal handler for SIGURG, to avoid ps failure if
someone sends such signal. Without the signal handler, SIGURG will
just be ignored.

  Signal 23 (URG) caught by ps (3.3.16).
  ps:ps/display.c:66: please report this bug

https://man7.org/linux/man-pages/man7/signal.7.html
https://www.freebsd.org/cgi/man.cgi?sektion=3&query=signal

3 years agoRemove autogen.sh libtool prog check #222.
Rafael Kitover [Mon, 11 Oct 2021 20:23:12 +0000 (20:23 +0000)]
Remove autogen.sh libtool prog check #222.

Remove the check for the libtool executable as many libtool distribution
packages do not have it and it is not necessary for building, as
libtoolize is also checked for to determine the presence of libtool.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
3 years agotestsuite: Make test program compile on Hurd
Craig Small [Tue, 12 Oct 2021 20:56:39 +0000 (07:56 +1100)]
testsuite: Make test program compile on Hurd

procps fails to build from source due to usage of field si_int of struct
siginfo_t in lib/test_process.c which does not exist on GNU/Hurd.

Thanks to Svante Signell for the patch.

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotop: restore ending ']' when summary graphs are scaled
Jim Warner [Mon, 4 Oct 2021 05:00:00 +0000 (00:00 -0500)]
top: restore ending ']' when summary graphs are scaled

When a visual separator was added to 2 abreast summary
items in a recent commit, this bug was introduced. So,
from that earlier patch we'll revert one line of code.

The bug surfaced under an 80/even column terminal only
when that '4' toggle was off. With an an 81/odd column
screen, it existed in both single and 2 abreast modes.

[ this commit also goes the extra distance to ensure ]
[ two abreast mode maximizes available screen width. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: revert part of a patch regarding separate threads
Jim Warner [Thu, 30 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: revert part of a patch regarding separate threads

In the patch referenced below, some logic was moved in
that frame_make function in an effort to overlap those
background threads with additional main thread duties.

Unfortunately, the auto-size column feature was broken
in the process. So this patch will revert a portion of
the earlier patch so as to restore the broken feature.

Reference(s):
. Sep 2021, top overlap additional processing
commit f11f43b4f7118f284f9aec19f6885d163848ffe7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: ensure thread safety via function substitutes
Jim Warner [Tue, 28 Sep 2021 05:00:00 +0000 (00:00 -0500)]
library: ensure thread safety via function substitutes

Even though we we had to abandon the master branch top
multi-thread effort and even though the newlib version
of a multi-threaded top provides no real benefit, that
whole exercise was not wasted. Rather, it has revealed
some deficiencies in our library which this addresses.

If two or more threads in the same address space tried
to use procps_loadavg or procps_uptime simultaneously,
there's a chance they would experience problems due to
thread-unsafe functions our library called internally.

So, this patch switches them for thread-safe versions.

[ along the way we will also make that procps_uptime ]
[ initialization of his 'up' & 'idle' variables mean ]
[ something by delaying the -ERANGE return a little. ]

Reference(s):
https://www.freelists.org/post/procps/a-few-more-patches,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: ensure thread safety for all static variables
Jim Warner [Tue, 28 Sep 2021 05:00:00 +0000 (00:00 -0500)]
library: ensure thread safety for all static variables

Even though we we had to abandon the master branch top
multi-thread effort and even though the newlib version
of a multi-threaded top provides no real benefit, that
whole exercise was not wasted. Rather, it has revealed
some deficiencies in our library which this addresses.

If two or more threads in the same address space tried
to access the same api simultaneously, there is a good
chance some function-local static variables will yield
some of those renowned unpredictable results. So, this
patch protects them with the '__thread' storage class.

Reference(s):
https://www.freelists.org/post/procps/a-few-more-patches,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: ensure those potential focused tasks stay focused
Jim Warner [Thu, 23 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: ensure those potential focused tasks stay focused

When that 'F' focus command has been applied to a task
in forest view it should remain as the topmost process
in a particular window. But without this patch that is
not guaranteed. Newly forked/cloned tasks 'above' such
a process result in task(s) appearing which shouldn't.

The effect was as if that up arrow key scrolled beyond
the topmost parent task, which would never be allowed.

[ since scrolling is permitted within a focus range, ]
[ when any task 'above' our focus/topmost task ends, ]
[ we respond as if scrolled with the down arrow key. ]

[ that result is completely appropriate. if the user ]
[ wishes to return to a focused parent, the up arrow ]
[ or home key can be used to accomplish such a goal. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: overlap some more processing for separate threads
Jim Warner [Wed, 22 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: overlap some more processing for separate threads

In an effort to improve the performance & decrease the
cost of our separate background update threads we will
relocate some overhead so that it might be overlapped.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: modify semaphore destruction for separate threads
Jim Warner [Tue, 21 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: modify semaphore destruction for separate threads

This commit just ensures that at program end all those
semaphores are removed in the same order for symmetry.
From thread's view of importance, we do least to most.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: reverse the #define defaults for separate threads
Jim Warner [Sun, 19 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: reverse the #define defaults for separate threads

Rather than having those 3 separate background threads
enabled by default, we'll turn them off until somebody
chooses to activate them. That seems more appropriate.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: introduce background updates via separate threads
Jim Warner [Sat, 18 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: introduce background updates via separate threads

After the stage had been set in the previous patch, in
this patch we will actually implement those background
updates via 3 separate threads. The design was simple:

. the do-while loops have now been made truly infinite
. 2 semaphores per thread allow needed synchronization
. 1 semaphore will provide for each thread to sem_wait
. 1 semaphore will provide for display o/p to sem_wait
. and all 3 thread's program name was made descriptive

A complication was the potential for a signal directed
to one of our new threads. Rather than having a thread
try to deal with such signals, we pass a mask with all
signals blocked at pthread_create time. Thereafter any
subsequent signals are forwarded to the parent thread.

[ also sigprocmask was exchanged for pthread_sigmask ]
[ since warned about use "in multithreaded process". ]

[ plus we also modified each of those POSIX comments ]
[ about 2004 to agree with current signal-safety(7). ]

Sadly, after all this effort there were no performance
benefits to having separate threads. In fact there was
a measurable performance degradation when running with
ever smaller delay intervals. But even with a delay of
1/10 second the 'real' cost increase is only about 1%.

There is one way whereby any additional costs might be
eliminated (at least seemingly). One could introduce 2
separate sets of contexts for each of those 3 threads.
Then retrieval & display could be overlapped. However,
the resulting display wouldn't represent the real-time
results. Rather it would be stale by 1 delay interval.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: refactor 3 routines ahead of the separate threads
Jim Warner [Sat, 18 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: refactor 3 routines ahead of the separate threads

This commit sets the stage for turning three functions
into code that can support a separate thread to update
their respective data while working in the background.

It involved relocating 1 function, renaming 2 routines
and adding parameters plus return addresses to each of
three functions. Those latter changes will be required
when issuing 'pthread_create' calls in the next patch.

The final step was organizing this code into what will
become the infinite do-while loop supporting a thread.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: tweak end-of-job processing if invoked via signal
Jim Warner [Thu, 16 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: tweak end-of-job processing if invoked via signal

The master branch top is pretty well insulated against
signal-unsafe function calls during end-of-job action.

However, this newlib branch top had exposed himself to
a bunch of such unsafe activity in the form of 'unref'
function calls to the new library. In those guys there
will be several 'free' invocations which are not safe.

So, this commit will simply correct such an oversight.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: justify those header #define description comments
Jim Warner [Tue, 14 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: justify those header #define description comments

This commit is an example of what can happen when this
author is waiting around for the release of our newlib
& otherwise runs out of legitimate changes to be made.

[ on the other hand, such changes surely make us run ]
[ quite a bit more efficiently, if i am not mistaken ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: Add note in sysctl.conf.5 for line length
Craig Small [Wed, 15 Sep 2021 11:45:26 +0000 (21:45 +1000)]
docs: Add note in sysctl.conf.5 for line length

References:
 procps-ng/procps#77

3 years agodocs: Fix comment for priority
Craig Small [Wed, 15 Sep 2021 11:36:40 +0000 (21:36 +1000)]
docs: Fix comment for priority

Adjust the pri field for ps.1 because a higher pri field means a
higher priority.

References:
 procps-ng/procps#115

3 years agosysctl: Return non-zero if param setting failed
Jan Rybar [Wed, 15 Sep 2021 11:07:43 +0000 (21:07 +1000)]
sysctl: Return non-zero if param setting failed

Real usecase:
'sysctl -w user.max_uts_namespaces=2147483648; echo $?'
returns 0 even though it failed with EINVAL

The close_stream() realised there was an issue and printed an
error but didn't change the return value.

Slightly modified merge request.

References:
 procps-ng/procps!76

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agomisc: Add NEWS for previous
Craig Small [Wed, 15 Sep 2021 10:54:30 +0000 (20:54 +1000)]
misc: Add NEWS for previous

References:
 procps-ng/procps!91

3 years agopgrep: Add a newline after regex error messages
Tom Levy [Fri, 1 Nov 2019 02:17:54 +0000 (02:17 +0000)]
pgrep: Add a newline after regex error messages

The message from 'regerror' does not include a newline.

Test with `pgrep '*'`.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotestsuite: Add sysctl test for directory checks
Craig Small [Wed, 15 Sep 2021 10:16:06 +0000 (20:16 +1000)]
testsuite: Add sysctl test for directory checks

Adds a test to try to write a sysctl parameter above /proc
and passes if it gives an error message.

References:
 commit f25d462166f80b844d33dad3e4c06088c809a426

3 years agosysctl: Update previous patch for newlib
Craig Small [Wed, 15 Sep 2021 10:09:44 +0000 (20:09 +1000)]
sysctl: Update previous patch for newlib

This change was cherry picked from old library branch but
missed the change to check the path.

References:
 commit 6389deca5bf667f5fab5912acde78ba8e0febbc7

3 years agosysctl: Support systemd glob patterns
Craig Small [Mon, 13 Sep 2021 12:07:37 +0000 (22:07 +1000)]
sysctl: Support systemd glob patterns

systemd-sysctl handles glob patterns along with overrides and
exceptions. Now the procps sysctl does it too.

The return value for sysctl is consistently either 0 or 1.

Added tests to check sysctl functions.

References:
 procps-ng/procps#191

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotop: some minor tweaks supporting long cmdline options
Jim Warner [Wed, 8 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: some minor tweaks supporting long cmdline options

This darn patch began as 1 correction to an extraneous
comma in the man document. Then, it grew to include an
adjustment for a couple of additional man page things.

After that, I figured I might as well tighten up logic
dealing with those awful gaps in the getopt_long code.

[ the error_exit mentioned in the associated comment ]
[ will only be taken when '=' ends the argv vectors! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: update to acknowledge top's long cmdline options
Jim Warner [Sat, 4 Sep 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: update to acknowledge top's long cmdline options

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: update man document with new long cmdline options
Jim Warner [Sat, 4 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: update man document with new long cmdline options

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: utilize getopt and introduce long cmdline options
Jim Warner [Sat, 4 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: utilize getopt and introduce long cmdline options

For quite some time now, top has stood out like a sore
thumb regarding the approach to cmdline options & help
text.  Only short options were used and that same help
text was displayed for '-h' (help) plus 'v' (version).

[ also, top 'rolled his own' when it came to parsing ]
[ options while avoiding that getopt implementation. ]

Well, with this commit all of that has changed and top
now has added a long form of his options. Additionally
he employs getopt_long() for the bulk of that parsing.

[ however, top will still avoid separate fputs calls ]
[ characteristic of other procps-ng programs when it ]
[ comes to help. rather all such text is one string. ]

Along the way, the following major getopt deficiencies
were addressed, assuming the absence of a new #define:

* an equals sign ('=') is allowed on both option forms

* whitespace is allowed before & after the equals sign

* optional arguments needn't abut their related option
for short form nor is an '=' required with either form

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: some minor organizational tweaks for man document
Jim Warner [Fri, 3 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: some minor organizational tweaks for man document

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: trade 2 strstr & atoi calls for 1 sscanf call
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: trade 2 strstr & atoi calls for 1 sscanf call

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: just eliminate a couple of unnecessary braces
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: just eliminate a couple of unnecessary braces

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: and just eliminate a couple of unnecessary braces
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: and just eliminate a couple of unnecessary braces

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: reposition call to cpus_refresh() for consistency
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: reposition call to cpus_refresh() for consistency

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: corrected single man document typographical error
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: corrected single man document typographical error

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: man page now reflects change for the 'select' i/f
Jim Warner [Thu, 12 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: man page now reflects change for the 'select' i/f

Reference(s):
https://www.freelists.org/post/procps/important-extension-to-newlib,4
. 'select' i/f top response
commit 23776571a74ce9c526b0171ca8ba7ec0357d8002
. 'select' i/f library change
commit af34cc964ae7667db15d2507f24098c26ba3c664

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: address major bug in the 'listed_nextpid' guy
Jim Warner [Tue, 10 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: address major bug in the 'listed_nextpid' guy

Ever since 2003, the 'listed_nextpid' routine has been
misrepresenting its duties. Far from finding processes
in a list given to openproc, it just inserted the next
pid in that list into the passed proc_t as BOTH a tgid
and tid. There was no attempt to validate such values.

The net result is that tid & tgid were valid only with
a thread group leader. When called with a pid for some
sibling thread, the resulting tgid would be incorrect.

With this commit, our little function will now attempt
to validate both the tid and tgid. If this should fail
then the fallback position will be the same as what we
inherited. So we're no worse off & likely much better.

[ note that calling the function with a thread's pid ]
[ likely stems from 2011 when a 'readeither' routine ]
[ was added which dealt with both tasks and threads! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: disabled some code that now serves no purpose
Jim Warner [Tue, 10 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: disabled some code that now serves no purpose

In the patch shown below, two lines involving the flag
PROC_UID were uncommented (enabled). However given the
construct of the readeither function, it is impossible
for the simple_readtask guy to be called when its TGID
leader has already been ignored. So, let's disable it.

[ it's only now true that the lines serve no purpose ]
[ after the commit shown below tweaked readeither to ]
[ access the base directory of the tgid leader. but, ]
[ before that, the 2 lines should have been enabled! ]

Reference(s):
. two lines uncommented
commit af34cc964ae7667db15d2507f24098c26ba3c664
. tweaked readeither
commit a37526260917bac624ae6b75fd9f4ea7287d81ad

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: thread mode transitions should remove focus ('F')
Jim Warner [Sun, 8 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: thread mode transitions should remove focus ('F')

The commit referenced below forced a return to row one
whenever there was a thread mode transition. Now, with
our new focus ('F') feature, we should adopt a similar
philosophy so as to avoid potential display anomalies.

Reference(s)
. Jun 2018, force row 1 w/ thread mode transition
commit 19ec80bd416c570a70f2fa7fa7e84a2667d71a08

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: respond to that preceding fix in the 'select' i/f
Jim Warner [Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: respond to that preceding fix in the 'select' i/f

This patch makes it possible to honor our '-H' threads
switch even when operating under that '-p' switch used
to select/filter only certain pids. Of course, what we
have done is just exploit the new library enhancement.

[ and we're pretending we don't know the enumerators ]
[ PIDS_FETCH_THREADS_TOO + PIDS_SELECT_PID are equal ]
[ to that PIDS_SELECT_PID_THREADS enumerator itself. ]

[ thankfully, those dependencies can be assured with ]
[ a 'make check-lib' which exploits ITEMTABLE_DEBUG! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: repair <pids> api boo-boo in the 'select' i/f
Jim Warner [Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: repair <pids> api boo-boo in the 'select' i/f

The patch referenced below corrected some flaws in the
procps_pids_select implementation. But, there remained
one flaw which this commit will now hopefully address.

Rather than assume callers wished to select only tasks
and not threads meant a command like 'top -H -p 10329'
works differently under newlib than release 3.3.17. It
fails to honor the '-H' (threads) switch under newlib.

So, to fix that oops, we'll allow that select function
to get threads or tasks depending on its 'which' parm.

Reference(s):
. Oct 2015, some flaws corrected
commit bc616b361596bc3008800de839b88446508cfdd0

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: ensure thread group leader retrieval accuracy
Jim Warner [Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: ensure thread group leader retrieval accuracy

With that recent addition of the autogroup provisions,
it became apparent that '/proc/<pid>/task' information
is sometimes incomplete. In fact, there's no autogroup
file at all in any '/proc/<pid>/task/<pid>' directory!

As a result, when the top -H mode was invoked, all the
processes showed a -1 for AGID, even the group leader.

So, this commit will ensure that for every TGID leader
its basic '/proc/<pid>' directory will always be used.
The 'task' subdirectory is now only used for siblings.

[ and it's time that readeither prologue was updated ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: announce changes for displaying autogroup values
Jim Warner [Fri, 6 Aug 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: announce changes for displaying autogroup values

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: document new items for displaying autogroup values
Jim Warner [Fri, 6 Aug 2021 05:00:00 +0000 (00:00 -0500)]
ps: document new items for displaying autogroup values

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: added 2 new fields for displaying autogroup values
Jim Warner [Fri, 6 Aug 2021 05:00:00 +0000 (00:00 -0500)]
ps: added 2 new fields for displaying autogroup values

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: document 2 fields for displaying autogroup values
Jim Warner [Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: document 2 fields for displaying autogroup values

[ we'll also eliminate a couple of references to the ]
[ repurposed 'F' command which should have gone away ]
[ with the introduction of that new 'focus' feature! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: exploit new items for displaying autogroup values
Jim Warner [Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: exploit new items for displaying autogroup values

Ordinarily, whenever a new field is added to top, that
RCF_VERSION_ID should be bumped which then prevents an
older version of top from reading the expanded rcfile.

With this change, however, we'll keep the existing 'k'
version since we've yet to release the newlib version.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: add provision for displaying autogroup values
Jim Warner [Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: add provision for displaying autogroup values

In the link referenced below there's an explanation of
the linux autogroup feature which has been around ever
since linux-2.6.38. With that explanation there's also
surprising (maybe shocking) revelations about the nice
and renice commands if CONFIG_SCHED_AUTOGROUP was set.

When autogroups are active, such programs are rendered
mostly useless because the nice value will only affect
scheduling priority relative to other processes in the
same autogroup. In order to accomplish what we thought
of as renice, that nice value in /proc/<pid>/autogroup
must be changed. Altering any single member of a group
will also affect every other member of that autogroup.

So, this commit will set the stage for users of newlib
to display autogroup identifiers plus their associated
nice values (now that their importance is understood).

Reference(s):
https://github.com/nlburgin/reallynice

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: eliminated an overlooked obsoleted <pids> API item
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
ps: eliminated an overlooked obsoleted <pids> API item

When several obsolete linux-2.6 fields were eliminated
and ps responded in the commit referenced below, there
was one reference overlooked. So, with this commit the
reference to PIDS_ALARM has been whacked at long last.

Reference(s):
. Sep 2016, ps response to removal
commit 86992bb58f59d617ee2bf20de4f2a185bf817dae

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate all field numbers from the man document
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: eliminate all field numbers from the man document

As far back as release 3.2.8 (maybe even farther) this
man page used a number with each field's descriptions.

That practice caused no real harm when top was limited
to a grand total of 26 fields (thru lower case letters
of the alphabet). However, now we've reached 70 fields
and, depending on the name that's chosen, adding a new
field could result in a massive renumbering of fields.

Thus, this patch eliminates such potential by removing
all numbers from section '3a. DESCRIPTIONS of Fields'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: refactor all the readproc.h 'PROC_FILL' flags
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: refactor all the readproc.h 'PROC_FILL' flags

The 'PROC_FILL' flags, found in readproc.h, had become
almost unmanageable. The hex values were scattered all
over the map as new flags had been introduced. So this
commit resets all of them and will help ensure any new
flags don't duplicate some already existing hex value.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: document summary area changes involving 2 abreast
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: document summary area changes involving 2 abreast

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: allow the summary memory lines to print 2 abreast
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: allow the summary memory lines to print 2 abreast

The commit shown below introduced two abreast printing
for %Cpu statistics. But, the Memory & Swap lines have
always been printed on separate lines when '4' was on.

With this commit, those lines will now be treated just
like %Cpu stats, either separate lines or two abreast.

Reference(s):
. May 2020, added '4' toggle for 2 abreast
commit 59f5a37a247184b3009af963706ca68198067185

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: add a visual separator to lines printed 2 abreast
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: add a visual separator to lines printed 2 abreast

When the '4' toggle is on, and Summary Area %Cpu lines
are shown two abreast, it's not always clear where the
separation is between the two processors. So with this
patch we'll now print a vertical bar separator between
them (looking similar to the existing field headings).

We will also reduce that 'GRAPH_suffix' constant to 1,
reflecting the the trailing ']' bracket only, so as to
maximize top's exploitation of available screen width.

[ plus a superfluous double '+ +' has now been fixed ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: TREE_FOCUS_X works properly with multiple windows
Jim Warner [Wed, 28 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: TREE_FOCUS_X works properly with multiple windows

As promised, this commit will ensure that TREE_FOCUS_X
impacts only the window under which an 'F' was issued.

Previously, when 'F' was invoked it would impact every
window that was displaying forest view. Now, only that
window where 'F' was applied will show the indentation
losses whenever multiple windows were being displayed.

[ each of the 4 windows can now have different focus ]
[ pids active and not impact any other forest views! ]

Reference(s):
. 'TREE_FOCUS_X' introduction
commit c23d2708d4a6a80e029289d630c84824d27b1ada

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: trade most pids_stack pointers for a WIN_t ppt ix
Jim Warner [Tue, 27 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: trade most pids_stack pointers for a WIN_t ppt ix

For every function whose parameters consist of a WIN_t
pointer and a pointer to a pids_stack, we will instead
pass the WIN_t pointer and index to that window's ppt.

This change will save six instructions per invocation,
and converts the index once in those called functions.

[ you can consider this an efficiency change, but it ]
[ is really being implemented so that 'TREE_FOCUS_X' ]
[ #define can be made to behave as one should expect ]
[ when running under top's 'alternate display' mode! ]

[ stay tuned for the very next commit to be pushed!! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: restored a function prologue lost a long time ago
Jim Warner [Mon, 26 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: restored a function prologue lost a long time ago

For some reason, when top was modified to exploit that
<pids> api, one function prologue was removed. So this
commit just restores it to the 'window_show' function.

Reference(s):
. Aug, 2015 - adapted to new <pids> api
commit 77dc22b9101af39fc30306e36d65cad2b396cc9e

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: new #define added for focus ('F') toggle tweaking
Jim Warner [Sun, 25 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: new #define added for focus ('F') toggle tweaking

Just to see if I could, the new #define will force the
indentation of a parent task to be reset to zero while
maintaining the proper child indentation relationship.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: introduced new focus toggle ('F'), man doc & NEWS
Jim Warner [Sat, 24 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: introduced new focus toggle ('F'), man doc & NEWS

[ i also corrected an unrelated typographical error! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: introduced new focus toggle ('F'), program source
Jim Warner [Sat, 24 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: introduced new focus toggle ('F'), program source

Sometimes, it might be useful to isolate a parent task
and its forked children from other system activity. As
an example, a user might want to examine workload in a
specific lxc container. Or maybe there is some need to
question what's happening under the same tmux session.

Since forest view mode tends to be a relatively stable
display, it will sometimes satisfy the above need. But
that mode can't currently guarantee the target process
always remains as the topmost task or even is visible.

So, this patch will enable focusing on any parent task
and keeping it as the topmost process while displaying
it and its forked children only. It then appears as if
there is no other activity in that system by virtue of
the blank lines which follow that final child process.

To implement this new feature, top's redundant 'F' key
has been repurposed. It made little sense devoting two
keys to the Fields Management screen (especially since
the key we've taken required two separate keystrokes).

[ and while we're at it, i also added punctuation to ]
[ the prologue for that renamed 'forest_display' guy ]
[ since all other forest functions used punctuation. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: make eu_TREE_LVL a signed int not an unsigned int
Jim Warner [Fri, 23 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: make eu_TREE_LVL a signed int not an unsigned int

Since the internally kept nesting 'level' under forest
view is limited to a maximum of 101, we will now treat
it as signed to avoid any potential conversion issues.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: standardize 'pointer-to-thing' whitespace use
Jim Warner [Thu, 22 Jul 2021 05:00:00 +0000 (00:00 -0500)]
library: standardize 'pointer-to-thing' whitespace use

When declaring a pointer there's usually a space after
the thing-pointed-to and no space between the asterisk
and the pointer-thingy itself. So this commit enforces
such conventions where needed on old library elements.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: whack a label & branch in 'summary_show' function
Jim Warner [Wed, 21 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: whack a label & branch in 'summary_show' function

If there are zero numa nodes then the View_CPUNOD flag
cannot possibly be set. So it was unnecessary to check
both the numa total and View_CPUNOD in 'summary_show'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: added a new #define to test absence of numa nodes
Jim Warner [Tue, 20 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: added a new #define to test absence of numa nodes

This new #define will produce top results identical to
the results achieved for './configure --disable-numa'.

However it keeps the change entirely local to our top.

[ it has been introduced to test the following patch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: just play catch up with some top implementations
Jim Warner [Mon, 19 Jul 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: just play catch up with some top implementations

These changes were already implemented for this newlib
version, but not in the the master branch top version.

[ and we also add the missing 3.3.17 ps 'exe' change ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotestsuite: Add test for previous sysctl change
Craig Small [Tue, 20 Jul 2021 12:45:17 +0000 (22:45 +1000)]
testsuite: Add test for previous sysctl change

Add a check for path traversal to sysctl.

References:
 commit f25d462166f80b844d33dad3e4c06088c809a426

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agosysctl: Check path is under /proc/sys
Craig Small [Tue, 20 Jul 2021 12:36:15 +0000 (22:36 +1000)]
sysctl: Check path is under /proc/sys

sysctl would try to read/write any path you gave it either on
the command line or configuration file. It would append /proc/sys
on the path but not check for any sneaky path traversal with ../

This commit means it first resolves all paths using realpath(3)
and then checks the path starts with "/proc/sys/"

At first I thought this might be a non-issue, but perhaps someone
could put a file into the sysctl configuration path and.. do
something? Anyway its a 8-line fix and makes things more correct.

References:
 #179

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodoc: updated NEWS plus top(1) for IO accounting fields
Jim Warner [Tue, 22 Jun 2021 05:00:00 +0000 (00:00 -0500)]
doc: updated NEWS plus top(1) for IO accounting fields

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: fix a fix for the 'bye_bye' function (merge #127)
Jim Warner [Mon, 21 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: fix a fix for the 'bye_bye' function (merge #127)

In the merge request shown below, 1 too many bytes are
written to stdout thus including the terminating null.
As the cure, this commit just reduces the length by 1.

[ along the way, we will remove some unneeded braces ]
[ plus add some additional comments with attribution ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/127
. original ported cchange
commit 6b8980a3b6279058d727377e914cfb6439d6f178

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: documented those newly added IO accounting fields
Jim Warner [Sun, 20 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: documented those newly added IO accounting fields

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: follow ps lead & add several IO accounting fields
Jim Warner [Sun, 20 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: follow ps lead & add several IO accounting fields

Some time ago, IO accounting was added for the library
and exploited by the ps program. This patch just plays
a little catch-up & adds similar functionality to top.

[ and we also finally get around to incrementing the ]
[ rcfile id which should have already been done when ]
[ the smaps fields were added or, at least, with USS ]

Reference(s):
. added IO accounting to ps program
commit 8baf8eeab4d5cf4ce712f3a0048985fe045c87f7
. added IO accounting to library
commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: correct sources for IO accounting, <pids> api
Jim Warner [Sun, 20 Jun 2021 05:00:00 +0000 (00:00 -0500)]
library: correct sources for IO accounting, <pids> api

This patch just brings 'PIDS_IO' source into alignment
with the names being used in that /proc/<pid>/io file.

[ i had my chance to fix them in a whitespace change ]
[ made in the patch referenced below, but i blew it! ]

Reference(s):
commit 2dcbe71f3b8e3586acab0221b2e4c55d10cf8f76

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNLS: Update translate files
Craig Small [Thu, 17 Jun 2021 06:45:07 +0000 (16:45 +1000)]
NLS: Update translate files

3 years agotop: exploit the newly added library smaps_rollup item
Jim Warner [Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: exploit the newly added library smaps_rollup item

We're just following the ps program's lead introducing
a new 'USS' field to represent the non-swapped portion
of physical memory ('RSS') not shared by another task.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: adapt to the newly added library smaps_rollup item
Jim Warner [Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)]
ps: adapt to the newly added library smaps_rollup item

In that commit referenced below, a new field was added
to the ps program which required adding 2 newlib items
together. Such a need is now satisfied by the library.

So, this commit will just adapt ps for that provision.

Reference(s):
commit e782b1d85989a9d27474264d4d65ffe1c485bdc9

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: add new derived smaps_rollup item, <pids> api
Jim Warner [Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)]
library: add new derived smaps_rollup item, <pids> api

That recent addition of USS to the ps program prompted
this change.  Rather than have it (and soon top) add 2
separate items to yield the desired value, we will let
our new library perform the arithmetic when necessary.

Outside of a little extra storage, there is no runtime
costs for such an extension. There is, however, a real
benefit to having such code in the library. Now should
callers choose to sort on this new field, results will
be guaranteed to be what was expected (i.e. accurate).

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: refactor 'mkVIZ' support to avoid future problems
Jim Warner [Tue, 15 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: refactor 'mkVIZ' support to avoid future problems

In the patch referenced below, 2 potential abends were
fixed both of which involved 'alternate display mode'.

The root cause of those abends was a negative value in
the 'begnext' field for other than the current window.

And while that potential is fixed for now the existing
code almost invites such problems again in the future.

So, this patch will remove any temptation to name some
other window in the 'mkVIZrow1' macro. And, since that
macro is not the only source of 'begnext' changes, the
'mkVizrowX' is being added to identify such occasions.

[ and for symmetry i've added a 'mkVIZyes' macro and ]
[ ameliorated an otherwise surreptitious assignment! ]

Reference(s):
commit 8281ac4f98cf04c51cbeb746d214201531d660ec

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: Add PSS and USS fields
Craig Small [Wed, 16 Jun 2021 11:13:52 +0000 (21:13 +1000)]
ps: Add PSS and USS fields

The library added smaps_rollup fields in the referenced commit.
This commit exploits the new fields to give pss and uss options.

These options were first proposed back in 2015 by Petr Malat
and, with the library update, they are finally made it into ps.

Why use proportional or unique segment size? It is argued that
these give a better idea of the "real" memory usage of a process.

References:
 commit 12543b6c7690c379abc28e278cd804c05490a8b1
 issue #112
 https://www.freelists.org/post/procps/PSS-and-USS-support-for-ps
 https://lwn.net/Articles/230975/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotestsuite: Add test for free committed
Craig Small [Wed, 16 Jun 2021 10:34:33 +0000 (20:34 +1000)]
testsuite: Add test for free committed

Add a check for free -v for committed memory.

References:
 commit 16734d580eb779654e626f3b41a98992fc0d557d

3 years agofree: option to show memory commit limits
Craig Small [Wed, 16 Jun 2021 10:29:03 +0000 (20:29 +1000)]
free: option to show memory commit limits

This commit is largely the userland only changes found in !73
added by Jens Låås (@jelaas)

References:
 procps-ng/procps!73

3 years agoc: print strerror() instead of error code.
Érico Nogueira [Fri, 4 Jun 2021 16:10:28 +0000 (13:10 -0300)]
c: print strerror() instead of error code.

This changes error() behavior to match what glibc already does.

3 years agofree: Clean up scale_size and fix `free -h --si`
Jan Alexander Steffens (heftig) [Tue, 15 Jun 2021 18:43:36 +0000 (20:43 +0200)]
free: Clean up scale_size and fix `free -h --si`

- Simplify control flow a bit. We don't need two loop variables, either.
- Consistently use %lld for bytes.
- Fix the base handling for human-readable output. The code used to
  calculate *mebibytes* first, then scale that to the required exponent
  with the selected base, which is patently wrong.

Fixes https://gitlab.com/procps-ng/procps/-/issues/133

3 years agotop: fix two potential 'alternate display mode' abends
Jim Warner [Mon, 31 May 2021 05:00:00 +0000 (00:00 -0500)]
top: fix two potential 'alternate display mode' abends

This commit will address potential abends upon leaving
the windows help or color mapping screens and invoking
alternate display mode ('A').  It only happens if that
current window was changed with multiple 'a'/'w' keys.

So now, rather than leaving a trail of negative values
in the 'begtask' field, compliments of that win_select
function, we'll remove the mkVIZrow1 macro. Henceforth
it will be issued just once per user interaction. Thus
a promise of 'Curwin' only being impacted is restored.

[ my thanks to Vladimir Chren for reporting this bug ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/210
https://gitlab.com/procps-ng/procps/-/merge_requests/135

Discovered by:Vladimir Chren <vladimir.chren@gmail.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agosysctl man page update for pattern
Bas van der Vlies [Thu, 25 Feb 2021 08:35:33 +0000 (09:35 +0100)]
sysctl  man page update for pattern

pattern must be used before `--system` else it does not work for sysctl
file(s)

```
root# /sbin/sysctl --system --pattern '^net.ipv6'
* Applying /etc/sysctl.d/30-ceph-osd.conf ...
fs.aio-max-nr = 1048576
kernel.pid_max = 4194304
* Applying /etc/sysctl.d/protect-links.conf ...
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
* Applying /etc/sysctl.d/sara_tweaks.conf ...
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 0
* Applying /etc/sysctl.conf ...
```

vs:
```
root# /sbin/sysctl --pattern '^net.ipv6' --system
* Applying /etc/sysctl.d/30-ceph-osd.conf ...
* Applying /etc/sysctl.d/protect-links.conf ...
* Applying /etc/sysctl.d/sara_tweaks.conf ...
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 0
* Applying /etc/sysctl.conf ...
```

References:
 !124

3 years agoconfigure: add macro to check for __PROGNAME
Henrik Grimler [Wed, 26 May 2021 13:45:02 +0000 (15:45 +0200)]
configure: add macro to check for __PROGNAME

in include/c.h we check if HAVE___PROGNAME is defined, but the
corresponding macro for setting (or not setting) it is missing from
the configure script. This commit adds the missing macro, by
copying it from the macro in tmux.

3 years agoCoverity scan findings - memleaks, unused vars, potential nullptr dereferences
Jan Rybar [Thu, 6 May 2021 14:30:54 +0000 (16:30 +0200)]
Coverity scan findings - memleaks, unused vars, potential nullptr dereferences

3 years agolibrary: rename/reposition two enumerators, <pids> api
Jim Warner [Fri, 30 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: rename/reposition two enumerators, <pids> api

The two special hugetlbfs items were misnamed. The TBL
reference (table) should be TLB (transaction lookaside
buffer). Besides, I never liked their position anyway!

[ and one macro argument tweak is being snuck in too ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: add comments for the new smaps_rollup provisions
Jim Warner [Wed, 28 Apr 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: add comments for the new smaps_rollup provisions

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: document all of top's new smaps_rollup provisions
Jim Warner [Tue, 27 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: document all of top's new smaps_rollup provisions

[ of course, we had to renumber most existing fields ]
[ with these additions. plus, some typos were fixed. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: exploit some of those new smaps_rollup provisions
Jim Warner [Tue, 27 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: exploit some of those new smaps_rollup provisions

My, how time flies. Here we are finally attending to a
2 year old issue at long last (well, at least top is).

In truth, this change was prompted by that more recent
issue #201 and simply represents my initial picks from
among those available with the new library provisions.

Note: we have to bump that rcfile version whenever new
fields are added. That will mean older top programs no
longer can read this top's rcfile. But that's Ok since
top offers a warning before replacing an older rcfile.

Doubtless, more smaps_rollup fields will be introduced
under top as we get more experience with this feature.
However, any such usage comes with tremendoud costs as
was reported for the previous patch and repeated here:

Here is a small preview of just what you will discover
when using this command line: time top/top -d0 -n1000.

------------------------------------ as a regular user
    with only PID + RES (statm)
real       0m2.605s
user       0m1.060s
sys        0m1.377s
    with only PID + RSS (smaps)
real      0m26.397s                    10x more costly
user       0m1.253s
sys       0m24.915s

----------------- as a root (thus smaps for all tasks)
    with only PID + RES (statm)
real       0m2.651s
user       0m1.177s
sys        0m1.286s
    with only PID + RSS (smaps)
real      0m33.040s                    12x more costly
user       0m1.256s
sys       0m31.533s

Reference(s):
. top/ps: add support for PSS reporting
https://gitlab.com/procps-ng/procps/-/issues/112
. ps: expose shared/private memory separately
https://gitlab.com/procps-ng/procps/-/issues/201

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: add support for smaps_rollup file, <pids> api
Jim Warner [Mon, 26 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: add support for smaps_rollup file, <pids> api

A couple of people have suggested that smaps_rollup be
added to the ps program and/or top program. This patch
is intended to set the stage for just such extensions.

There are currently 20 displayable items in the rollup
file. And newlib sometimes uses sscanf when populating
the target, sometimes hsearch and one customized gperf
approach. None of these fit well with the smaps items.

Thus, an approach using a simple table lookup was used
and, by disabling 1 code line, it could be made immune
from changes to the items order (unlike a sscanf call)
and doesn't carry the greater cost of a hsearch/gperf.

Note: The next patch will allow top to display some of
these new fields. Then, it'll be possible to determine
the colossal costs of accessing the smaps_rollup file.

Here is a small preview of just what you will discover
when using the command 'time top/top -d0 -n1000' while
configured with just two fields: PID + 1 memory field.

------------------------------------ as a regular user
    with only PID + RES (statm)
real       0m2.605s
user       0m1.060s
sys        0m1.377s
    with only PID + RSS (smaps)
real      0m26.397s                    10x more costly
user       0m1.253s
sys       0m24.915s

----------------- as a root (thus smaps for all tasks)
    with only PID + RES (statm)
real       0m2.651s
user       0m1.177s
sys        0m1.286s
    with only PID + RSS (smaps)
real      0m33.040s                    12x more costly
user       0m1.256s
sys       0m31.533s

Reference(s):
. ps: expose shared/private memory separately
https://gitlab.com/procps-ng/procps/-/issues/201
. top/ps: add support for PSS reporting
https://gitlab.com/procps-ng/procps/-/issues/112

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: some miscellaneous tweaks before smaps_rollup
Jim Warner [Mon, 26 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: some miscellaneous tweaks before smaps_rollup

This commit is strictly cosmetic. It was an attempt to
normalize/standardize/alphabetize those #define/#undef
statements. Some missing #undef's were added plus some
comments regarding sources corrected/standardized too.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: extend end-of-job report to reflect unused fields
Jim Warner [Sun, 25 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: extend end-of-job report to reflect unused fields

In anticipation of adding some smaps_rollup stuff, our
end-of-job report will now offer some insight into the
current unused entries for a window's fieldscur array.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agovmstat: add guest time to stat
Christian Borntraeger [Wed, 28 Apr 2021 08:51:34 +0000 (18:51 +1000)]
vmstat: add guest time to stat

Since 2.6.24/33 the kernel knows about guest and guest nice time. That
is the time that is spend in KVM guests. To handle userspace programs
that do not know about this the guest time is also added to user.

Let us provide a guest time column in vmstat that collects both guest
and guest nice into a gu value.

We also subtract that value from the user time as we are now aware of
the guest value.

This commit is different to !113 in several ways:
 * newlib already knows about these to values
 * vmstat summary already shows these values
 * non-wide vmstat squishes the values

So its around the wide vmstat output.

References:
 procps-ng/procps!113
Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agolibrary: fix alignment with new 'io' types, <pids> api
Jim Warner [Sat, 24 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: fix alignment with new 'io' types, <pids> api

The commit referenced below was well done but needed a
small whitespace tweak to preserve existing alignment.

Reference(s):
. io accounting added
commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agomisc: Add NEWS item for previous
Craig Small [Sat, 24 Apr 2021 13:17:35 +0000 (23:17 +1000)]
misc: Add NEWS item for previous

3 years agops: Add IO Accounting fields
Craig Small [Sat, 24 Apr 2021 13:13:38 +0000 (23:13 +1000)]
ps: Add IO Accounting fields

Add the fields for the IO accounting to ps as the library now
has them added from previous commit.

References:
 commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

3 years agolibrary: adding IO accounting
Craig Small [Sat, 24 Apr 2021 12:38:48 +0000 (22:38 +1000)]
library: adding IO accounting

This is a modification of MR !122 by @renit1609 to fit the new
library.

Problem statement:
The procps library has no PROC_FILLIO flag to
fetch the proc field "/proc/[pid]/io" data
process-wise.
IO Accounting is not included as part of procps.

Requirement:
We have a requirement to fetch process wise
IO utilization which can be used for monitoring.

When looking through the procps library, I see
that IO Accounting (/proc/[pid]/io) is not being
included as part of procps. There is no such
flag like PROC_FILLIO being included in readproc.h .

Solution:
While looking at the implementation done for
other proc fields, I used the spare bits in app code.
I renamed PROC_SPARE_1 as PROC_FILLIO, the spare bit from
PROC_SPARE_* and used it for fetching /proc/[pid]/io
data as part of the procps library similar to other
fields. I moved the PROC_SPARE_* bits each by 1 bit
to retain the spare bits. Meanwhile added the IO fields
in proc_t structure.

References:
 procps-ng/procps!122
 procps-ng/procps#184

3 years agowatch.1: Correct long option for no linewrap.
Craig Small [Sat, 24 Apr 2021 02:01:49 +0000 (12:01 +1000)]
watch.1: Correct long option for no linewrap.

The correct long option for -w is --no-wrap but the man page
said it was --no-linewrap

References:
 procps-ng/procps#203

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agobuild-sys: find split systemd libraries
Christian Hermann [Wed, 14 Apr 2021 07:42:53 +0000 (09:42 +0200)]
build-sys: find split systemd libraries

With 4e7f4237 and 5e73c832, systemd library detection through pkg-config
was changed to unconditionally look for unified libsystemd.

This adds a fallback to match the previous behavior and find the split
libs as well.

References:
 procps-ng/procps!128

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoescape.c: Fix missing nl_langinfo on certain configs
Issam E. Maghni [Sat, 24 Apr 2021 01:46:48 +0000 (11:46 +1000)]
escape.c: Fix missing nl_langinfo on certain configs

nl_langinfo and CODESET are undefined in a musl system. Instead of
uncondionally including langinfo.h, this change includes include/nls.h
which has the tests and work-arounds for systems that don't have these
features. This is similar to how other programs within procps include
langinfo.h via nls.h

References:
 procps-ng/procps!130

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoconfigure: Add --disable-w
Issam E. Maghni [Fri, 23 Apr 2021 19:58:36 +0000 (15:58 -0400)]
configure: Add --disable-w

Some systems implement utmp as a stub so it doesn't make sense to have
a non-functioning w.  This change mitigates #193 and !126

References:
 procps-ng/procps!129
 procps-ng/procps!126
 procps-ng/procps#193