Package: procps Version: 1:3.2.8-2 Severity: important Tags: patch Due to a very old bug in vmstat (apparently wrong descision), vmstat always displays zero in swap in/out columns when invoked with -SM (units=Mb). This is because in that case, si/so gets converted to megabytes/sec (or tried to, anyway), which is insane swap levels. On the other hand, using -SM on nowadays machines makes much more sense because amount of memory on a typical machine is measured in gigabytes, thus making default vmstat display hardly readable. Note also that bi/bo columns (I/O per sec) is not affected by -S.
The patch attached just removes wrong unit conversion for kb_per_page to megabytes (!), making the whole thing more sensible. Severity is important because vmstat is one of essential tools to diagnose system problems (including inadequate memory usage), and it is assumed the tool is correct, but since it displays 0 for swapping such important problem gets unnoticed. As far as I can see, many people hit this trap - not noticing the swapping while the sole reason for their system slowness is swapping. Thanks! -- System Information: Debian Release: 5.0.3 APT prefers stable APT policy: (990, 'stable'), (60, 'testing'), (50, 'unstable'), (1, 'experimental') Architecture: i386 (x86_64) Kernel: Linux 2.6.32-rc7-amd64 (SMP w/2 CPU cores) Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages procps depends on: ii initscripts 2.86.ds1-61 Scripts for initializing and shutt ii libc6 2.7-18 GNU C Library: Shared libraries ii libncurses5 5.7+20081213-1 shared libraries for terminal hand ii lsb-base 3.2-20 Linux Standard Base 3.2 init scrip Versions of packages procps recommends: ii psmisc 22.6-1 Utilities that use the proc filesy procps suggests no packages. -- no debconf information Fix vmstat swap (si/so) displaying to be != 0 by default vmstat displays statistics in Kb. There's a command-line switch, -S, to specify units - either Kb or Mb. With -SM (Mb), some stats gets converted to megabytes - such as amount of memory and swap. But for some values such conversion makes no good sense. For example, block i/o (bi&bo) are always displayed in Kb/sec regardless of -S, because it is not yet expected to see disk speeds in gigabytes per sec. But swapin/swapout (si&so columns) gets converted to megabytes per sec, and if we're reaching this level of swap the system is barely usable. It is not a good idea to convert si&so to megabytes. It's more: the usage of swaps * unitConvert(kb_per_page) is already wrong. unitConvert converst the value to either kb or mb, and kb_per_page is usually a small number like 4. Converting it to mb will return 0. So swap will always be 0 if we're converting to megabytes. In short, with -SM swap as displayed by vmstat is always 0. But -SM makes much more sense nowadays because amount of memory on a typical system measured in gigabytes, so that vmstat memory area gets large and other colums are shifted. The fix is to remove the unitConvert() call for swap stats to always display swap in/out values in kb/sec, as done with block i/o (bi/bo). This is a very old issue, but it's also a classical trap: when looking at vmstat output while debugging "slow system" issue, it is vital to have correct information in swap in/out columns. Or else, in case of swapping, such swapping wont be noticed. Signed-off-by: Michael Tokarev <m...@tls.msk.ru> --- procps-3.2.8/vmstat.c.orig 2009-11-26 12:44:33.217326167 +0300 +++ procps-3.2.8/vmstat.c 2009-11-26 12:43:46.670940161 +0300 @@ -211,4 +211,4 @@ unitConvert(a_option?kb_active:kb_main_cached), - (unsigned)( (*pswpin * unitConvert(kb_per_page) * hz + divo2) / Div ), - (unsigned)( (*pswpout * unitConvert(kb_per_page) * hz + divo2) / Div ), + (unsigned)( (*pswpin * kb_per_page * hz + divo2) / Div ), + (unsigned)( (*pswpout * kb_per_page * hz + divo2) / Div ), (unsigned)( (*pgpgin * hz + divo2) / Div ), @@ -260,4 +260,4 @@ unitConvert(a_option?kb_active:kb_main_cached), - (unsigned)( ( (pswpin [tog] - pswpin [!tog])*unitConvert(kb_per_page)+sleep_half )/sleep_time ), /*si*/ - (unsigned)( ( (pswpout[tog] - pswpout[!tog])*unitConvert(kb_per_page)+sleep_half )/sleep_time ), /*so*/ + (unsigned)( ( (pswpin [tog] - pswpin [!tog])*kb_per_page+sleep_half )/sleep_time ), /*si*/ + (unsigned)( ( (pswpout[tog] - pswpout[!tog])*kb_per_page+sleep_half )/sleep_time ), /*so*/ (unsigned)( ( pgpgin [tog] - pgpgin [!tog] +sleep_half )/sleep_time ), /*bi*/ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org