[LTP] [PATCH v1] mmapstress06: Rate limit page-dirtying loop to prevent MemCG OOM-kills
Wei Gao
wegao@suse.com
Tue Aug 25 04:13:06 CEST 2026
Reduce the throttling interval from 2 MB to 64 KB (usleep for 200us
every 64 KB) in the page-dirtying loop. This smooths out allocation
spikes and gives asynchronous swap writeback time to catch up under
slower VM storage environments, avoiding unexpected MemCG OOM-kills.
Signed-off-by: Wei Gao <wegao@suse.com>
---
testcases/kernel/mem/mmapstress/mmapstress06.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/mem/mmapstress/mmapstress06.c b/testcases/kernel/mem/mmapstress/mmapstress06.c
index 4e6023399..2813ef185 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress06.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress06.c
@@ -57,10 +57,14 @@ static void run_test(void)
tst_res(TINFO, "Dirtying %zu bytes in child", map_size);
+ /*
+ * Yield periodically to space out allocation spikes and allow
+ * asynchronous swap writeback to catch up on slower VM disks.
+ */
for (size_t i = 0; i < map_size; i += page_size) {
mmapaddr[i] = 'a';
- if ((i % (2 * 1024 * 1024)) == 0)
- usleep(1000);
+ if ((i % (64 * 1024)) == 0)
+ usleep(200);
}
SAFE_CG_SCANF(cg_child, "memory.swap.current", "%lu", &cg_swap_after);
--
2.55.0
More information about the ltp
mailing list