procps/proc/slabinfo.h
Jim Warner 6671a3a8b7 library: refactored some header file items and origins
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 96d59cbf46
. 01/2019, <stat> origins tweaked
commit 201e816b26

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-03-26 19:55:30 +11:00

142 lines
4.8 KiB
C

/*
* libprocps - Library to read proc filesystem
*
* Copyright (C) 1998-2005 Albert Cahalan
* Copyright (C) 2015 Craig Small <csmall@enc.com.au>
* Copyright (C) 2016 Jim Warnerl <james.warner@comcast.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PROCPS_SLABINFO_H
#define PROCPS_SLABINFO_H
#ifdef __cplusplus
extern "C "{
#endif
enum slabinfo_item {
SLABINFO_noop, // ( never altered )
SLABINFO_extra, // ( reset to zero )
// returns origin, see proc(5)
// ------- -------------------
SLAB_NAME, // str /proc/slabinfo
SLAB_NUM_OBJS, // u_int "
SLAB_ACTIVE_OBJS, // u_int "
SLAB_OBJ_SIZE, // u_int "
SLAB_OBJ_PER_SLAB, // u_int "
SLAB_NUMS_SLABS, // u_int "
SLAB_ACTIVE_SLABS, // u_int "
SLAB_PAGES_PER_SLAB, // u_int "
SLAB_PERCENT_USED, // u_int derived from ACTIVE_OBJS / NUM_OBJS
SLAB_SIZE_TOTAL, // ul_int derived from page size * NUM_OBJS * PAGES_PER_SLAB
SLABS_CACHES_TOTAL, // u_int derived from all caches
SLABS_CACHES_ACTIVE, // u_int "
SLABS_NUM_OBJS, // u_int "
SLABS_ACTIVE_OBJS, // u_int "
SLABS_OBJ_SIZE_AVG, // u_int "
SLABS_OBJ_SIZE_MIN, // u_int "
SLABS_OBJ_SIZE_MAX, // u_int "
SLABS_NUMS_SLABS, // u_int "
SLABS_ACTIVE_SLABS, // u_int "
SLABS_PAGES_TOTAL, // u_int "
SLABS_SIZE_ACTIVE, // ul_int "
SLABS_SIZE_TOTAL, // ul_int "
SLABS_DELTA_CACHES_TOTAL, // s_int derived from above
SLABS_DELTA_CACHES_ACTIVE, // s_int "
SLABS_DELTA_NUM_OBJS, // s_int "
SLABS_DELTA_ACTIVE_OBJS, // s_int "
SLABS_DELTA_OBJ_SIZE_AVG, // s_int "
SLABS_DELTA_OBJ_SIZE_MIN, // s_int "
SLABS_DELTA_OBJ_SIZE_MAX, // s_int "
SLABS_DELTA_NUMS_SLABS, // s_int "
SLABS_DELTA_ACTIVE_SLABS, // s_int "
SLABS_DELTA_PAGES_TOTAL, // s_int "
SLABS_DELTA_SIZE_ACTIVE, // s_int "
SLABS_DELTA_SIZE_TOTAL // s_int "
};
enum slabinfo_sort_order {
SLABINFO_SORT_ASCEND = +1,
SLABINFO_SORT_DESCEND = -1
};
struct slabinfo_result {
enum slabinfo_item item;
union {
signed int s_int;
unsigned int u_int;
unsigned long ul_int;
char *str;
} result;
};
struct slabinfo_stack {
struct slabinfo_result *head;
};
struct slabinfo_reap {
int total;
struct slabinfo_stack **stacks;
};
#define SLABINFO_GET( info, actual_enum, type ) ( { \
struct slabinfo_result *r = procps_slabinfo_get( info, actual_enum ); \
r ? r->result . type : 0; } )
#define SLABINFO_VAL( relative_enum, type, stack, info ) \
stack -> head [ relative_enum ] . result . type
struct slabinfo_info;
int procps_slabinfo_new (struct slabinfo_info **info);
int procps_slabinfo_ref (struct slabinfo_info *info);
int procps_slabinfo_unref (struct slabinfo_info **info);
struct slabinfo_result *procps_slabinfo_get (
struct slabinfo_info *info,
enum slabinfo_item item);
struct slabinfo_reap *procps_slabinfo_reap (
struct slabinfo_info *info,
enum slabinfo_item *items,
int numitems);
struct slabinfo_stack *procps_slabinfo_select (
struct slabinfo_info *info,
enum slabinfo_item *items,
int numitems);
struct slabinfo_stack **procps_slabinfo_sort (
struct slabinfo_info *info,
struct slabinfo_stack *stacks[],
int numstacked,
enum slabinfo_item sortitem,
enum slabinfo_sort_order order);
#ifdef XTRA_PROCPS_DEBUG
# include <proc/xtra-procps-debug.h>
#endif
#ifdef __cplusplus
}
#endif
#endif