Whamcloud - gitweb
LU-13197 e2fsck: avoid mallinfo() if over 2GB allocated 36/37436/7
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 5 Feb 2020 03:17:42 +0000 (20:17 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 23 May 2020 23:02:36 +0000 (23:02 +0000)
commit039b852c6a40e12bec0d621bf7aa4f9b554a8dbc
tree8b5e595fc045d0860041fdd4ead03a4bd3bba640
parent8051687bc488a00fb3e17554064c308add13cbcf
LU-13197 e2fsck: avoid mallinfo() if over 2GB allocated

Don't use mallinfo() for determining the amount of memory used if it
is over 2GB.  Otherwise, the signed ints used by this interface can
can overflow and return garbage values.  This makes the actual amount
of memory used by e2fsck misleading and hard to determine.

Instead, use brk() to get the total amount of memory allocated, and print
this if the more detailed mallinfo() information is not suitable for use.

There does not appear to be a mallinfo64() variant of this function.
There does appear to be an abomination named malloc_info() that writes
XML-formatted malloc stats to a FILE stream that would need to be read
and parsed in order to get these stats.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: If38984cd31b96a8115206f422931a7c0303ebbe5
Reviewed-on: https://review.whamcloud.com/37436
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
e2fsck/util.c