From: Jan Polensky <japo@linux.ibm.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH v1 1/1] overcommit_memory: Disable optimization for malloc to prevent false positives
Date: Tue, 20 May 2025 17:25:51 +0200 [thread overview]
Message-ID: <20250520152551.390069-1-japo@linux.ibm.com> (raw)
When compiling with GCC 15.1.1+, the default-enabled -fmalloc-dce=2 and
-fallocation-dce under -O2 can eliminate the entire malloc block because its
result is only compared to NULL and/or passed to free().
This leads to false positives in tests that expect malloc() to fail under memory
pressure, as the allocation is optimized away.
Disable this optimization for the affected function to preserve the intended
test behavior.
References: https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gcc/Optimize-Options.html
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
---
testcases/kernel/mem/tunable/overcommit_memory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
index b5beebbcd3c4..fb42dbb75a00 100644
--- a/testcases/kernel/mem/tunable/overcommit_memory.c
+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
@@ -151,6 +151,7 @@ static void overcommit_memory_test(void)
}
+__attribute__((optimize("O0")))
static int heavy_malloc(long size)
{
char *p;
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2025-05-20 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 15:25 Jan Polensky [this message]
2025-05-21 19:47 ` [LTP] [RFC PATCH v1 1/1] overcommit_memory: Disable optimization for malloc to prevent false positives Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250520152551.390069-1-japo@linux.ibm.com \
--to=japo@linux.ibm.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.