[compiler-rt] [msan] Reland: Increase k num stack origin descrs (limited to non-PowerPC) (PR #93117)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 17:45:12 PDT 2024


https://github.com/thurstond created https://github.com/llvm/llvm-project/pull/93117

The original pull request (https://github.com/llvm/llvm-project/pull/92838) was reverted due to a PowerPC buildbot breakage (https://github.com/llvm/llvm-project/commit/df626dd11c360c58eddae813ce6a0524d0a53696).
This reland limits the scope of the change to non-PowerPC platforms. I am unaware of any PowerPC use cases that would benefit from a larger kNumStackOriginDescrs constant.

Original CL description: This increases the constant size of kNumStackOriginDescrs to 4M (64GB of BSS across two arrays), which ought to be enough for anybody.

This is the easier alternative suggested by eugenis@ in https://github.com/llvm/llvm-project/pull/92826.



>From 3d6395048b7a536bf9f2693f436ef7e18aaa303f Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston at google.com>
Date: Mon, 20 May 2024 23:56:02 +0000
Subject: [PATCH 1/3] [msan] Increase kNumStackOriginDescrs constant

This increases the constant size of kNumStackOriginDescrs to
64M (1GB of BSS across two arrays), which ought to be enough for
anybody.

This is the easier alternative suggested by eugenis@ in
https://github.com/llvm/llvm-project/pull/92826.
---
 compiler-rt/lib/msan/msan.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index a2fc27de1901b..8bef6812f21c2 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -100,7 +100,13 @@ int msan_report_count = 0;
 
 // Array of stack origins.
 // FIXME: make it resizable.
-static const uptr kNumStackOriginDescrs = 1024 * 1024;
+// Although BSS memory doesn't cost anything until used, it is limited to 2GB
+// in some configurations (e.g., relocation R_X86_64_PC32 out of range:
+// 8600110908 is not in [-2147483648, 2147483647]; references section '.bss')
+// hence kNumStackOriginDescrs is limited to roughly 2GB / sizeof(uptr) / 2
+// == 128M per array (StackOriginDescr, StackOriginPC). We set it at 64M each
+// in case other parts of MSan want more BSS space in the future.
+static const uptr kNumStackOriginDescrs = 64 * 1024 * 1024;
 static const char *StackOriginDescr[kNumStackOriginDescrs];
 static uptr StackOriginPC[kNumStackOriginDescrs];
 static atomic_uint32_t NumStackOriginDescrs;

>From 45d0496380c7ea98a98777679b41839a94145c4d Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston at google.com>
Date: Tue, 21 May 2024 18:25:50 +0000
Subject: [PATCH 2/3] Change constant to 4M per Evgenii's feedback

---
 compiler-rt/lib/msan/msan.cpp | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 8bef6812f21c2..7a152910193e0 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -101,12 +101,10 @@ int msan_report_count = 0;
 // Array of stack origins.
 // FIXME: make it resizable.
 // Although BSS memory doesn't cost anything until used, it is limited to 2GB
-// in some configurations (e.g., relocation R_X86_64_PC32 out of range:
-// 8600110908 is not in [-2147483648, 2147483647]; references section '.bss')
-// hence kNumStackOriginDescrs is limited to roughly 2GB / sizeof(uptr) / 2
-// == 128M per array (StackOriginDescr, StackOriginPC). We set it at 64M each
-// in case other parts of MSan want more BSS space in the future.
-static const uptr kNumStackOriginDescrs = 64 * 1024 * 1024;
+// in some configurations (e.g., "relocation R_X86_64_PC32 out of range:
+// ... is not in [-2147483648, 2147483647]; references section '.bss'").
+// We use kNumStackOriginDescrs * (sizeof(char*) + sizeof(uptr)) == 64MB.
+static const uptr kNumStackOriginDescrs = 4 * 1024 * 1024;
 static const char *StackOriginDescr[kNumStackOriginDescrs];
 static uptr StackOriginPC[kNumStackOriginDescrs];
 static atomic_uint32_t NumStackOriginDescrs;

>From fefb8a3b78e53143f1c308375d2c733de12c0bba Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston at google.com>
Date: Thu, 23 May 2024 00:31:02 +0000
Subject: [PATCH 3/3] This limits the scope of the change to non-PowerPC
 platforms, to avoid the PowerPC buildbot breakage
 (https://lab.llvm.org/buildbot/#/builders/57/builds/35160). I am unaware of
 any PowerPC use cases that would benefit from a larger kNumStackOriginDescrs
 constant.

---
 compiler-rt/lib/msan/msan.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 7a152910193e0..9375e27d4f4d2 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -104,7 +104,13 @@ int msan_report_count = 0;
 // in some configurations (e.g., "relocation R_X86_64_PC32 out of range:
 // ... is not in [-2147483648, 2147483647]; references section '.bss'").
 // We use kNumStackOriginDescrs * (sizeof(char*) + sizeof(uptr)) == 64MB.
+#ifdef SANITIZER_PPC
+// soft_rss_limit test (release_origin.c) fails on PPC if kNumStackOriginDescrs
+// is too high
+static const uptr kNumStackOriginDescrs = 1 * 1024 * 1024;
+#else
 static const uptr kNumStackOriginDescrs = 4 * 1024 * 1024;
+#endif  // SANITIZER_PPC
 static const char *StackOriginDescr[kNumStackOriginDescrs];
 static uptr StackOriginPC[kNumStackOriginDescrs];
 static atomic_uint32_t NumStackOriginDescrs;



More information about the llvm-commits mailing list