summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2018-02-05 15:21:40 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2018-02-05 15:22:20 +0000
commitbed3cd5ed18e3c029e2d3dcf19584e7e259da5e1 (patch)
treef920e6f9970b52518d5d71f1999a9e8d91f702f2 /usr/src
parent798215342b98076fa2a26da2dba1176b2ce84532 (diff)
downloadillumos-joyent-bed3cd5ed18e3c029e2d3dcf19584e7e259da5e1.tar.gz
OS-6584 lx: 'ps -ef' stime output is sometimes wrong
Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/brand/lx/procfs/lx_prvnops.c27
-rw-r--r--usr/src/uts/common/brand/lx/sys/lx_userhz.h4
2 files changed, 24 insertions, 7 deletions
diff --git a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
index 349f4a55d5..71e608c0d0 100644
--- a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
+++ b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
@@ -21,7 +21,7 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- * Copyright 2017 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
/*
@@ -64,6 +64,7 @@
#include <sys/kstat.h>
#include <sys/lx_misc.h>
#include <sys/lx_types.h>
+#include <sys/lx_userhz.h>
#include <sys/brand.h>
#include <sys/cred_impl.h>
#include <sys/tihdr.h>
@@ -2843,6 +2844,13 @@ lxpr_read_pid_tid_stat(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
ticks -= boottime;
lxpr_unlock(p);
+ /* Adjust hz for relevant fields */
+ utime = HZ_TO_LX_USERHZ(utime);
+ stime = HZ_TO_LX_USERHZ(stime);
+ cutime = HZ_TO_LX_USERHZ(cutime);
+ cstime = HZ_TO_LX_USERHZ(cstime);
+ ticks = HZ_TO_LX_USERHZ(ticks);
+
lxpr_uiobuf_printf(uiobuf,
"%d " /* 1 */
"(%s) %c %d %d %d %d %d " /* 2-8 */
@@ -4497,6 +4505,12 @@ lxpr_read_stat(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
fmtstr1 = "cpu%d %lu 0 %lu %lu\n";
}
+ /* Adjust hz */
+ user_cum = HZ_TO_LX_USERHZ(user_cum);
+ sys_cum = HZ_TO_LX_USERHZ(sys_cum);
+ idle_cum = HZ_TO_LX_USERHZ(idle_cum);
+ irq_cum = HZ_TO_LX_USERHZ(irq_cum);
+
lxpr_uiobuf_printf(uiobuf, fmtstr0,
user_cum, sys_cum, idle_cum, irq_cum);
@@ -4519,18 +4533,19 @@ lxpr_read_stat(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
get_cpu_mstate(cp, msnsecs);
- idle_ticks = NSEC_TO_TICK(msnsecs[CMS_IDLE]);
- sys_ticks = NSEC_TO_TICK(msnsecs[CMS_SYSTEM]);
- user_ticks = NSEC_TO_TICK(msnsecs[CMS_USER]);
+ idle_ticks = HZ_TO_LX_USERHZ(NSEC_TO_TICK(msnsecs[CMS_IDLE]));
+ sys_ticks = HZ_TO_LX_USERHZ(NSEC_TO_TICK(msnsecs[CMS_SYSTEM]));
+ user_ticks = HZ_TO_LX_USERHZ(NSEC_TO_TICK(msnsecs[CMS_USER]));
for (i = 0; i < NCMSTATES; i++) {
tmptime = cp->cpu_intracct[i];
scalehrtime(&tmptime);
irq_ticks += NSEC_TO_TICK(tmptime);
}
+ irq_ticks = HZ_TO_LX_USERHZ(irq_ticks);
- lxpr_uiobuf_printf(uiobuf, fmtstr1,
- cp->cpu_id, user_ticks, sys_ticks, idle_ticks, irq_ticks);
+ lxpr_uiobuf_printf(uiobuf, fmtstr1, HZ_TO_LX_USERHZ(cp->cpu_id),
+ user_ticks, sys_ticks, idle_ticks, irq_ticks);
if (pools_enabled)
cp = cp->cpu_next_part;
diff --git a/usr/src/uts/common/brand/lx/sys/lx_userhz.h b/usr/src/uts/common/brand/lx/sys/lx_userhz.h
index 7f273744c8..ebbda28698 100644
--- a/usr/src/uts/common/brand/lx/sys/lx_userhz.h
+++ b/usr/src/uts/common/brand/lx/sys/lx_userhz.h
@@ -10,7 +10,7 @@
*/
/*
- * Copyright 2017 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
#ifndef _LX_USERHZ_H
@@ -46,6 +46,8 @@ extern "C" {
* testing on Linux seems to show that these fields are not consistent
* with the corresponding times(2) data for the process, even for the
* SIGCHLD sigaction handler case.
+ * 4) Some fields in /proc/stat and /proc/pid/stat. See the Linux proc man
+ * page for references to sysconf(_SC_CLK_TCK).
*
* Although the siginfo_t si_stime and si_utime data for cases #2 and #3 is not
* consistent on Linux, we populate these fields correctly to be on the safe