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, ===
Good catch. Thanks!
Product Management has reviewed and declined this request. You may appeal this decision by reopening this request.