aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-09-02 01:23:58 -0500
committerRob Landley <rob@landley.net>2015-09-02 01:23:58 -0500
commit54524ccbf83feb842271cf08349d9626b753f20f (patch)
treed219db59c0ac0d91cd7344124df83d152ec82e5a
parent3b83ab5cc76ea4a1dcd785c7df4957f3b5062f72 (diff)
downloadtoybox-54524ccbf83feb842271cf08349d9626b753f20f.tar.gz
vmstat: fix units for bi and bo columns
pgpgin and pgpgout in /proc/vmstat are in kbytes, not pages. (see http://lxr.free-electrons.com/source/mm/vmstat.c?v=4.2#L1310). Remove the extra * page_kb for io_in and io_out.
-rw-r--r--toys/other/vmstat.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c
index ad76a070..df35db12 100644
--- a/toys/other/vmstat.c
+++ b/toys/other/vmstat.c
@@ -2,7 +2,7 @@
*
* Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
*
- * TODO: I have no idea how the "io" and "system" categories are calculated.
+ * TODO: I have no idea how "system" category is calculated.
* whatever we're doing isn't matching what other implementations are doing.
USE_VMSTAT(NEWTOY(vmstat, ">2n", TOYFLAG_BIN))
@@ -33,8 +33,10 @@ struct vmstat_proc {
uint64_t user, nice, sys, idle, wait, irq, sirq, intr, ctxt, running, blocked;
// From /proc/meminfo (units are kb)
uint64_t memfree, buffers, cached, swapfree, swaptotal;
+ // From /proc/vmstat (units are kb)
+ uint64_t io_in, io_out;
// From /proc/vmstat (units are pages)
- uint64_t io_in, io_out, swap_in, swap_out;
+ uint64_t swap_in, swap_out;
};
// All the elements of vmstat_proc are the same size, so we can populate it as
@@ -142,7 +144,8 @@ void vmstat_main(void)
// Adjust rate and units
if (i>5) out -= oldptr[order[i]];
if (order[i]<7) out = ((out*100) + (total_hz/2)) / total_hz;
- else if (order[i]>15) out = ((out * page_kb)+(units-1))/units;
+ else if (order[i]>17) out = ((out * page_kb)+(units-1))/units;
+ else if (order[i]>15) out = ((out)+(units-1))/units;
else if (order[i]<9) out = (out+(units-1)) / units;
// If a field was too big to fit in its slot, try to compensate later