[LTP] [PATCH 2/3] ipc/semget05: Set dynamic run time

Martin Doucha mdoucha@suse.cz
Fri May 5 16:56:25 CEST 2023


The semget() syscall can be slow on some archs so too high default
system limit may cause timeouts. Set dynamic run time based on
semaphore limit.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

I've originally tried to create an IPC namespace and set low custom limit
but IPC namespaces don't allow unprivileged users to reconfigure them
like the network namespaces do. This is the second best solution.

 testcases/kernel/syscalls/ipc/semget/semget05.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testcases/kernel/syscalls/ipc/semget/semget05.c b/testcases/kernel/syscalls/ipc/semget/semget05.c
index d6810c11b..dd9a6285d 100644
--- a/testcases/kernel/syscalls/ipc/semget/semget05.c
+++ b/testcases/kernel/syscalls/ipc/semget/semget05.c
@@ -42,6 +42,9 @@ static void setup(void)
 		used_cnt);
 	SAFE_FILE_SCANF("/proc/sys/kernel/sem", "%*d %*d %*d %d", &maxsems);
 
+	/* Prevent timeout due to high semaphore array limit */
+	tst_set_max_runtime(maxsems / 200);
+
 	sem_id_arr = SAFE_MALLOC((maxsems - used_cnt) * sizeof(int));
 	for (num = 0; num < maxsems - used_cnt; num++) {
 		res = semget(semkey + num, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
-- 
2.40.0



More information about the ltp mailing list