Bug 196524 - vmstat -m 10 ... never shows swap activity.
Summary: vmstat -m 10 ... never shows swap activity.
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: procps
Version: 3.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks: 190430
TreeView+ depends on / blocked
 
Reported: 2006-06-23 22:51 UTC by Mike Simons
Modified: 2007-11-30 22:07 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-01-18 15:20:59 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Mike Simons 2006-06-23 22:51:21 UTC
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 11:20:49 UTC
Good catch. Thanks!

Comment 5 RHEL Program Management 2007-01-18 15:20:59 UTC
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.