[llvm-branch-commits] [NFC][msan][test] Chunk memset in release_origin.c (PR #231058)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Oct 11 20:02:28 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
A single 100 MiB __msan_memset faults in all 100 MiB of user pages before
SetShadow unmaps the corresponding shadow and origin pages. Under heavy test
parallelism on 192-CPU ppc64le (64 KiB pages, 24 MiB per-CPU RSS counter
batch), this causes two problems:
1. BackgroundThread (polling every 100 ms) can sample GetRSS() mid-memset
during the temporary +100 MiB RSS spike before shadow/origin pages are
unmapped.
2. If the thread migrates across CPUs during the 100 MiB user page faults,
earlier CPUs retain partial positive per-CPU RSS batches while the single
MmapFixedSuperNoReserve syscall unmaps all 100 MiB of shadow on the final
CPU, causing global /proc/self/statm RSS to drop prematurely in non-origin
mode.
Splitting the memset into 1 MiB chunks bounds the transient RSS spike to 1 MiB
and pairs each chunk's user page faults with its shadow/origin unmap on the
same CPU.
Assisted-by: Gemini
---
Full diff: https://github.com/llvm/llvm-project/pull/231058.diff
1 Files Affected:
- (modified) compiler-rt/test/msan/release_origin.c (+2-1)
``````````diff
diff --git a/compiler-rt/test/msan/release_origin.c b/compiler-rt/test/msan/release_origin.c
index be20c83297add..560aee5182207 100644
--- a/compiler-rt/test/msan/release_origin.c
+++ b/compiler-rt/test/msan/release_origin.c
@@ -16,7 +16,8 @@ int main(int argc, char **argv) {
p = malloc(s);
sleep(1);
fprintf(stderr, "memset\n");
- memset(p, 1, s);
+ for (int i = 0; i < s; i += 1024 * 1024)
+ memset((char *)p + i, 1, 1024 * 1024);
sleep(1);
fprintf(stderr, "free\n");
free(p);
``````````
</details>
https://github.com/llvm/llvm-project/pull/231058
More information about the llvm-branch-commits
mailing list