library: normalize & minimize result types, <PIDS> api

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>
This commit is contained in:
Jim Warner 2016-07-31 00:00:00 -05:00 committed by Craig Small
parent 01beb85f7d
commit c4aa6c0ab4
4 changed files with 179 additions and 176 deletions

View File

@ -141,7 +141,7 @@ REG_set(ADDR_KSTK_EIP, ul_int, kstk_eip)
REG_set(ADDR_KSTK_ESP, ul_int, kstk_esp)
REG_set(ADDR_START_CODE, ul_int, start_code)
REG_set(ADDR_START_STACK, ul_int, start_stack)
REG_set(ALARM, sl_int, alarm)
REG_set(ALARM, ul_int, alarm)
STR_set(CGNAME, cgname)
STR_set(CGROUP, cgroup)
VEC_set(CGROUP_V, cgroup_v)
@ -152,12 +152,12 @@ STR_set(ENVIRON, environ)
VEC_set(ENVIRON_V, environ_v)
REG_set(EXIT_SIGNAL, s_int, exit_signal)
REG_set(FLAGS, ul_int, flags)
REG_set(FLT_MAJ, sl_int, maj_flt)
REG_set(FLT_MAJ_C, sl_int, cmaj_flt)
REG_set(FLT_MAJ_DELTA, sl_int, maj_delta)
REG_set(FLT_MIN, sl_int, min_flt)
REG_set(FLT_MIN_C, sl_int, cmin_flt)
REG_set(FLT_MIN_DELTA, sl_int, min_delta)
REG_set(FLT_MAJ, ul_int, maj_flt)
REG_set(FLT_MAJ_C, ul_int, cmaj_flt)
REG_set(FLT_MAJ_DELTA, s_int, maj_delta)
REG_set(FLT_MIN, ul_int, min_flt)
REG_set(FLT_MIN_C, ul_int, cmin_flt)
REG_set(FLT_MIN_DELTA, s_int, min_delta)
REG_set(ID_EGID, u_int, egid)
REG_set(ID_EGROUP, str, egroup)
REG_set(ID_EUID, u_int, euid)
@ -181,19 +181,19 @@ REG_set(ID_SUSER, str, suser)
REG_set(ID_TGID, s_int, tgid)
REG_set(ID_TPGID, s_int, tpgid)
REG_set(LXCNAME, str, lxcname)
REG_set(MEM_CODE, sl_int, trs)
CVT_set(MEM_CODE_KIB, sl_int, trs)
REG_set(MEM_DATA, sl_int, drs)
CVT_set(MEM_DATA_KIB, sl_int, drs)
REG_set(MEM_DT, sl_int, dt)
REG_set(MEM_LRS, sl_int, lrs)
REG_set(MEM_RES, sl_int, resident)
CVT_set(MEM_RES_KIB, sl_int, resident)
REG_set(MEM_SHR, sl_int, share)
CVT_set(MEM_SHR_KIB, ul_int, share)
REG_set(MEM_VIRT, sl_int, size)
CVT_set(MEM_VIRT_KIB, sl_int, size)
REG_set(NICE, sl_int, nice)
CVT_set(MEM_CODE, ul_int, trs)
REG_set(MEM_CODE_PGS, ul_int, trs)
CVT_set(MEM_DATA, ul_int, drs)
REG_set(MEM_DATA_PGS, ul_int, drs)
REG_set(MEM_DT_PGS, ul_int, dt)
REG_set(MEM_LRS_PGS, ul_int, lrs)
CVT_set(MEM_RES, ul_int, resident)
REG_set(MEM_RES_PGS, ul_int, resident)
CVT_set(MEM_SHR, ul_int, share)
REG_set(MEM_SHR_PGS, ul_int, share)
CVT_set(MEM_VIRT, ul_int, size)
REG_set(MEM_VIRT_PGS, ul_int, size)
REG_set(NICE, s_int, nice)
REG_set(NLWP, s_int, nlwp)
REG_set(NS_IPC, ul_int, ns.ns[0])
REG_set(NS_MNT, ul_int, ns.ns[1])
@ -205,10 +205,10 @@ REG_set(OOM_ADJ, s_int, oom_adj)
REG_set(OOM_SCORE, s_int, oom_score)
REG_set(PRIORITY, s_int, priority)
REG_set(PROCESSOR, u_int, processor)
REG_set(RSS, sl_int, rss)
REG_set(RSS, ul_int, rss)
REG_set(RSS_RLIM, ul_int, rss_rlim)
REG_set(RTPRIO, ul_int, rtprio)
REG_set(SCHED_CLASS, ul_int, sched)
REG_set(RTPRIO, s_int, rtprio)
REG_set(SCHED_CLASS, s_int, sched)
STR_set(SD_MACH, sd_mach)
STR_set(SD_OUID, sd_ouid)
STR_set(SD_SEAT, sd_seat)
@ -226,29 +226,32 @@ STR_set(SUPGIDS, supgid)
STR_set(SUPGROUPS, supgrp)
setDECL(TICS_ALL) { (void)I; R->result.ull_int = P->utime + P->stime; }
setDECL(TICS_ALL_C) { (void)I; R->result.ull_int = P->utime + P->stime + P->cutime + P->cstime; }
REG_set(TICS_DELTA, sl_int, pcpu)
REG_set(TICS_ALL_DELTA, s_int, pcpu)
REG_set(TICS_BLKIO, ull_int, blkio_tics)
REG_set(TICS_GUEST, ull_int, gtime)
setDECL(TICS_GUEST_C) { (void)I; R->result.ull_int = P->gtime + P->cgtime; }
REG_set(TICS_SYSTEM, ull_int, stime)
REG_set(TICS_SYSTEM_C, ull_int, cstime)
setDECL(TICS_SYSTEM_C) { (void)I; R->result.ull_int = P->stime + P->cstime; }
REG_set(TICS_USER, ull_int, utime)
REG_set(TICS_USER_C, ull_int, cutime)
setDECL(TICS_USER_C) { (void)I; R->result.ull_int = P->utime + P->cutime; }
setDECL(TIME_ALL) { R->result.ull_int = (P->utime + P->stime) / I->hertz; }
setDECL(TIME_ELAPSED) { R->result.ull_int = (I->boot_seconds >= (P->start_time / I->hertz)) ? I->boot_seconds - (P->start_time / I->hertz) : 0; }
setDECL(TIME_ELAPSED) { unsigned long long t = P->start_time / I->hertz; R->result.ull_int = I->boot_seconds >= t ? (I->boot_seconds - t) : 0; }
REG_set(TIME_START, ull_int, start_time)
REG_set(TTY, s_int, tty)
setDECL(TTY_NAME) { char buf[64]; (void)I; dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV); R->result.str = strdup(buf); }
setDECL(TTY_NUMBER) { char buf[64]; (void)I; dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV|ABBREV_TTY|ABBREV_PTS); R->result.str = strdup(buf); }
REG_set(VM_DATA, sl_int, vm_data)
REG_set(VM_EXE, sl_int, vm_exe)
REG_set(VM_LIB, sl_int, vm_lib)
REG_set(VM_RSS, sl_int, vm_rss)
REG_set(VM_RSS_ANON, sl_int, vm_rss_anon)
REG_set(VM_RSS_FILE, sl_int, vm_rss_file)
REG_set(VM_RSS_LOCKED, sl_int, vm_lock)
REG_set(VM_RSS_SHARED, sl_int, vm_rss_shared)
REG_set(VM_SIZE, sl_int, vm_size)
REG_set(VM_STACK, sl_int, vm_stack)
REG_set(VM_SWAP, sl_int, vm_swap)
setDECL(VM_USED) { (void)I; R->result.sl_int = P->vm_swap + P->vm_rss; }
REG_set(VM_DATA, ul_int, vm_data)
REG_set(VM_EXE, ul_int, vm_exe)
REG_set(VM_LIB, ul_int, vm_lib)
REG_set(VM_RSS, ul_int, vm_rss)
REG_set(VM_RSS_ANON, ul_int, vm_rss_anon)
REG_set(VM_RSS_FILE, ul_int, vm_rss_file)
REG_set(VM_RSS_LOCKED, ul_int, vm_lock)
REG_set(VM_RSS_SHARED, ul_int, vm_rss_shared)
REG_set(VM_SIZE, ul_int, vm_size)
REG_set(VM_STACK, ul_int, vm_stack)
REG_set(VM_SWAP, ul_int, vm_swap)
setDECL(VM_USED) { (void)I; R->result.ul_int = P->vm_swap + P->vm_rss; }
REG_set(VSIZE_PGS, ul_int, vsize)
REG_set(WCHAN_ADDR, ul_int, wchan)
setDECL(WCHAN_NAME) { (void)I; R->result.str = strdup(lookup_wchan(P->tid)); }
@ -299,7 +302,6 @@ struct sort_parms {
NUM_srt(s_ch)
NUM_srt(s_int)
NUM_srt(sl_int)
REG_srt(u_int)
REG_srt(ul_int)
@ -389,7 +391,7 @@ static struct {
{ RS(ADDR_KSTK_ESP), f_stat, NULL, QS(ul_int), 0 },
{ RS(ADDR_START_CODE), f_stat, NULL, QS(ul_int), 0 },
{ RS(ADDR_START_STACK), f_stat, NULL, QS(ul_int), 0 },
{ RS(ALARM), f_stat, NULL, QS(sl_int), 0 },
{ RS(ALARM), f_stat, NULL, QS(ul_int), 0 },
{ RS(CGNAME), x_cgroup, FF(str), QS(str), 0 },
{ RS(CGROUP), x_cgroup, FF(str), QS(str), 0 },
{ RS(CGROUP_V), v_cgroup, FF(strv), QS(strv), 0 },
@ -400,12 +402,12 @@ static struct {
{ RS(ENVIRON_V), v_env, FF(strv), QS(strv), 0 },
{ RS(EXIT_SIGNAL), f_stat, NULL, QS(s_int), 0 },
{ RS(FLAGS), f_stat, NULL, QS(ul_int), 0 },
{ RS(FLT_MAJ), f_stat, NULL, QS(sl_int), 0 },
{ RS(FLT_MAJ_C), f_stat, NULL, QS(sl_int), 0 },
{ RS(FLT_MAJ_DELTA), f_stat, NULL, QS(sl_int), +1 },
{ RS(FLT_MIN), f_stat, NULL, QS(sl_int), 0 },
{ RS(FLT_MIN_C), f_stat, NULL, QS(sl_int), 0 },
{ RS(FLT_MIN_DELTA), f_stat, NULL, QS(sl_int), +1 },
{ RS(FLT_MAJ), f_stat, NULL, QS(ul_int), 0 },
{ RS(FLT_MAJ_C), f_stat, NULL, QS(ul_int), 0 },
{ RS(FLT_MAJ_DELTA), f_stat, NULL, QS(s_int), +1 },
{ RS(FLT_MIN), f_stat, NULL, QS(ul_int), 0 },
{ RS(FLT_MIN_C), f_stat, NULL, QS(ul_int), 0 },
{ RS(FLT_MIN_DELTA), f_stat, NULL, QS(s_int), +1 },
{ RS(ID_EGID), 0, NULL, QS(u_int), 0 }, // oldflags: free w/ simple_read
{ RS(ID_EGROUP), f_grp, NULL, QS(str), 0 },
{ RS(ID_EUID), 0, NULL, QS(u_int), 0 }, // oldflags: free w/ simple_read
@ -429,19 +431,19 @@ static struct {
{ RS(ID_TGID), 0, NULL, QS(s_int), 0 }, // oldflags: free w/ simple_nextpid
{ RS(ID_TPGID), f_stat, NULL, QS(s_int), 0 },
{ RS(LXCNAME), f_lxc, NULL, QS(str), 0 }, // freefunc NULL w/ cached string
{ RS(MEM_CODE), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_CODE_KIB), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_DATA), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_DATA_KIB), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_DT), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_LRS), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_RES), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_RES_KIB), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_SHR), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_SHR_KIB), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_VIRT), f_statm, NULL, QS(sl_int), 0 },
{ RS(MEM_VIRT_KIB), f_statm, NULL, QS(sl_int), 0 },
{ RS(NICE), f_stat, NULL, QS(sl_int), 0 },
{ RS(MEM_CODE), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_CODE_PGS), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_DATA), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_DATA_PGS), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_DT_PGS), f_statm, NULL, QS(ul_int), 0 }, // ( always 0 w/ since 2.6 )
{ RS(MEM_LRS_PGS), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_RES), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_RES_PGS), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_SHR), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_SHR_PGS), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_VIRT), f_statm, NULL, QS(ul_int), 0 },
{ RS(MEM_VIRT_PGS), f_statm, NULL, QS(ul_int), 0 },
{ RS(NICE), f_stat, NULL, QS(s_int), 0 },
{ RS(NLWP), f_either, NULL, QS(s_int), 0 },
{ RS(NS_IPC), f_ns, NULL, QS(ul_int), 0 },
{ RS(NS_MNT), f_ns, NULL, QS(ul_int), 0 },
@ -453,10 +455,10 @@ static struct {
{ RS(OOM_SCORE), f_oom, NULL, QS(s_int), 0 },
{ RS(PRIORITY), f_stat, NULL, QS(s_int), 0 },
{ RS(PROCESSOR), f_stat, NULL, QS(u_int), 0 },
{ RS(RSS), f_stat, NULL, QS(sl_int), 0 },
{ RS(RSS), f_stat, NULL, QS(ul_int), 0 },
{ RS(RSS_RLIM), f_stat, NULL, QS(ul_int), 0 },
{ RS(RTPRIO), f_stat, NULL, QS(ul_int), 0 },
{ RS(SCHED_CLASS), f_stat, NULL, QS(ul_int), 0 },
{ RS(RTPRIO), f_stat, NULL, QS(s_int), 0 },
{ RS(SCHED_CLASS), f_stat, NULL, QS(s_int), 0 },
{ RS(SD_MACH), f_systemd, FF(str), QS(str), 0 },
{ RS(SD_OUID), f_systemd, FF(str), QS(str), 0 },
{ RS(SD_SEAT), f_systemd, FF(str), QS(str), 0 },
@ -474,7 +476,10 @@ static struct {
{ RS(SUPGROUPS), x_supgrp, FF(str), QS(str), 0 },
{ RS(TICS_ALL), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_ALL_C), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_DELTA), f_stat, NULL, QS(sl_int), +1 },
{ RS(TICS_ALL_DELTA), f_stat, NULL, QS(s_int), +1 },
{ RS(TICS_BLKIO), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_GUEST), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_GUEST_C), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_SYSTEM), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_SYSTEM_C), f_stat, NULL, QS(ull_int), 0 },
{ RS(TICS_USER), f_stat, NULL, QS(ull_int), 0 },
@ -485,20 +490,20 @@ static struct {
{ RS(TTY), f_stat, NULL, QS(s_int), 0 },
{ RS(TTY_NAME), f_stat, FF(str), QS(strvers), 0 },
{ RS(TTY_NUMBER), f_stat, FF(str), QS(strvers), 0 },
{ RS(VM_DATA), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_EXE), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_LIB), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_RSS), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_RSS_ANON), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_RSS_FILE), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_RSS_LOCKED), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_RSS_SHARED), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_SIZE), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_STACK), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_SWAP), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_USED), f_status, NULL, QS(sl_int), 0 },
{ RS(VM_DATA), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_EXE), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_LIB), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_RSS), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_RSS_ANON), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_RSS_FILE), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_RSS_LOCKED), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_RSS_SHARED), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_SIZE), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_STACK), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_SWAP), f_status, NULL, QS(ul_int), 0 },
{ RS(VM_USED), f_status, NULL, QS(ul_int), 0 },
{ RS(VSIZE_PGS), f_stat, NULL, QS(ul_int), 0 },
{ RS(WCHAN_ADDR), f_stat, NULL, QS(ul_int), 0 },
{ RS(WCHAN_ADDR), 0, NULL, QS(ul_int), 0 }, // oldflags: was f_stat, but linux obsoleted
{ RS(WCHAN_NAME), 0, FF(str), QS(str), 0 }, // oldflags: tid already free
// dummy entry corresponding to PIDS_logical_end ...
@ -549,7 +554,7 @@ typedef unsigned long long TIC_t;
typedef struct HST_t {
TIC_t tics; // last frame's tics count
long maj, min; // last frame's maj/min_flt counts
unsigned long maj, min; // last frame's maj/min_flt counts
int pid; // record 'key'
int lnk; // next on hash chain
} HST_t;
@ -626,15 +631,14 @@ static int make_hist (
return -ENOMEM;
}
Hr(PHist_new[nSLOT].pid) = p->tid;
Hr(PHist_new[nSLOT].tics) = tics = (p->utime + p->stime);
Hr(PHist_new[nSLOT].maj) = p->maj_flt;
Hr(PHist_new[nSLOT].min) = p->min_flt;
Hr(PHist_new[nSLOT].tics) = tics = (p->utime + p->stime);
histput(info, nSLOT);
if ((h = histget(info, p->tid))) {
tics -= h->tics;
p->pcpu = tics;
p->pcpu = tics - h->tics;
p->maj_delta = p->maj_flt - h->maj;
p->min_delta = p->min_flt - h->min;
}
@ -939,7 +943,6 @@ static inline int oldproc_open (
unsigned flags,
...)
{
va_list vl;
int *ids;
int num = 0;

View File

@ -35,7 +35,7 @@ enum pids_item {
PIDS_ADDR_KSTK_ESP, // ul_int
PIDS_ADDR_START_CODE, // ul_int
PIDS_ADDR_START_STACK, // ul_int
PIDS_ALARM, // sl_int
PIDS_ALARM, // ul_int
PIDS_CGNAME, // str
PIDS_CGROUP, // str
PIDS_CGROUP_V, // strv
@ -46,12 +46,12 @@ enum pids_item {
PIDS_ENVIRON_V, // strv
PIDS_EXIT_SIGNAL, // s_int
PIDS_FLAGS, // ul_int
PIDS_FLT_MAJ, // sl_int
PIDS_FLT_MAJ_C, // sl_int
PIDS_FLT_MAJ_DELTA, // sl_int
PIDS_FLT_MIN, // sl_int
PIDS_FLT_MIN_C, // sl_int
PIDS_FLT_MIN_DELTA, // sl_int
PIDS_FLT_MAJ, // ul_int
PIDS_FLT_MAJ_C, // ul_int
PIDS_FLT_MAJ_DELTA, // s_int
PIDS_FLT_MIN, // ul_int
PIDS_FLT_MIN_C, // ul_int
PIDS_FLT_MIN_DELTA, // s_int
PIDS_ID_EGID, // u_int
PIDS_ID_EGROUP, // str
PIDS_ID_EUID, // u_int
@ -75,19 +75,19 @@ enum pids_item {
PIDS_ID_TGID, // s_int
PIDS_ID_TPGID, // s_int
PIDS_LXCNAME, // str
PIDS_MEM_CODE, // sl_int
PIDS_MEM_CODE_KIB, // sl_int
PIDS_MEM_DATA, // sl_int
PIDS_MEM_DATA_KIB, // sl_int
PIDS_MEM_DT, // sl_int
PIDS_MEM_LRS, // sl_int
PIDS_MEM_RES, // sl_int
PIDS_MEM_RES_KIB, // sl_int
PIDS_MEM_SHR, // sl_int
PIDS_MEM_SHR_KIB, // sl_int
PIDS_MEM_VIRT, // sl_int
PIDS_MEM_VIRT_KIB, // sl_int
PIDS_NICE, // sl_int
PIDS_MEM_CODE, // ul_int
PIDS_MEM_CODE_PGS, // ul_int
PIDS_MEM_DATA, // ul_int
PIDS_MEM_DATA_PGS, // ul_int
PIDS_MEM_DT_PGS, // ul_int
PIDS_MEM_LRS_PGS, // ul_int
PIDS_MEM_RES, // ul_int
PIDS_MEM_RES_PGS, // ul_int
PIDS_MEM_SHR, // ul_int
PIDS_MEM_SHR_PGS, // ul_int
PIDS_MEM_VIRT, // ul_int
PIDS_MEM_VIRT_PGS, // ul_int
PIDS_NICE, // s_int
PIDS_NLWP, // s_int
PIDS_NS_IPC, // ul_int
PIDS_NS_MNT, // ul_int
@ -99,10 +99,10 @@ enum pids_item {
PIDS_OOM_SCORE, // s_int
PIDS_PRIORITY, // s_int
PIDS_PROCESSOR, // u_int
PIDS_RSS, // sl_int
PIDS_RSS, // ul_int
PIDS_RSS_RLIM, // ul_int
PIDS_RTPRIO, // ul_int
PIDS_SCHED_CLASS, // ul_int
PIDS_RTPRIO, // s_int
PIDS_SCHED_CLASS, // s_int
PIDS_SD_MACH, // str
PIDS_SD_OUID, // str
PIDS_SD_SEAT, // str
@ -120,7 +120,10 @@ enum pids_item {
PIDS_SUPGROUPS, // str
PIDS_TICS_ALL, // ull_int
PIDS_TICS_ALL_C, // ull_int
PIDS_TICS_DELTA, // sl_int
PIDS_TICS_ALL_DELTA, // s_int
PIDS_TICS_BLKIO, // ull_int
PIDS_TICS_GUEST, // ull_int
PIDS_TICS_GUEST_C, // ull_int
PIDS_TICS_SYSTEM, // ull_int
PIDS_TICS_SYSTEM_C, // ull_int
PIDS_TICS_USER, // ull_int
@ -131,18 +134,18 @@ enum pids_item {
PIDS_TTY, // s_int
PIDS_TTY_NAME, // str
PIDS_TTY_NUMBER, // str
PIDS_VM_DATA, // sl_int
PIDS_VM_EXE, // sl_int
PIDS_VM_LIB, // sl_int
PIDS_VM_RSS, // sl_int
PIDS_VM_RSS_ANON, // sl_int
PIDS_VM_RSS_FILE, // sl_int
PIDS_VM_RSS_LOCKED, // sl_int
PIDS_VM_RSS_SHARED, // sl_int
PIDS_VM_SIZE, // sl_int
PIDS_VM_STACK, // sl_int
PIDS_VM_SWAP, // sl_int
PIDS_VM_USED, // sl_int
PIDS_VM_DATA, // ul_int
PIDS_VM_EXE, // ul_int
PIDS_VM_LIB, // ul_int
PIDS_VM_RSS, // ul_int
PIDS_VM_RSS_ANON, // ul_int
PIDS_VM_RSS_FILE, // ul_int
PIDS_VM_RSS_LOCKED, // ul_int
PIDS_VM_RSS_SHARED, // ul_int
PIDS_VM_SIZE, // ul_int
PIDS_VM_STACK, // ul_int
PIDS_VM_SWAP, // ul_int
PIDS_VM_USED, // ul_int
PIDS_VSIZE_PGS, // ul_int
PIDS_WCHAN_ADDR, // ul_int
PIDS_WCHAN_NAME // str
@ -170,7 +173,6 @@ struct pids_result {
signed char s_ch;
signed int s_int;
unsigned int u_int;
signed long sl_int;
unsigned long ul_int;
unsigned long long ull_int;
char *str;

View File

@ -350,37 +350,37 @@ ENTER(0x220);
P->fgid = strtol(S,&S,10);
continue;
case_VmData:
P->vm_data = strtol(S,&S,10);
P->vm_data = (unsigned long)strtol(S,&S,10);
continue;
case_VmExe:
P->vm_exe = strtol(S,&S,10);
P->vm_exe = (unsigned long)strtol(S,&S,10);
continue;
case_VmLck:
P->vm_lock = strtol(S,&S,10);
P->vm_lock = (unsigned long)strtol(S,&S,10);
continue;
case_VmLib:
P->vm_lib = strtol(S,&S,10);
P->vm_lib = (unsigned long)strtol(S,&S,10);
continue;
case_VmRSS:
P->vm_rss = strtol(S,&S,10);
P->vm_rss = (unsigned long)strtol(S,&S,10);
continue;
case_RssAnon: // subset of VmRSS, linux-4.5
P->vm_rss_anon = strtol(S,&S,10);
P->vm_rss_anon = (unsigned long)strtol(S,&S,10);
continue;
case_RssFile: // subset of VmRSS, linux-4.5
P->vm_rss_file = strtol(S,&S,10);
P->vm_rss_file = (unsigned long)strtol(S,&S,10);
continue;
case_RssShmem: // subset of VmRSS, linux-4.5
P->vm_rss_shared = strtol(S,&S,10);
P->vm_rss_shared = (unsigned long)strtol(S,&S,10);
continue;
case_VmSize:
P->vm_size = strtol(S,&S,10);
P->vm_size = (unsigned long)strtol(S,&S,10);
continue;
case_VmStk:
P->vm_stack = strtol(S,&S,10);
P->vm_stack = (unsigned long)strtol(S,&S,10);
continue;
case_VmSwap: // Linux 2.6.34
P->vm_swap = strtol(S,&S,10);
P->vm_swap = (unsigned long)strtol(S,&S,10);
continue;
case_Groups:
{ char *nl = strchr(S, '\n');
@ -551,21 +551,22 @@ ENTER(0x160);
S = tmp + 2; // skip ") "
num = sscanf(S,
"%c "
"%d %d %d %d %d "
"%lu %ld %ld %ld %ld "
"%llu %llu %llu %llu " /* utime stime cutime cstime */
"%ld %ld "
"%d "
"%ld "
"%llu " /* start_time */
"%lu "
"%ld "
"%lu %lu %lu %lu %lu %lu "
"%*s %*s %*s %*s " /* discard, no RT signals & Linux 2.1 used hex */
"%lu %*u %*u "
"%d %d "
"%lu %lu",
"%c " // state
"%d %d %d %d %d " // ppid, pgrp, sid, tty_nr, tty_pgrp
"%lu %lu %lu %lu %lu " // flags, min_flt, cmin_flt, maj_flt, cmaj_flt
"%llu %llu %llu %llu " // utime, stime, cutime, cstime
"%d %d " // priority, nice
"%d " // num_threads
"%lu " // 'alarm' == it_real_value (obsolete, always 0)
"%llu " // start_time
"%lu " // vsize
"%lu " // rss
"%lu %lu %lu %lu %lu %lu " // rsslim, start_code, end_code, start_stack, esp, eip
"%*s %*s %*s %*s " // pending, blocked, sigign, sigcatch <=== DISCARDED
"%lu %*u %*u " // 0 (former wchan), 0, 0 <=== Placeholders only
"%d %d " // exit_signal, task_cpu
"%d %d " // rt_priority, policy (sched)
"%llu %llu %llu", // blkio_ticks, gtime, cgtime
&P->state,
&P->ppid, &P->pgrp, &P->session, &P->tty, &P->tpgid,
&P->flags, &P->min_flt, &P->cmin_flt, &P->maj_flt, &P->cmaj_flt,
@ -582,7 +583,8 @@ ENTER(0x160);
/* -- Linux 2.0.35 ends here -- */
&P->exit_signal, &P->processor, /* 2.2.1 ends with "exit_signal" */
/* -- Linux 2.2.8 to 2.5.17 end here -- */
&P->rtprio, &P->sched /* both added to 2.5.18 */
&P->rtprio, &P->sched, /* both added to 2.5.18 */
&P->blkio_tics, &P->gtime, &P->cgtime
);
if(!P->nlwp){
@ -596,7 +598,7 @@ LEAVE(0x160);
static void statm2proc(const char* s, proc_t *restrict P) {
int num;
num = sscanf(s, "%ld %ld %ld %ld %ld %ld %ld",
num = sscanf(s, "%lu %lu %lu %lu %lu %lu %lu",
&P->size, &P->resident, &P->share,
&P->trs, &P->lrs, &P->drs, &P->dt);
/* fprintf(stderr, "statm2proc converted %d fields.\n",num); */

View File

@ -21,13 +21,6 @@
__BEGIN_DECLS
// ld cutime, cstime, priority, nice, timeout, alarm, rss,
// c state,
// d ppid, pgrp, session, tty, tpgid,
// s signal, blocked, sigignore, sigcatch,
// lu flags, min_flt, cmin_flt, maj_flt, cmaj_flt, utime, stime,
// lu rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip,
// lu start_time, vsize, wchan,
// This is to help document a transition from pid to tgid/tid caused
// by the introduction of thread support. It is used in cases where
@ -44,11 +37,6 @@ typedef struct proc_t {
int
tid, // (special) task id, the POSIX thread ID (see also: tgid)
ppid; // stat,status pid of parent process
long // next 2 fields are NOT filled in by readproc
maj_delta, // stat (special) major page faults since last update
min_delta; // stat (special) minor page faults since last update
unsigned
pcpu; // stat (special) %CPU usage (is not filled in by readproc!!!)
char
state, // stat,status single-char code for process state (S=sleeping)
#ifdef FALSE_THREADS
@ -65,7 +53,14 @@ typedef struct proc_t {
// and so on...
cutime, // stat cumulative utime of process and reaped children
cstime, // stat cumulative stime of process and reaped children
start_time; // stat start time of process -- seconds since 1-1-70
start_time, // stat start time of process -- seconds since 1-1-70
blkio_tics, // stat time spent waiting for block IO
gtime, // stat guest time of the task in jiffies
cgtime; // stat guest time of the task children in jiffies
int // next 3 fields are NOT filled in by readproc
pcpu, // stat (special) elapsed tics for %CPU usage calculation
maj_delta, // stat (special) major page faults since last update
min_delta; // stat (special) minor page faults since last update
#ifdef SIGNAL_STRING
char
// Linux 2.1.7x and up have 64 signals. Allow 64, plus '\0' and padding.
@ -89,12 +84,13 @@ typedef struct proc_t {
start_stack, // stat address of the bottom of stack for the process
kstk_esp, // stat kernel stack pointer
kstk_eip, // stat kernel instruction pointer
wchan; // stat (special) address of kernel wait channel proc is sleeping in
long
priority, // stat kernel scheduling priority
nice, // stat standard unix nice level of process
wchan, // stat (special) address of kernel wait channel proc is sleeping in
rss, // stat identical to 'resident'
alarm, // stat ?
alarm; // stat ?
int
priority, // stat kernel scheduling priority
nice; // stat standard unix nice level of process
unsigned long
// the next 7 members come from /proc/#/statm
size, // statm total virtual memory (as # pages)
resident, // statm resident non-swapped memory (as # pages)
@ -103,7 +99,7 @@ typedef struct proc_t {
lrs, // statm library resident set (always 0 w/ 2.6)
drs, // statm data+stack resident set (as # pages)
dt; // statm dirty pages (always 0 w/ 2.6)
long
unsigned long
vm_size, // status equals 'size' (as kb)
vm_lock, // status locked pages (as kb)
vm_rss, // status equals 'rss' and/or 'resident' (as kb)
@ -115,8 +111,6 @@ typedef struct proc_t {
vm_swap, // status based on linux-2.6.34 "swap ents" (as kb)
vm_exe, // status equals 'trs' (as kb)
vm_lib, // status total, not just used, library pages (as kb)
rtprio, // stat real-time priority
sched, // stat scheduling class
vsize, // stat number of pages of virtual memory ...
rss_rlim, // stat resident set size limit?
flags, // stat kernel flags for the process
@ -145,6 +139,8 @@ typedef struct proc_t {
*fgroup, // status filesystem group name
*cmd; // stat,status basename of executable file in call to exec(2)
int
rtprio, // stat real-time priority
sched, // stat scheduling class
pgrp, // stat process group id
session, // stat session id
nlwp, // stat,status number of threads, or 0 if no clue