diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-07 23:48:17 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-07 23:48:49 +0000 |
commit | e8c7ac9a7990d41daada0f2a3b49ba7030051b49 (patch) | |
tree | d44f4fdc78f97bc350b639b7a3fa37947241d88d /src | |
parent | 74266756a204f730fef84d30f8ad5ba5627a4921 (diff) | |
download | s6-linux-utils-e8c7ac9a7990d41daada0f2a3b49ba7030051b49.tar.xz |
Prepare for 2.6.2.0, add minflt/majflt to s6-ps
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include-local/s6ps.h | 14 | ||||
-rw-r--r-- | src/libs6ps/s6ps_pfield.c | 36 | ||||
-rw-r--r-- | src/libs6ps/s6ps_statparse.c | 8 | ||||
-rw-r--r-- | src/s6-linux-utils/s6-ps.c | 120 |
4 files changed, 117 insertions, 61 deletions
diff --git a/src/include-local/s6ps.h b/src/include-local/s6ps.h index 951cc3a..ca33a73 100644 --- a/src/include-local/s6ps.h +++ b/src/include-local/s6ps.h @@ -23,7 +23,11 @@ enum pfield_e PFIELD_PGRP, PFIELD_SESSION, PFIELD_TTY, - PFIELD_TPGID, + PFIELD_TPGID, + PFIELD_MINFLT, + PFIELD_CMINFLT, + PFIELD_MAJFLT, + PFIELD_CMAJFLT, PFIELD_UTIME, PFIELD_STIME, PFIELD_CUTIME, @@ -70,6 +74,10 @@ struct pscan_s pid_t session ; dev_t ttynr ; pid_t tpgid ; + uint64_t minflt ; + uint64_t cminflt ; + uint64_t majflt ; + uint64_t cmajflt ; uint64_t utime ; uint64_t stime ; uint64_t cutime ; @@ -104,6 +112,10 @@ struct pscan_s .session = 0, \ .ttynr = 0, \ .tpgid = -1, \ + .minflt = 0, \ + .cminflt = 0, \ + .majflt = 0, \ + .cmajflt = 0, \ .utime = 0, \ .stime = 0, \ .cutime = 0, \ diff --git a/src/libs6ps/s6ps_pfield.c b/src/libs6ps/s6ps_pfield.c index 6d84ea0..ae589aa 100644 --- a/src/libs6ps/s6ps_pfield.c +++ b/src/libs6ps/s6ps_pfield.c @@ -25,6 +25,10 @@ static char const *const fieldheaders[PFIELD_PHAIL] = "SESSION", "TTY", "TPGID", + "MINFLT", + "CMINFLT", + "MAJFLT", + "CMAJFLT", "UTIME", "STIME", "CUTIME", @@ -64,6 +68,10 @@ static char const *const opttable[PFIELD_PHAIL] = "sess", "tty", "tpgid", + "minflt", + "cminflt", + "majflt", + "cmajflt", "utime", "stime", "cutime", @@ -257,6 +265,30 @@ static int fmt_jiffies (s6ps_auxinfo_t *aux, pscan_t *p, size_t *pos, size_t *le return 1 ; } +static int fmt_minflt (s6ps_auxinfo_t *aux, pscan_t *p, size_t *pos, size_t *len) +{ + (void)aux ; + return fmt_64(p, pos, len, p->minflt) ; +} + +static int fmt_cminflt (s6ps_auxinfo_t *aux, pscan_t *p, size_t *pos, size_t *len) +{ + (void)aux ; + return fmt_64(p, pos, len, p->cminflt) ; +} + +static int fmt_majflt (s6ps_auxinfo_t *aux, pscan_t *p, size_t *pos, size_t *len) +{ + (void)aux ; + return fmt_64(p, pos, len, p->majflt) ; +} + +static int fmt_cmajflt (s6ps_auxinfo_t *aux, pscan_t *p, size_t *pos, size_t *len) +{ + (void)aux ; + return fmt_64(p, pos, len, p->cmajflt) ; +} + static int fmt_utime (s6ps_auxinfo_t *aux, pscan_t *p, size_t *pos, size_t *len) { return fmt_jiffies(aux, p, pos, len, p->utime) ; @@ -545,6 +577,10 @@ static pfieldfmt_func_ref const pfieldfmt_table[PFIELD_PHAIL] = &fmt_session, &fmt_ttynr, &fmt_tpgid, + &fmt_minflt, + &fmt_cminflt, + &fmt_majflt, + &fmt_cmajflt, &fmt_utime, &fmt_stime, &fmt_cutime, diff --git a/src/libs6ps/s6ps_statparse.c b/src/libs6ps/s6ps_statparse.c index 8cc5a93..601e14a 100644 --- a/src/libs6ps/s6ps_statparse.c +++ b/src/libs6ps/s6ps_statparse.c @@ -116,10 +116,10 @@ int s6ps_statparse (pscan_t *p) &p->ttynr, &p->tpgid, &dummy64, - &dummy64, - &dummy64, - &dummy64, - &dummy64, + &p->minflt, + &p->cminflt, + &p->majflt, + &p->cmajflt, &p->utime, &p->stime, &p->cutime, diff --git a/src/s6-linux-utils/s6-ps.c b/src/s6-linux-utils/s6-ps.c index 255b195..49cb4fb 100644 --- a/src/s6-linux-utils/s6-ps.c +++ b/src/s6-linux-utils/s6-ps.c @@ -32,22 +32,26 @@ #define USAGE "s6-ps [ -H ] [ -w spacing ] [ -W wchanfile ] [ -l | -o field,field... ]" #define RIGHTFORMATTED ( \ - (1 << PFIELD_PID) | \ - (1 << PFIELD_PPID) | \ - (1 << PFIELD_PGRP) | \ - (1 << PFIELD_SESSION) | \ - (1 << PFIELD_TPGID) | \ - (1 << PFIELD_PRIO) | \ - (1 << PFIELD_NICE) | \ - (1 << PFIELD_THREADS) | \ - (1 << PFIELD_VSIZE) | \ - (1 << PFIELD_RSS) | \ - (1 << PFIELD_RSSLIM) | \ - (1 << PFIELD_CPUNO) | \ - (1 << PFIELD_RTPRIO) | \ - (1 << PFIELD_PMEM) | \ - (1 << PFIELD_PCPU) | \ - ((uint64_t)1 << PFIELD_CPCPU)) + (1ULL << PFIELD_PID) | \ + (1ULL << PFIELD_PPID) | \ + (1ULL << PFIELD_PGRP) | \ + (1ULL << PFIELD_SESSION) | \ + (1ULL << PFIELD_TPGID) | \ + (1ULL << PFIELD_MINFLT) | \ + (1ULL << PFIELD_CMINFLT) | \ + (1ULL << PFIELD_MAJFLT) | \ + (1ULL << PFIELD_CMAJFLT) | \ + (1ULL << PFIELD_PRIO) | \ + (1ULL << PFIELD_NICE) | \ + (1ULL << PFIELD_THREADS) | \ + (1ULL << PFIELD_VSIZE) | \ + (1ULL << PFIELD_RSS) | \ + (1ULL << PFIELD_RSSLIM) | \ + (1ULL << PFIELD_CPUNO) | \ + (1ULL << PFIELD_RTPRIO) | \ + (1ULL << PFIELD_PMEM) | \ + (1ULL << PFIELD_PCPU) | \ + (1ULL << PFIELD_CPCPU)) static void *pid_dtok (unsigned int d, void *x) { @@ -81,7 +85,7 @@ static inline unsigned int ps_fieldscan (char const *s, pfield_t *list, uint64_t for (; i < PFIELD_PHAIL ; i++) if (!strcmp(tmp, s6ps_opttable[i])) break ; if (i >= PFIELD_PHAIL) strerr_dief4x(100, "invalid", " field for -o option", ": ", tmp) ; - if (bits & ((uint64_t)1 << i)) + if (bits & (1ULL << i)) strerr_dief4x(100, "duplicate", " field for -o option", ": ", tmp) ; } s += len + 1 ; @@ -130,7 +134,7 @@ int main (int argc, char const *const *argv) case 'l' : { nfields = 11 ; - fbf = (1 << PFIELD_USER) | (1 << PFIELD_PID) | ((uint64_t)1 << PFIELD_CPCPU) | (1 << PFIELD_PMEM) | (1 << PFIELD_VSIZE) | (1 << PFIELD_RSS) | (1 << PFIELD_TTY) | (1 << PFIELD_STATE) | (1 << PFIELD_START) | (1 << PFIELD_CTTIME) | (1 << PFIELD_ARGS) ; + fbf = (1ULL << PFIELD_USER) | (1ULL << PFIELD_PID) | (1ULL << PFIELD_CPCPU) | (1ULL << PFIELD_PMEM) | (1ULL << PFIELD_VSIZE) | (1ULL << PFIELD_RSS) | (1ULL << PFIELD_TTY) | (1ULL << PFIELD_STATE) | (1ULL << PFIELD_START) | (1ULL << PFIELD_CTTIME) | (1ULL << PFIELD_ARGS) ; fieldlist[0] = PFIELD_USER ; fieldlist[1] = PFIELD_PID ; fieldlist[2] = PFIELD_CPCPU ; @@ -165,35 +169,39 @@ int main (int argc, char const *const *argv) if (spacing > 256) spacing = 256 ; needstat = flagtree || !!(fbf & ( - (1 << PFIELD_PID) | - (1 << PFIELD_COMM) | - (1 << PFIELD_STATE) | - (1 << PFIELD_PPID) | - (1 << PFIELD_PGRP) | - (1 << PFIELD_SESSION) | - (1 << PFIELD_TTY) | - (1 << PFIELD_TPGID) | - (1 << PFIELD_UTIME) | - (1 << PFIELD_STIME) | - (1 << PFIELD_CUTIME) | - (1 << PFIELD_CSTIME) | - (1 << PFIELD_PRIO) | - (1 << PFIELD_NICE) | - (1 << PFIELD_THREADS) | - (1 << PFIELD_START) | - (1 << PFIELD_VSIZE) | - (1 << PFIELD_RSS) | - (1 << PFIELD_RSSLIM) | - (1 << PFIELD_CPUNO) | - (1 << PFIELD_RTPRIO) | - (1 << PFIELD_RTPOLICY) | - (1 << PFIELD_PMEM) | - (1 << PFIELD_WCHAN) | - (1 << PFIELD_PCPU) | - (1 << PFIELD_TTIME) | - (1 << PFIELD_CTTIME) | - ((uint64_t)1 << PFIELD_TSTART) | - ((uint64_t)1 << PFIELD_CPCPU))) ; + (1ULL << PFIELD_PID) | + (1ULL << PFIELD_COMM) | + (1ULL << PFIELD_STATE) | + (1ULL << PFIELD_PPID) | + (1ULL << PFIELD_PGRP) | + (1ULL << PFIELD_SESSION) | + (1ULL << PFIELD_TTY) | + (1ULL << PFIELD_TPGID) | + (1ULL << PFIELD_MINFLT) | + (1ULL << PFIELD_CMINFLT) | + (1ULL << PFIELD_MAJFLT) | + (1ULL << PFIELD_CMAJFLT) | + (1ULL << PFIELD_UTIME) | + (1ULL << PFIELD_STIME) | + (1ULL << PFIELD_CUTIME) | + (1ULL << PFIELD_CSTIME) | + (1ULL << PFIELD_PRIO) | + (1ULL << PFIELD_NICE) | + (1ULL << PFIELD_THREADS) | + (1ULL << PFIELD_START) | + (1ULL << PFIELD_VSIZE) | + (1ULL << PFIELD_RSS) | + (1ULL << PFIELD_RSSLIM) | + (1ULL << PFIELD_CPUNO) | + (1ULL << PFIELD_RTPRIO) | + (1ULL << PFIELD_RTPOLICY) | + (1ULL << PFIELD_PMEM) | + (1ULL << PFIELD_WCHAN) | + (1ULL << PFIELD_PCPU) | + (1ULL << PFIELD_TTIME) | + (1ULL << PFIELD_CTTIME) | + (1ULL << PFIELD_TSTART) | + (1ULL << PFIELD_CPCPU))) ; /* Scan /proc */ @@ -293,18 +301,18 @@ int main (int argc, char const *const *argv) /* Format, compute length, output */ - if (fbf & ((1 << PFIELD_START) | ((uint64_t)1 << PFIELD_TSTART) | (1 << PFIELD_PCPU) | ((uint64_t)1 << PFIELD_CPCPU))) + if (fbf & ((1ULL << PFIELD_START) | (1ULL << PFIELD_TSTART) | (1ULL << PFIELD_PCPU) | (1ULL << PFIELD_CPCPU))) { tain_wallclock_read_g() ; s6ps_compute_boottime(&aux, p, mypos) ; } - if (fbf & (1 << PFIELD_USER) && !s6ps_cache_init(&aux.caches[0])) + if (fbf & (1ULL << PFIELD_USER) && !s6ps_cache_init(&aux.caches[0])) strerr_diefu1sys(111, "init user name cache") ; - if (fbf & (1 << PFIELD_GROUP) && !s6ps_cache_init(&aux.caches[1])) + if (fbf & (1ULL << PFIELD_GROUP) && !s6ps_cache_init(&aux.caches[1])) strerr_diefu1sys(111, "init group name cache") ; - if (fbf & (1 << PFIELD_TTY) && !s6ps_cache_init(&aux.caches[2])) + if (fbf & (1ULL << PFIELD_TTY) && !s6ps_cache_init(&aux.caches[2])) strerr_diefu1sys(111, "init tty name cache") ; - if (fbf & (1 << PFIELD_WCHAN) && !s6ps_wchan_init(&aux.wchan, wchanfile)) + if (fbf & (1ULL << PFIELD_WCHAN) && !s6ps_wchan_init(&aux.wchan, wchanfile)) { if (wchanfile) strerr_warnwu2sys("init wchan file ", wchanfile) ; else strerr_warnwu1sys("init wchan") ; @@ -329,10 +337,10 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < nfields ; i++) if (maxlen[i] > maxspaces) maxspaces = maxlen[i] ; maxspaces += spacing ; - if (fbf & (1 << PFIELD_USER)) s6ps_cache_finish(&aux.caches[0]) ; - if (fbf & (1 << PFIELD_GROUP)) s6ps_cache_finish(&aux.caches[1]) ; - if (fbf & (1 << PFIELD_TTY)) s6ps_cache_finish(&aux.caches[2]) ; - if (fbf & (1 << PFIELD_WCHAN)) s6ps_wchan_finish(&aux.wchan) ; + if (fbf & (1ULL << PFIELD_USER)) s6ps_cache_finish(&aux.caches[0]) ; + if (fbf & (1ULL << PFIELD_GROUP)) s6ps_cache_finish(&aux.caches[1]) ; + if (fbf & (1ULL << PFIELD_TTY)) s6ps_cache_finish(&aux.caches[2]) ; + if (fbf & (1ULL << PFIELD_WCHAN)) s6ps_wchan_finish(&aux.wchan) ; stralloc_free(&satmp) ; { char spaces[maxspaces] ; |