summaryrefslogtreecommitdiff
path: root/usr.bin/top
AgeCommit message (Collapse)Author
2023-03-08Delete obsolete /* ARGSUSED */ lint comments.Philip Guenther
ok miod@ millert@
2023-01-07Add {get,set}thrname(2) for putting thread names in the kernel andPhilip Guenther
exposed in a new field returned by sysctl(KERN_PROC). Update pthread_{get,set}_name_np(3) to use the syscalls. Show them, when set, in ps -H and top -H output. libc and libpthread minor bumps ok mpi@, mvs@, deraadt@
2022-12-16top(1): always recount number of online CPUsScott Soule Cheloha
If hw.smt is toggled while top(1) is running in "combined" mode the CPU count on the CPU state line is incorrect. We always need to recount the number of online CPUs.
2022-09-10top(1): remove last vestiges of "last pid" supportScott Soule Cheloha
millert@ removed most of the "last pid" support from top(1) in 1997. See, e.g. top/machine.c,v1.7: http://cvsweb.openbsd.org/src/usr.bin/top/machine.c?rev=1.7&content-type=text/x-cvsweb-markup Let's remove the rest of it: - Eliminate system_info.last_pid. - Remove mpid parameter and "last pid" printing code from i_loadave(). Link: https://marc.info/?l=openbsd-tech&m=166277253606823&w=2 ok millert@
2022-08-08top(1): display uptime with seconds, print uptime in fixed formatScott Soule Cheloha
1. It's sometimes useful to know the system uptime with more precision than one minute. So, this patch changes top(1) to print seconds of uptime in addition to minutes, hours, and days. 2. It's *always* annoying when the information you want on a realtime display is not shown in the same place in a consistent format. So, this patch also changes top(1) to always print the uptime like this: up D days HH:MM:SS This is much easier to read at a glance. In particular, it requires no additional thought on my part to figure out whether the machine has been up less than one day. Maybe of note is that these changes make top(1)'s output different from that of uptime(1). I don't think this matters very much. top(1) is a realtime display, so it isn't likely to be parsed. uptime(1) is a different story. Link: https://marc.info/?l=openbsd-tech&m=160046282400892&w=2 Positive feedback from kn@. ok gnezdo@ bluhm@ millert@
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-02-22MAXCOMLEN is no longer needed in these programs, so remove the annotationTheo de Raadt
from sys/param.h include lines, or remove the include lines entirely if it this was the least requirement. ok millert
2022-02-18Avoid gendered language in man pages when not referring to a specificJonathan Gray
person. Rewrite or use singular they. ok thfr@ sthen@ daniel@ ian@ job@ kmos@ jcs@ ratchov@ phessler@ and others I'm likely missing on an earlier version. feedback tj@, feedback and ok jmc@
2021-03-12spellingJonathan Gray
2021-02-19Add 't' to options in man page. ok jmc@ kn@Mark Lumsden
2020-08-26Add "t" to toggle the display of routing tableskn
Swap the WAIT column with RTABLE (and vice versa); WAIT is wide enough to fit RTABLE, somewhat adds additional value to STATE and seems therefore most appropiate to hide in favour of RTABLE. Filtering rtables with "T" does not toggle the column, just like filtering users with "u" does not toggle between user and thread id. Feedback jmc OK remi
2020-08-25Rename rtable filter variables and simplify buffer handlingkn
No functional change, the rename is for consistency and the buffer handling reduces churn in an upcoming diff.
2020-08-23Filter by routing tablekn
"-T-0" for processes outside the default routing table, "-T3" for those in a specific one; same semantics as with other filters. Manual wording and command line flag taken from pgrep(1) being the only way to identify processes by routing table; After netstat(1)'s recent addition of "-R", filtering in top makes for handy tooling around rtable(4). "looks good to me" millert OK remi
2020-07-26Add / as alias for g (grep)kn
Simpliy mdoc(7) markup for "n|# count" while here. Positive manual feedback jmc No objections millert
2020-07-06Use mnemonic KERN_PROC_ALL not literal zerokn
No object change.
2020-06-27Add missing scroll keys to help page, name default signale for kill commandkn
The order of commands is not in sync between help page and manual, but I refrained from reordering to avoid churn. OK millert
2020-06-26Remove duplicate initialisationkn
Those are global variables are (zero) initialised as such already and machine_init() is called only once upon startup. OK mvs
2020-06-25Remove unused "remaining" member in struct handlekn
Only ever set or decremented since import with machine.c r1.1 (1997); While here, simplify the skip semantics behind the scroll functionality. OK millert
2020-06-24Remove obsolete comment about "extra nulls"kn
Those were removed in r1.39 in 2004.
2020-06-23Fix COMMAND descriptionkn
There is no code anymore that puts angle brackets around swapped out processes, machine.c r1.54 removed this in 2006. Typo in first diff spotted by Matthew Martin, OK jmc (who also pointed out the CVS commit)
2020-06-23Remove redundant NULL checkkn
For the sake of simplicity and to reflect that the process list is always sorted (default is "cpu"), even if not explicitly requested; this makes it easier to argue about the code around sort order and its selection. OK millert
2020-01-07zap trailing whitespace;Jason McIntyre
2020-01-06Implement scrolling in top(1) using 9 and 0 keys.Vadim Zhukov
Planned improvements: scroll position displaying, using arrow/pgup/pgdown keys. okay tedu@
2019-12-16Delete tests for P_THREAD that predate the existence ofPhilip Guenther
KERN_PROC_SHOW_THREADS and have been rendered superfluous by it. Similarly, some P_SYSTEM tests can be deleted or pushed to the kernel by using KERN_PROC_ALL instead of KERN_PROC_KTHREAD. ok visa@ mpi@
2019-10-27+ resets P as wellkn
The manual has it, complete the help screen. OK millert
2019-10-08Simplify threads flag handlingkn
Instead of always passing the threads flag which decides whether other function arguments are used or not, make callers pass those arguments or NULL depending on the threads flag. This reflects better how thread IDs are shown in place of user names/IDs. OK millert
2019-10-08Replace "boolean.h" with <stdbool.h>kn
Be consistent with other programs in base and unify variable usage as follows to improve readability: bool = (bool == No) ? Yes : No -> bool = !bool if (bool == Yes) -> if (bool) if (bool == No) -> if (!bool) bool = Maybe -> bool = -1 OK millert
2019-10-06Avoid gasting around get_process_info()kn
get_process_info() returns a pointer to the global handle later only be used in format_next_process(); treat this struct handle as such without casting the pointer to caddr_t and back again. No object change. OK millert deraadt
2019-10-06Zap intermediate structs in compare_*()kn
SETORDER() can assign from function arguments directly without additional identical structs in each function. No object change. OK millert
2019-07-03snprintf/vsnprintf return < 0 on error, rather than -1.Theo de Raadt
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2018-11-28Allow reverse sort orderkn
Prefixing the field with a dash will sort processes in reverse order. `o -pid' will therefore list PID 1 on top. "looks good" tedu, improvements and OK cheloha
2018-11-17Add new KERN_CPUSTATS sysctl(2) so we can identify offline CPUs.cheloha
Because of hw.smt we need a way to determine whether a given CPU is "online" or "offline" from userspace. KERN_CPTIME2 is an array, and so cannot be cleanly extended for this purpose, so add a new sysctl(2) KERN_CPUSTATS with an extensible struct. At the moment it's just KERN_CPTIME2 with a flags member, but it can grow as needed. KERN_CPUSTATS appears to have been defined by BSDi long ago, but there are few (if any) packages in the wild still using the symbol so breakage in ports should be near zero. No other system inherited the symbol from BSDi, either. Then, use the new sysctl(2) in systat(1) and top(1): - systat(1) draws placeholder marks ('-') instead of percentages for offline CPUs in the cpu view. - systat(1) omits offline CPU ticks when drawing the "big bar" in the vmstat view. The upshot is that the bar isn't half idle when half your logical CPUs are disabled. - top(1) does not draw lines for offline CPUs; if CPUs toggle on or offline in interactive mode we redraw the display to expand/reduce space for the new/missing CPUs. This is consistent with what some top(1) implementations do on Linux. - top(1) omits offline CPUs from the totals when CPU totals are combined into a single line (the '-1' flag). Originally prompted by deraadt@. Discussed endlessly with deraadt@, ketennis@, and sthen@. Tested by jmc@ and jca@. Earlier versions also discussed with jca@. Earlier versions tested by jmc@, tb@, and many others. docs ok jmc@, kernel bits ok ketennis@, everything ok sthen@, "Is your stuff in yet?" deraadt@
2018-11-02Accept numeric user IDskn
This makes `top -U 0' and "u-1000" work. Feedback and "that looks right" tedu, OK millert, manual bits and OK jmc
2018-11-01Merge duplicate code into helper functionskn
This introduces filteruser() and filterpid(), where the first one can now easily be extended to support matching numeric UIDs. The latter one is now used by the `highlight` command as well. No change in behaviour or output. Feedback and OK millert
2018-10-05Revert KERN_CPTIME2 ENODEV changes in kernel and userspace.cheloha
ok kettenis deraadt
2018-09-26KERN_CPTIME2: set ENODEV if the CPU is offline.cheloha
This lets userspace distinguish between idle CPUs and those that are not schedulable because hw.smt=0. A subsequent commit probably needs to add documentation for this to sysctl.2 (and perhaps elsewhere) after the dust settles. Also included here are changes to systat(1) and top(1) that account for the ENODEV case and adjust behavior accordingly: - systat(1)'s cpu view prints placeholder marks ('-') instead of percentages for each state if the given CPU is offline. - systat(1)'s vmstat view checks for offline CPUs when computing the machine state total and excludes them, so the CPU usage graph only represents the states for online CPUs. - top(1) does not draw CPU rows for offline CPUs when the view is redrawn. If CPUs "go offline", percentages for each state are replaced by placeholder marks ('-'); the view will need to be redrawn to remove these rows. If CPUs "go online" the view will need to be redrawn to show these new CPUs. In "combined CPU" mode, the count and the state totals only represent online CPUs. Ports using KERN_CPTIME2 will need to be updated. The changes described above to make systat(1) and top(1) aware of the ENODEV case *and* gracefully handle a changing HW_NCPUONLINE while the application is running are not necessarily appropriate for each and every port. The changes described above are so extensive in part to demonstrate one way a program *might* be made robust to changing CPU availability. In particular, changing hw.smt after boot is an extremely rare event, and this needs to be weighed when updating ports. The logic needed to account for the KERN_CPTIME2 ENODEV case is very roughly: if (sysctl(...) == -1) { if (errno != ENODEV) { /* Actual error occurred. */ } else { /* CPU is offline. */ } } else { /* CPU is online and CPU states were set by sysctl(2). */ } Prompted by deraadt@. Basic idea for ENODEV from kettenis@. Discussed at length with kettenis@. Additional testing by tb@. No complaints from hackers@ after a week. ok kettenis@, "I think you should commit [now]" deraadt@
2018-09-22Remove unused Table_size define and digits() function.Todd C. Miller
2018-09-22Use user_from_uid() and uid_from_user() directly. The wrappersTodd C. Miller
in username.c are now so simple there is no longer a good reason to use them. OK deraadt@
2018-09-22fix uid -> username lookupRichard Procter
ok deraadt@
2018-09-16Unbreak tree with 'char *' -> 'const char *' forKenneth R Westerback
userid().
2018-09-16Use uid_from_user(3) and gid_from_group(3) in utilities thatTodd C. Miller
do repeated lookups. OK tb@
2018-09-13Fix warnings caused by user_from_uid() and group_from_gid() nowTodd C. Miller
returning const char *.
2018-07-29After "termcap" initilization is finished, top appears to not open anyTheo de Raadt
files ever again, so we can re-pledge tighter.
2018-07-25Document the spinning time of the CPU in systat(1) and top(1).Alexander Bluhm
from Marcus MERIGHI; OK deraadt@ jmc@
2018-05-14Stopping counting and reporting CPU time spent spinning on a lock asMartin Pieuchot
system time. Introduce a new CP_SPIN "scheduler state" and modify userland tools to display the % of timer a CPU spents spinning. Based on a diff from jmatthew@, ok pirofti@, bluhm@, visa@, deraadt@
2018-01-04glaring KNF violationTheo de Raadt
2017-12-18Add the CLOCK_BOOTTIME clockid for use with clock_gettime(2)cheloha
and put it to use in userspace in lieu of the kern.boottime sysctl. Its absolute value is the time that has elapsed since the system booted, i.e., the system uptime. Use in top(1), w(1), and snmpd(8) eliminates a race with settimeofday(2), adjtime(2), etc. inherent to deriving the system uptime via the kern.boottime sysctl. Product of a great deal of discussion/revision with jca@, tb@, and guenther@. ok tb@ jca@ guenther@ dlg@ mlarkin@ tom@
2017-05-30avoid some shadow warnings. from Brian CallahanTed Unangst
2017-03-15annoying whitespace die die dieTheo de Raadt