diff mbox series

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

Message ID 20230505145626.2537-2-mdoucha@suse.cz
State Accepted
Headers show
Series [1/3] ipc/semget05: Fix .save_restore flags | expand

Commit Message

Martin Doucha May 5, 2023, 2:56 p.m. UTC
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(+)

Comments

Petr Vorel May 5, 2023, 4:24 p.m. UTC | #1
Hi Martin,

> 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.

> 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.

IMHO good enough.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
diff mbox series

Patch

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);