[LTP] [PATCH v2] ipc/msgstress03: Assume all forks will run concurently

Teo Couprie Diaz teo.coupriediaz@arm.com
Mon Apr 3 17:52:58 CEST 2023


It appears that msgstress03 doesn't account for all PIDs that its children
can use, as it expects the tasks will terminate quickly and not reach
the PID limit.
On some systems, this assumption can be invalid and the PID limit
will be hit.
Change the limit to account for all possible children at once, knowning
that each child will fork as well.

Signed-off-by: Teo Couprie Diaz <teo.coupriediaz@arm.com>
---
v2:
  - Slightly change the computation, kind of similar to what is done
    in msgstress04, to make the warning make sense with the change.
  - Added comment to clarify.

Maybe the message could be rephrased entirely ? Something along the lines
of: "Maximum number of used processes higher than limit [...]"

CI build: https://github.com/Teo-CD/ltp/actions/runs/4598445898

 testcases/kernel/syscalls/ipc/msgstress/msgstress03.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c b/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
index 3cb70ab18a80..aa37d9058b3e 100644
--- a/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
+++ b/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
@@ -110,11 +110,12 @@ int main(int argc, char **argv)
 	}
 
 	free_pids = tst_get_free_pids(cleanup);
-	if (nprocs >= free_pids) {
+	/* Each forked child forks once, take it into account here. */
+	if (nprocs * 2 >= free_pids) {
 		tst_resm(TINFO,
 			 "Requested number of processes higher than limit (%d > %d), "
-			 "setting to %d", nprocs, free_pids, free_pids);
-		nprocs = free_pids;
+			 "setting to %d", nprocs * 2, free_pids, free_pids);
+		nprocs = free_pids / 2;
 	}
 
 	srand(getpid());
-- 
2.34.1



More information about the ltp mailing list