[PATCH] [Sanitizer] Fix GetRSS on Linux with non-4k pages

Jay Foad jay.foad at gmail.com
Thu Dec 18 01:37:24 PST 2014


Hi kcc, willschm,

The numbers in /proc/self/statm are in pages, not in fixed 4k units.
This fixes Linux/hard_rss_limit_mb_test.cc on my PowerPC64 box which
has 64k pages.

http://reviews.llvm.org/D6717

Files:
  lib/sanitizer_common/sanitizer_linux.cc

Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -432,7 +432,7 @@
   buf[len] = 0;
   // The format of the file is:
   // 1084 89 69 11 0 79 0
-  // We need the second number which is RSS in 4K units.
+  // We need the second number which is RSS in pages.
   char *pos = buf;
   // Skip the first number.
   while (*pos >= '0' && *pos <= '9')
@@ -444,7 +444,7 @@
   uptr rss = 0;
   while (*pos >= '0' && *pos <= '9')
     rss = rss * 10 + *pos++ - '0';
-  return rss * 4096;
+  return rss * GetPageSizeCached();
 }
 
 static void GetArgsAndEnv(char*** argv, char*** envp) {

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6717.17425.patch
Type: text/x-patch
Size: 732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141218/ddfbd231/attachment.bin>


More information about the llvm-commits mailing list