summaryrefslogtreecommitdiff
path: root/proc/pids.h
Commit message (Collapse)AuthorAgeFilesLines
* misc: amend the man page & source file copyright datesJim Warner2022-01-071-1/+1
| | | | | | | This just updates the copyright dates in the documents where I was already represented. Others are unchanged. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: reposition those 'info' structures in headersJim Warner2021-12-161-2/+2
| | | | | | | | For some unknown reason all the 'info' structures were declared between macros and function prototypes rather than right after all the other structure declarations. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: change 'PIDS_PROCESSOR' into a signed integerJim Warner2021-12-161-1/+1
| | | | | | | This change is really being made on behalf of the ps & top programs. Besides, over 2 billion CPUs are plenty! Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: repair <pids> api boo-boo in the 'select' i/fJim Warner2021-08-091-2/+4
| | | | | | | | | | | | | | | | | | | | 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>
* library: add provision for displaying autogroup valuesJim Warner2021-08-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* library: refactor all the readproc.h 'PROC_FILL' flagsJim Warner2021-08-091-2/+2
| | | | | | | | | | 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>
* library: correct sources for IO accounting, <pids> apiJim Warner2021-06-231-7/+7
| | | | | | | | | | | | | 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>
* library: add new derived smaps_rollup item, <pids> apiJim Warner2021-06-171-0/+1
| | | | | | | | | | | | | | | 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>
* library: rename/reposition two enumerators, <pids> apiJim Warner2021-05-021-2/+2
| | | | | | | | | | 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>
* library: add support for smaps_rollup file, <pids> apiJim Warner2021-04-291-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* library: fix alignment with new 'io' types, <pids> apiJim Warner2021-04-271-7/+7
| | | | | | | | | | | 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>
* library: adding IO accountingCraig Small2021-04-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* library: lessen chance of distortion on TICS_ALL_DELTAJim Warner2021-04-241-1/+1
| | | | | | | | | | | | | That old library defined this field as 'unsigned int'. However, here it was known as a 'signed int'. Thus for consistency we'll now also treat it as 'unsigned int'. [ this commit was made in pursuit of a bug involving ] [ the distortion of elapsed task tics. but, it turns ] [ out these changes had nothing to do with that bug. ] [ however, the patch is being retained as desirable. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: fix a few source/origin notations, <pids> apiJim Warner2021-03-111-23/+23
| | | | | | | | | | | | | After removing brackets from those 'derived' notations I was surprised to discover that several origin/source comments were wrong. So this patch fixes those errors. [ along the way a couple enumerators were renamed to ] [ better (i hope) reflect what they're representing. ] [ that, in turn, also required a little rearranging. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: clean 'derived' origins in header, <pids> apiJim Warner2021-03-111-25/+25
| | | | | | | | | None of the other four new api headers use brackets on derived items. With this patch we normalize the fifth. [ it makes for a cleaner, less confusing, appearance ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: update those source files for copyright datesJim Warner2021-02-091-2/+2
| | | | | | | | | | | | | In addition to copyright date, the initial descriptive line was changed from a generic statement to one which reflects the specific portion of the proc/ filesystem. [ such descriptions alternate between 'declarations' ] [ (h files) & corresponding 'definitions' (c files). ] Also, a few missing copyright attributions were added. Signed-off-by: Jim Warner <james.warner@comcast.net>
* misc: Update Craig's emailCraig Small2021-01-211-1/+1
|
* library: ensure 'XTRA_PROCPS_DEBUG' works in real lifeJim Warner2020-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This commit attempts to smooth some wrinkles impacting any future libprocps user exploitation. The 2 problems relate exclusively to our XTRA_PROCPS_DEBUG provision. 1. The 'xtra-procps-debug.h' header had an include for 'procps-private.h', which was not an installed header. So the STRINGIFY macros will now be embedded directly. 2. Each of the new api headers referenced '<proc/...>' rather than '<procps/...>' for the debugging #include. So, we must drop that prefix in favor of a quoted file name so that debugging builds work regardless of where that 'xtra-procps-debug.h' header happens to be found. Reference(s): . Jun, 2020 - changed target install directory commit d64755ea5f48295f5b064da0ea667ee3503b4cd8 . Sep, 2018 - #include migrated from procps.h commit fab37662efe92650063a45e6b20eda09afe07e14 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: misc accumulated cosmetic header file changesJim Warner2020-05-281-1/+1
| | | | | | Well gosh, I only accumulated 1 minor cosmetic change. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: correct 'vectorized' string logic, <PIDS> apiJim Warner2019-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit referenced below addressed (some) anomalies surrounding 'strv' pointers. However, there remained a couple quirks involving a potential NULL return value. Any NULL values returned from the old library readproc guys would cause no real harm for newlib. But they did produce the misleading "[ duplicate ENUM_ID ]" result. The following all represent potential NULL results and suggest shortcomings in testing of that earlier patch. . kernel threads do not have cgroup, cmdline & environ . even if present environ could require root to access So, this patch reverts a portion of the earlier commit and ensures when some vectored string is not available a traditional dash ('-') is the 'strv' returned value. [ and we'll also correct one typo in the header file ] Reference(s): . eliminated a final potential NULL, <PIDS> api commit 09503dc59792ab0147de604ab48342b8508f2d7b Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: refactored some header file items and originsJim Warner2019-03-261-104/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is intended as a refinement of the patches mentioned below, where origins/sources of newlib items were added to the header files for user documentation. However, if those additions are to be truly effective, along with kernel documentation (where available), the following prerequisites must also have been satisfied: . our identifiers closely align with linux field names . our derived items are documented or self-documenting Satisfying those prerequisites prompted this patch and for these changes, kernel sources were emphasized over available documentation (shame on me, it should always have been so). And, while some 'new' fields were found to be conditional, they were included unconditionally. These changes appear more extensive than they actually need be since I have attempted to enforce some spacing conventions. So, I've summarize the significant things in the sections that follow. For a proper perspective, use: 'git diff --ignore-space-change' (good as alias). ___________________________________________ <PIDS> api This api is unique in that there exists many different file/directory origins subordinate to /proc/<pid>. And our item identifiers are sometimes coerced so as to be able to group related or similar enumerators together. So, users needed more help relating our identifiers to an actual documented field. Thus, we will now also add the field names as with 'stat: delayacct_blkio_ticks'. Each item ending with a '_C' now consistently includes both the parent's count/time plus waited for children. That 'RTPRIO' guy was renamed/relocated as PRIORITY_RT since its original name is an implementation artifact. ___________________________________________ <STAT> api The only api change was to correct a typo ('dervied'). _________________________________________ <VMSTAT> api Even ignoring white space, this interface received the largest number of changes. Mostly, this was because of deficiencies in the proc(5) documentation. Recall that this documentation already sorely lacks any substance. Usually, just kernel releases are noted, not contents. When compared to kernel source, that proc(5) contained many non-existent fields and also omitted many others. ________________________________________ <MEMINFO> api Sadly, with this api many of the changes were simply a correction of some earlier 'human error' where several fields where hashed then tracked but never represented with an item enumerator in this meminfo.h header file. _______________________________________ <SLABINFO> api The 'SLABS' (summary) & 'SLABNODE' items were reversed since the former are derived from the separate caches. More significantly, those 'SLABNODE' guys were renamed to 'SLAB' since they concern individual caches and the concept of 'nodes' is really an implementation detail. Also, several enumerators were changed to more closely agree with official slabinfo(5) documentation referred to in what we're treating as a base document: proc(5). Lastly, while those 'SLABS' items are solely a product of our library and not represented in slabinfo(5), the names attempt to parallel those found as 'SLAB' items. ______________________________________ <DISKSTATS> api One enumeration identifier was changed so as to better reflect its relationship to that actual documentation: 'Documentation/iostats.txt', as referenced in proc(5). Reference(s): . 12/2018, item origins added (and commit msg history) commit 96d59cbf46b3ff687bd29fad4708074a0e1cea14 . 01/2019, <stat> origins tweaked commit 201e816b26ddaccc923ec40977c92037cdd0c34e Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: add item origin (as comments) to header filesJim Warner2019-01-031-119/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A lack of documentation seems to be the major obstacle to releasing this new library. So, in an effort to get the ball rolling again, this patch adds the origins of each item as a comment to six of the new header files. However, before reviewing how such changes may benefit that documentation objective, it seemed appropriate to first reflect on newlib's background & current status. ___________________________________________ BACKGROUND Discussions about and work on a new library began back in July 2012 but quickly died. After a lull of 2 years those discussions were resumed in August 2014 but soon died also (and no code survived the gitorious demise). With those early discussions, the recommended approach was to encapsulate all of the libprocps data offerings in individual functions. When it came to extensibility it was suggested we should rely on symbols versioning. Unfortunately that approach would have made for a huge Application Programming Interface virtually impossible to master or even document. And, runtime call overhead would have been substantial for ps and especially top. So, an alternative design was sought but there were no new suggestions/contributions via freelists or gitlab. Thus, in spite of a lack of library design experience, the procps-ng team (Craig & Jim) set out to develop an alternative API, more concise and with lower overhead. Reference(s): . 07/01/2012, begin library design discussion https://www.freelists.org/post/procps/Old-library-calls . 08/12/2014, revival of library design discussion https://www.freelists.org/post/procps/libprocs-redesign _____________________________________ DESIGN EVOLUTION Our newlib branch first appeared on June 14, 2015. And our current API actually represents the 4th generation during the past 3 years of evolution. First, there was a basic 'new', 'get' and 'unref' approach, using enums to minimize the proliferation of 'get' function calls. Then, in anticipation of other programs like ps, where multiple fields times multiple processes would greatly increase the number of 'get' function calls, a concept of 'chains' was introduced. This became generation #2. Such 'chains' proved unnecessarily complex so 'stacks' replaced them. This was considered the 3rd generation, but too many implementation details were still exposed requiring those users to 'alloc', 'read', 'fill', etc. Finally, a 4th generation emerged representing several refinements to standardize and minimize those exported functions, thus hiding all implementation details from the users. Lastly, handling of 'errno' was normalized. Reference(s): . 06/14/2015, revival of new API discussion https://www.freelists.org/post/procps/The-library-API-again . 06/24/2015, birth of the newlib branch https://www.freelists.org/post/procps/new-library . 06/29/2015, 2nd generation introduced 'chains' https://www.freelists.org/post/procps/new-library,8 . 07/22/2015, 3rd generation introduced 'stacks' https://www.freelists.org/post/procps/newlib-stacks-vs-chains . 06/18/2016, 4th generation refinements begin https://www.freelists.org/post/procps/newlib-generation-35 . 11/10/2017, 4th generation standardized 'errno' https://www.freelists.org/post/procps/some-more-master-newlib-stuff _______________________________________ CURRENT DESIGN Central to this new design is a simple 'result' struct reflecting an item plus its value (thanks to a union). As a user option, these item structures can be grouped into 'stacks', yielding many results with just 1 call. Such a 'stack' can be seen as a variable length record whose content/order is determined solely by the users. Within that 'result' structure, the union has standard C language types so there is never a doubt how a value should be used in a printf statement. Given that linux requires a least a 32-bit platform the only difference in capacity surrounds 'long' integers. And, where such types might be used, the 32-bit maximums are adequate. The items themselves are simply enumerators defined in the respective header files. A user can name any items of interest then the library magically provides result structure(s). The approach was proven to be extensible without breaking the ABI (in commit referenced below). The 6 major APIs each provide for the following calls: . 'new' ---------> always required as the first call . . 'ref' -------------------------> strictly optional . . 'unref' --------> optional, if ill-behaved program . . 'get' --------------------> retrieve a single item . . 'select' ----------------> retrieve multiple items . And the 'get' and 'select' functions provide for delta results representing the difference between successive get/select calls (or a 'new' then 'get/select' call). For the <diskstats>, <pids>, <slabinfo> & <stat> APIs, where results are unpredictable, a 'reap' function can return multiple result structures for multiple stacks. The <pids> API differs from others in that those items of interest must be provided at 'new' or 'reset' time, a function unique to this API. And the <pids> 'select' function requires PIDs or UIDs which are to be fetched which then operates as a subset of 'reap'. Lastly, the 'get' function is an iterator for successive PIDs/TIDs returning items previously identified via 'new/reset'. To provide assistance to users during development, the special header 'proc/xtra-procps-debug.h' is available to check type usage against library expectations. That check is activated by including this header explicitly or via build using: ./configure '-DXTRA_PROCPS_DEBUG'. Reference(s): . 08/05/2016, type validation introduced https://www.freelists.org/post/procps/newlib-types-validation commit e3270d463de7eebd9f5ae20c85495e3cb5b69a9f . 08/11/2016, extensibility while preserving ABI example https://www.freelists.org/post/procps/new-meminfo-fields commit 09e1886c9e731f8b8c89a55d11f72f53f030b2de _________________________ INITIAL DOCUMENTATION EFFORT The initial attempt, referenced below, dealt primarily with the <pids> interface. Separate man pages for each exported function were created. Plus there was another document describing the items, among other miscellany. Adopting such an approach encounters several problems: 1. In order to use these man pages, users are required to already know how to use the library. Or alternately one could randomly search each of them while trying to ascertain which function call satisfies their need and what exactly was the proper compliment/order required. 2. While we can explain what all of those <pids> items represent, that certainly isn't true for all the APIs. See the gaps in kernel documentation for <meminfo> and complete lack of documentation with that <vmstat> API. 3. Our documentation effort should take pains to avoid unnecessary implementation details. Here's an example: . "The pointer to info will have memory" . "allocated and a structure created." Alternatively, the following conveys user requirements while not offering any internal implementation detail: . "You must provide the address of a NULL" . "info structure pointer." Reference(s): . 01/04/2017, initial documentation offering https://www.freelists.org/post/procps/Using-reap-and-get commit 2598e9f2ce39c93ebf55f664454d3bea919ed4e0 ___________________ RECOMMENDED DOCUMENTATION APPROACH I recommend that the newlib documentation consist of 3 man pages only. The first would cover the 5 major APIs and their common functions. The second would deal with the <pids> API exclusively, explaining how it differs. Any remaining exported libproc functions which are yet to be included could be represented in a 3rd document. For these new documents the following are are assumed: 1. Since we will not be able to document all items, we shouldn't try to document any items. We should instead rely on proc(5) or Documentation/filesystems/proc.txt. 2. Program development often involves referencing some header file(s). So, make that an absolute requirement. 3. With the addition of item origins, represented with this commit, and considering that 'types' were already present, the header file might be all some users need. 4. And who knows, when a user of our libproc complains about gaps in their documentation, it might prompt the kernel folks to correct those long standing omissions. To summarize, I suggest that we replace that libproc.3 document with a more general one explaining the basics of accessing this new library and the common calls for most of the major interfaces. We can then create a new document (libproc-pids.3?), which explains differences in using the <PIDS> application programming interface. A final document (libproc-misc.3?) covers what's left. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: insert 'PIDS_ID_TID' for symmetry, <PIDS> apiJim Warner2019-01-031-0/+1
| | | | | | | This change is being made in anticipation of adding the source origin of each item to the <pids.h> header file. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: refactor the XTRA_PROCPS_DEBUG implementationJim Warner2018-09-121-0/+4
| | | | | | | | | | | | | | | | | If we ever were to eliminate the procps.h header file, as discussed in the thread referenced below, then that would impair the current XTRA_PROCPS_DEBUG provisions. The only remaining way to verify result types would be to explicitly include that <proc/xtra-procps-debug.h>. So, this commit will once again enable the ./configure provision for defining the -DXTRA_PROCPS_DEBUG option. Reference(s): https://www.freelists.org/post/procps/newlib-Qualys-patches,6 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: expanded to provide for the 'executable path'Jim Warner2018-06-261-0/+1
| | | | | | | | | | | | | | This patch is the first of three implementing a newlib branch version of that Jan Rybar master merge request. With this series we'll ultimately extend 'EXE' support to both ps and top (plus, everyone else who wants it). Reference(s): . master branch merge request https://gitlab.com/procps-ng/procps/merge_requests/66 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: replace the troublesome '__BEGIN_DECLS' macroJim Warner2018-05-061-4/+6
| | | | | | | | | | | | | | | | | | | | | | | When 'newlib' was introduced, in the commit referenced below, the use of that glibc '__BEGIN_DECLS' macro was standardized. However, as issue #88 revealed, this may result in a fatal build error with other environments. So, this patch just trades that macro for the standard '#ifdef __cplusplus' conventions (thus avoiding use of all those '#include <features.h>' directives as well). Reference(s): . newlib introduced commit a410e236abb47c7c43194e61d0566686f81513af . procps-ng-3.3.13 issue https://gitlab.com/procps-ng/procps/issues/88 . some additional discussion https://www.freelists.org/post/procps/PATCH-Replace-glibcspecific-macros-in-procnumah,1 . musl wiki (see: sys/cdefs.h error messages) https://wiki.musl-libc.org/faq.html Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: expanded to provide for the UID used at loginJim Warner2018-02-191-0/+1
| | | | | | | | | | | | | This patch represents the newlib implementation of Jan Rybar's merge request referenced below. It essentially moves that code out of the ps program and into our new library where it's available via the <pids> interface. Reference(s): https://gitlab.com/procps-ng/procps/merge_requests/57 https://bugzilla.redhat.com/show_bug.cgi?id=1518986 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: account for idle state ('I') threads in totalJim Warner2018-02-121-1/+1
| | | | | | | | | | | | | With the documentation update in the commit referenced below, we should also account for such threads as they will already be represented in the task/thread totals. [ and do it in a way that might avoid future changes ] Reference(s): commit 91df65b9e778b9d7da7952d766e129f58423b807 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: set stage for NUMA node field display supportJim Warner2017-05-221-0/+1
| | | | | | | | | | | | | | | In response to that suggestion referenced below, these changes allow display of task/thread level NUMA nodes. Currently, only the 'top' program offers any NUMA type support and it is limited to the Summary Area display. With this commit both the 'top' and 'ps' programs will be able to display NUMA nodes associated with threads. Reference(s): https://gitlab.com/procps-ng/procps/issues/58 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library <stat>: remove that PIDS_WCHAN_ADDR enumeratorJim Warner2016-10-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removing the Item_table 'stat' oldflags for WCHAN_ADDR was wrong since that 'stat' field is not a constant 0. Rather, it could assume these 3 values: -1, 0, and +1. I have not been able to pin down a '-1' result, but it probably means some sort of permission error (-EPERM). The '1' or '0' values were supposed to distinguish the tasks that were or were not blocked (whether there was a wchan address). However, in practice there is little correlation between those values and availability of a kernel symbol in /proc/$$/wchan (perhaps due to race). Anyway, the real point is that a 'stat' wchan does not now intentionally contain an address. Thus, outputting 'ffffff', '-' or '1' in programs like ps is senseless. So this patch just eliminates PIDS_WCHAN_ADDR from our item enumerators leaving only the PIDS_WCHAN_NAME guy. Now the new library can't be blamed for bad addresses! Reference(s): . removed Item_table 'oldflags' commit c4aa6c0ab4263976b2abbc5df0068d5a1612d731 . linux removal of wchan addresses commit b2f73922d119686323f14fbbe46587f863852328 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library <pids>: remove fields obsoleted with linux 2.6Jim Warner2016-10-091-3/+0
| | | | | | | | | | | It seems inappropriate to blindly include fields known to always be zero in our brand new library. Therefore, this patch removes support for three such enumerators. [ that stat 'it_real_value' (PIDS_ALARM) field could ] [ have been made obsolete before a linux 2.6 release ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: strictly cosmetic, absolutely no code changesJim Warner2016-10-091-3/+3
| | | | | | | | | | This commit just contains some tweaks to comments plus a few adjustments to whitespace for alignment purposes and a normalization of the header inclusion #define's. [ plus a spelling error in one header file was fixed ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: expand VAL macros to include the context parmJim Warner2016-08-071-1/+1
| | | | | | | | | | | | This patch will set the stage for validating the types referenced in the result union. For now, the parameter representing that 'info' structure will remain unused. [ and while we're at it, let us correct a faulty GET ] [ macro in the diskstats header. that puppy missed a ] [ parm which ain't so good if that guy is ever used! ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: normalize & minimize result types, <PIDS> apiJim Warner2016-08-011-37/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit attempts to minimize the variety of types currently used. Plus, the following were also changed: . the MEM fields were switched to parallel the VM guys . PIDS_MEM_VIRT -> PIDS_MEM_VIRT_PGS . PIDS_MEM_VIRT_KIB -> PIDS_MEM_VIRT . made NICE 's_int' so that it then parallels PRIORITY . change RTPRIO & SCHED_CLASS from 'ul_int' to 's_int' . removed Item_table 'oldflags' for an obsoleted field . PIDS_WCHAN_ADDR . added calculations like TICS_ALL_C for the following . PIDS_TICS_USER_C . PIDS_TICS_SYSTEM_C . these three new 'TICS' fields have been incorporated . PIDS_TICS_BLKIO - jiffies spent in block i/o . PIDS_TICS_GUEST - jiffies spent as a guest . PIDS_TICS_GUEST_C - as above, includes dead children . that PIDS_TICS_DELTA was renamed PIDS_TICS_ALL_DELTA ( so it did not hide between TICS_BLKIO & TICS_GUEST ) ( and to make clearer what's included: utime + stime ) . eliminated 'sl_int' entirely from that result struct [ often, the <pids> module changes necessitated that ] [ readproc header and source files had to change too ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: removed all the 'PROCPS_' enumerator prefixesJim Warner2016-07-261-128/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many of our item enumerator identifiers are very long, especially in that <VMSTAT> module. Additionally, they all contain the exact same universal 'PROCPS_' prefix. The origins for this are likely found in the desire to avoid name clashes with other potential include files. But with procps-ng newlib, we've probably gone way too far. Did 'PROCPS_PIDS_TICS_SYSTEM' actually offer more protection against clash than 'PIDS_TICS_SYSTEM' does? I don't think so. Besides, no matter how big that name becomes, one can never guarantee they'll never be some clash. And, conversely, extremely short names will not always create conflict. Of course, in either case when some clash occurs, one can always #undef that problem. Thus, this commit will eliminate that 'PROCPS_' prefix making all of those enum identifiers a little shorter. And, we'll still be well above some ridiculously short (criminally short) names found in some common headers: - - - - - - - - - - <term.h> - 'tab', 'TTY', etc - - - - - - - - - - - - - - - - <search.h> - 'ENTER', ENTRY', 'FIND', etc ------------------------------------------------------ Finally, with this as a last of the wholesale changes, we will have established the naming conventions below: . only functions will begin with that 'procps_' prefix . exposed structures begin with the module/header name . item enumerators begin like structs, but capitalized . other enumerators work exactly like item enumerators . macros and constants begin just like the enumerators ------------------------------------------------------ Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: standardize all the 'context' structure namesJim Warner2016-07-261-10/+10
| | | | | | | | | | | | | | | | | | | | This patch attempts to standardize the naming of those most important (declared not defined) context structs. The present practice represents a hodge podge of names only some of which reflect the source /proc file name. And 2 of those file names embed a literal 'info' which is likely the origin of that required parm identifier. Now we'll append a universal '_info' to such structure names, while including the names of those /proc pseudo files where possible. In any case, that context struct will *always* begin with the actual module/header file name. And only the following two sound a little weird! ---------> 'meminfo_info' + 'slabinfo_info' <--------- Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: more pids_fetch struct opaqueness, <PIDS> apiJim Warner2016-06-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | With all our 3rd generation interfaces, we're now well positioned to preserve binary compatibility should new fields be added to any public structure (assuming that the 'result' union already contains its largest type). This remains true even for the <pids> interface, which unlike the others, has one structure embedded within a separate struct rather than declaring a pointer to it. The counts struct was positioned after the stacks ptrs array so as to preserve that ABI if ever new ints were added. Logically, however, the counts (especially that total) should precede the stacks array if we wished to properly place a horse (total) before a cart (stacks). So to enable relocating those counts we will no longer embed that structure, but provide a pointer to it. And this will make accessing syntax feel more natural too. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: a couple of miscellaneous changes, <PIDS> apiJim Warner2016-06-211-2/+2
| | | | | | | | | | This patch represents the following minor adjustments: . old PROCTAB used with select & reap more descriptive . reformatted PROCPS_PIDS_VAL macro like other 3rd gen Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: more tweaks for code and/or comments, 3rd genJim Warner2016-06-171-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following is a summary of significant changes (if any) to each of these now upgraded 3rd gen library modules. <meminfo> ............................................ . eliminated duplicate decl of 'struct procps_meminfo' . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . how did i miss relocating all these friggin' #undefs . cleanup 'get' return logic (remove a redundant 'if') <pids> ............................................... . repositioned the procps_pidsinfo structure in header . removed the extra trailing comma from enum pids_item . standardized/normalized results struct union members <slabinfo> ........................................... . corrected comment typo (jeeze, in an 'aligned' para) . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . removed an obsolete #undef from procps_slabinfo_sort . cleanup 'get' return logic (remove a redundant 'if') <stat> ............................................... . how did i miss relocating all these friggin' #undefs . corrected an initialization fencepost used with numa <=== see Craig, here's a bug fix . removed the extra trailing comma from enum stat_item . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . strengthen those parm checks in procps_stat_get func . cleanup 'get' return logic (remove a redundant 'if') <vmstat> ............................................. . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . cleanup 'get' return logic (remove a redundant 'if') [ virtually all of these tweaks reflect the author's ] [ continuing pursuit of an unreasonable goal -- that ] [ of a 'perfect' (plus 'pretty') C language program! ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: final tweaks to code and/or comments, 3rd genJim Warner2016-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the dust now settling on all those 3rd generation upgrades, this patch tries to provide some consistency among the separate modules involved. Someday we should consider a 4th generation where all redundant code has been removed and isolated in a new shared source file. Following is a summary of significant changes (if any) to each of these now upgraded 3rd gen library modules. <meminfo> ............................................ . strictly formatting/comment changes, code unaffected <pids> ............................................... . replaced a local mkSTR macro with existing STRINGIFY . added fetch narrative explaining duplicate addresses <slabinfo> ........................................... . rearranged some free logic for procps_slabinfo_unref . added fetch narrative explaining duplicate addresses <stat> ............................................... . added #define ENFORCE_LOGICAL, just as in <slabinfo> . replaced a local mkSTR macro with existing STRINGIFY . alphabetized the function declarations in the header <vmstat> ............................................. . made one coverity concession with read_vmstat_failed [ several of these changes may reflect this author's ] [ continuing pursuit of an unreasonable goal -- that ] [ of a 'perfect' (plus 'pretty') C language program! ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: misc tweaks for code and comments, <PIDS> apiJim Warner2016-06-091-4/+2
| | | | | | | | | This commit simply tries to keep naming plus formating conventions on a par with the continuing climb up that learning curve. These changes were suggested following <slabinfo> sources upgrade from 2nd to 3rd generation. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: try different alignment for types, <PIDS> apiJim Warner2016-05-161-118/+118
| | | | | | | | | | | | | | | | Rather than adopt an approach offered below, involving changing all enumerator names to convey types, perhaps this much more modest change is a worthwhile 1st step. By just changing the comments to 'right justification' it dramatically improves readability, at least it does to my eye. Perhaps such an approach can postpone that massive alternative effort for the foreseeable future. Reference(s): http://www.freelists.org/post/procps/newlib-drip-drip,4 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: try to minimize the results types, <PIDS> apiJim Warner2016-05-161-24/+24
| | | | | | | | | | | | | | | | | | | | This is just beginning an effort to minimize/normalize the sheer variety of results types in use for our API. In taking these first baby steps, a few anomalies were found. There'll no doubt be many more yet to discover. . the _FLT_ (fault) fields were already signed long in the proc_t (even though their sscanf format used %lu). . although strtoul will alway return an unsigned long, all of the _VM_ fields were made signed long just like other memory fields (& signed sorts more efficiently). Reference(s): http://www.freelists.org/post/procps/newlib-drip-drip,4 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: standardize portions of interface, <PIDS> apiJim Warner2016-05-161-32/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This represents a rather major interface redesign. The following highlights most of the changes/enhancements. . The 'read' interface (employed by pgrep & pidof) saw the biggest change. The 'open', 'next' and 'shut' guys all went bye-bye, replaced by a single 'get' function. . The items specified at 'new' time no longer serve as the maximum. In fact, items & numitems are now treated as optional, should callers prefer to wait until later when the 'reset' function would then become mandatory. . Even at 'reset' time, the stacks are not tied to any sort of maximum. They will grow dynamically as needed. . The order of some parameters was changed to parallel that found in our other APIs. Specifically, when items & numitems are needed they're specified in that order. . A user will no longer be prevented from concurrently employing any accessor functions. In other words, that 'get' (old 'read') won't preclude 'reap' and 'select'. . A duplicate enumerator was found dealing with locked resident pages. So, the name VM_LOCK was eliminated in favor of VM_RSS_LOCKED, which is way more descriptive. . The struct address returned to callers following any reap() or select() is now more sharable as pids_fetch. . Some input parameter names were changed to make them more descriptive of the intended purpose/requirements. ------------------------------------------------------ Internally, there were numerous implementation changes made that did not directly impact any potential users. . That #define FPRINT_STACKS was eliminated along with the associated supporting function and its invocation. . Addresses returned following 'reap' or 'select' will now be NULL delimited, so one has the option of stacks access via the total count or this new NULL fencepost. . Input params were simplified and generalized in both oldproc_open() & close() to enable more than 1 PROCTAB to be open simultaneously, which was required for get. . The PROCPS_PIDS_logical_end enum was relocated after the Item_table making the need to keep it synchronized more apparent (if the table expands it's right there). . The 'Public function' section of the source file was subdivided into 1) the three basic required functions; and 2) functions that can sometimes vary between APIs. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: changed use of 'fill' to 'select', <pids> APIJim Warner2016-04-191-4/+4
| | | | | | | Remove a remnant of this new API's evolution. Here we no longer fill stacks, rather we reap and select them. Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: protect against a future breakage, <pids> ABIJim Warner2016-04-191-2/+2
| | | | | | | | | | | | | | | | | | | | By co-mingling both external/internal identifiers with actual implementation code, potential future additions to our API would have been considerably more difficult. So, this patch will now rely solely on internal/hidden identifiers serving as fenceposts in validation logic. And if the following convention is used for new fields we will maintain that enumerator alphabetic ordering a a little longer (even though 2 user fields now don't): . PROCPS_PIDS_XTRA_FOO_A, PROCPS_PIDS_XTRA_FOO_B, etc. Reference(s): http://www.freelists.org/post/procps/me-too-newlib,7 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: cleanup of library includesCraig Small2016-04-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The includes used to define a lot of things a library include should not. It was also a bit messy what was exposed in the library and what was not. get_pid_digits -> procps_pid_length and exported correctly MALLOC attribute move into relevant .c files NORETURN attribute moved to relevant .c, not used in library PURE attribute removed, it wasn't used KLONG/KLF/STRTOUKL were fixed for long, so now just use long HIDDEN attribute removed. It was for 3 functions. The PROCPS_EXPORT seems to do the same (opposite) thing. likely/unlikely removed from most places, its highly debateable this does anything useful as CPUs have gotten smarter about branches. Re-arranged the includes, ALL external programs should just #include <proc/procps.h> then proc/procps.h includes headers for files that have exported functions. procps.h and the headers it includes should not use items that are not exportable (e.g. hidden functions or macros) they go in procps-private.h
* library: exploit linux-4.5 resident memory enhancementJim Warner2016-04-141-0/+4
| | | | | | | | | | | | | | | | | | Beginning with linux-4.5, the following new fields are being added under that /proc/<pid>/status pseudo file: . RssAnon - size of resident anonymous memory . RssFile - size of resident file mappings . RssShmem - size of resident shared memory This patch just represents the initial library and top support, sharing a commit message with 2 more patches. p.s. locked resident memory support was also added but isn't directly related to the kernel 4.5 enhancements. Reference(s): commit 1f8e41d01966ef337bc252bffb181d0acc0c8751 Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: added PROCPS_PIDS_CGNAME for <pids> interfaceJim Warner2015-10-141-0/+1
| | | | | | | | | | | | | | | | The ps program was modified to print the control group names, based on the library provided list of all those control groups to which a process belongs. But this is probably something the newlib should be doing for all. So this commit borrows the ps approach to cg names and thus will make that available to all future consumers. [ but stay tuned! there is a commit coming soon that ] [ represents a rather major internal redesign, which ] [ was prompted by the ps and top adaptation testing. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* library: rename the 'procps_pids_stacks_sort' functionJim Warner2015-10-141-1/+1
| | | | | | | | | | The above function was the sole public function in the <pids> interface to use the word 'stacks' in its name. All of the others dealt exclusively with their duties, So this commit normalizes that outlier by renaming it. Signed-off-by: Jim Warner <james.warner@comcast.net>