[procps] [PATCH] Fix "free -b" on 32-bit machine with lots of swap

  • From: Adam Sampson <ats@xxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Tue, 26 Jun 2012 14:18:01 +0100

Hi,

On my i386 machine with 6G of swap, the "free -b" test fails, because
the "swap total" field wraps at 4G -- there's a cast in the wrong place
in free.c which means it's doing a "long" multiplication rather than a
"long long" one. Patch attached.

; uname -a
Linux gar-ia32 3.3.4 #1 SMP PREEMPT Sun May 6 23:55:38 BST 2012 i686 GNU/Linux
; cat /proc/meminfo 
MemTotal:        3630724 kB
[...]
SwapTotal:       6147064 kB
[...]
# i.e. swaptotal should be 6294593536 bytes

# With free from procps-3.2.8 (or 3.3.3 with the patch):
; free -b
             total       used       free     shared    buffers     cached
Mem:    3717861376 2718912512  998948864          0  379105280 2096431104
-/+ buffers/cache:  243376128 3474485248
Swap:   6294593536   19431424 6275162112

# With free from procps-3.3.3 (without the patch);
; work/procps-3.3.3/free -b
             total       used       free     shared    buffers     cached
Mem:    3717861376 2718658560  999202816          0  379113472 2096439296
-/+ buffers/cache:  243105792 3474755584
Swap:   1999626240   19431424 1980194816

Thanks,

-- 
Adam Sampson <ats@xxxxxxxxx>                         <http://offog.org/>











Other related posts: