Skip to contentSkip to conversation

syscalls/msgstress01: Set upper bound for num_messages

PATCH Superseded Ricardo B. Marlière via ltp 1 participant 2 messages May 12, 2025 – May 20, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 syscalls/msgstress01: Set upper bound for num_messages

From: Ricardo B. Marlière <[email protected]>

The msgstress01 test has a workaround to limit the amount of processes it will spawn, but it is only used if the option str_num_messages (-n) is passed. This is known to be problematic in low memory SUTs, so make sure it's used.

---
Changes in v2:
- Print a message if num_messages value is reduced
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 testcases/kernel/syscalls/ipc/msgstress/msgstress01.c | 8 ++++++++
 1 file changed, 8 insertions(+)
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +8 -0
index ae637e5d7ad89c1257c9cce0145122497c19ee64..5fd4cd430f63de4755b4c1d03bf122fb49ddf0d1 100644
@@ -271,6 +271,14 @@ static void setup(void)
 	if (tst_parse_int(str_num_messages, &num_messages, 1, avail_msg))
 		tst_brk(TBROK, "Invalid number of messages '%s'", str_num_messages);
 
+	if (num_messages > avail_msg) {
+		if (avail_msg < num_messages / 2)
+			tst_res(TWARN, "Number of messages reduced to %d", avail_msg);
+		else
+			tst_res(TINFO, "Number of messages reduced to %d", avail_msg);
+		num_messages = avail_msg;
+	}
+
 	if (tst_parse_int(str_num_iterations, &num_iterations, 1, MAXNREPS))
 		tst_brk(TBROK, "Invalid number of messages iterations '%s'", str_num_iterations);
 

---
base-commit: 4a0e3a8fa7b592958f8e3cd366f63c78fba9f014
change-id: 20250512-fixes-msgstress01-4157ceb54b38

Best regards,

Signature · 5 lines
Ricardo B. Marlière <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

testcases/kernel/syscalls/ipc/msgstress/msgstress01.c static void setup(void) · line 280

Quoted 7 lines · Ricardo B. Marlière via ltp
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +7 -0
+	if (num_messages > avail_msg) {
+		if (avail_msg < num_messages / 2)
+			tst_res(TWARN, "Number of messages reduced to %d", avail_msg);
+		else
+			tst_res(TINFO, "Number of messages reduced to %d", avail_msg);
+		num_messages = avail_msg;
+	}

We can simplify with:

    tst_res(
        avail_msg < num_messages / 2 ? TWARN : TINFO, "Number of messages reduced to %d", avail_msg);

- Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp