Bug 196524 - vmstat -m 10 ... never shows swap activity.
vmstat -m 10 ... never shows swap activity.
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: procps (Show other bugs)
3.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Karel Zak
Brian Brock
:
Depends On:
Blocks: 190430
  Show dependency treegraph
 
Reported: 2006-06-23 18:51 EDT by Mike Simons
Modified: 2007-11-30 17:07 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-01-18 10:20:59 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mike Simons 2006-06-23 18:51:21 EDT
Description of problem:

vmstat -m 10 ... never shows activity.

Reason is that swap_in/out are multipled by page_units and page_units is
equal to 0, because code right shifts getpagesize() to by 20 bits
(4096 >> 20 == 0).


How reproducible:
always

Steps to Reproduce:
1... in one window:
  vmstat -m 10
2... in another window:
  vmstat -k 10
3... now make the machine swap... 
I recommend running and suspending as many of these as you 
need to swap:
  perl -e '"a" x (1<<30); print "done\n";'

Actual results:
in -m vmstat si and so columns are zero,
in -k vmstat si/so are multiple megabytes

Expected results:
si and so columns are non-zero in -m window


Additional info:

source code walk through... 

rhel3/procps-2.0.17/vmstat.c
===
     93   while ((opt = getopt_long(argc, argv, "nabkmgVh", longopts,
     94                   NULL)) != -1) {
    108           case 'm':
    109                   shift = 20;
    110                   break;
    111           case 'g':
    112                   shift = 30;
    113                   break;
[...]
    171   page_units = getpagesize() >> shift;
[...]
    179   printf("%2lu %2lu %6llu %6llu %6llu %6llu %4lu %4lu %5lu %5lu "
    180           "%4lu %5lu %2lu %2lu %2lu %2lu\n",
    181           stats[0].running, stats[0].blocked,
    182           mem_info.swap.used >> shift, mem_info.mem.free >> shift,
    183                 (show_active) ? (mem_info.mem.inactive_dirty +
    184                           mem_info.mem.inactive_clean) >> shift :
    185                           mem_info.mem.buffers >> shift,
    186           (show_active) ? mem_info.mem.active >> shift :
    187                           mem_info.mem.cached >> shift,
    188           (stats[0].swap_in * page_units * hz + half_cpu) / total_cpu,
    189           (stats[0].swap_out * page_units * hz + half_cpu) / total_cpu,
===

Needs to do something like (not tested):
===
    page_units = getpagesize();
    ((stats[0].swap_in * page_units * hz) >> shift + half_cpu) / total_cpu,
===
Comment 1 Karel Zak 2006-06-26 07:20:49 EDT
Good catch. Thanks!
Comment 5 RHEL Product and Program Management 2007-01-18 10:20:59 EST
Product Management has reviewed and declined this request.  You may appeal this
decision by reopening this request. 

Note You need to log in before you can comment on or make changes to this bug.