Skip to contentSkip to conversation

ipc/semget05: Fix .save_restore flags

PATCH In review Martin Doucha 3 participants 7 messages May 5, 2023 – May 8, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ipc/semget05: Fix .save_restore flags

The test can run without root privileges. Add TST_SR_SKIP_RO to ignore read-only permissions on /proc/sys/kernel/sem.

---
 testcases/kernel/syscalls/ipc/semget/semget05.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ipc/semget/semget05.c +2 -1
index 38b0fad3c..d6810c11b 100644
@@ -73,7 +73,8 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test_all = verify_semget,
 	.save_restore = (const struct tst_path_val[]){
-		{"/proc/sys/kernel/sem", NULL, TST_SR_TCONF},
+		{"/proc/sys/kernel/sem", NULL,
+			TST_SR_TCONF_MISSING | TST_SR_SKIP_RO},
 		{}
 	}
 };
Signature · 5 lines
2.40.0


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

PATCH 2/3 ipc/semget05: Set dynamic run time

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.

 testcases/kernel/syscalls/ipc/semget/semget05.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/ipc/semget/semget05.c +3 -0
index d6810c11b..dd9a6285d 100644
@@ -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);
Signature · 5 lines
2.40.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/3
#2 lore raw

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

Hi Martin,

Quoted 7 lines

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.

Kind regards,
Petr

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

PATCH 3/3 doc: Fix typo in max_runtime docs

In reply to Martin Doucha
---
 doc/c-test-api.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/c-test-api.txt +1 -1
index bd9ec72b9..dcb6e1ba8 100644
@@ -102,7 +102,7 @@ that should cover the duration of test setup and cleanup plus some safety.
 Any test that runs for more than a second or two has to make sure to:
 
 - set the runtime either by setting the '.max_runtime' in tst_test or by
-  calling 'tst_set_runtime()' in the test setup
+  calling 'tst_set_max_runtime()' in the test setup
 
 - monitor remaning runtime by regular calls to 'tst_remaining_runtime()' and
   exit when runtime has been used up
Signature · 5 lines
2.40.0


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

Re: [LTP] [PATCH 3/3] doc: Fix typo in max_runtime docs

Hi Martin,

I merged this simple fix.
And I'll ask in "LTP release preparations" thread for merging this. Thanks!

Kind regards,
Petr

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

Re: [LTP] [PATCH 3/3] doc: Fix typo in max_runtime docs

Hi Petr, Martin

Quoted 4 lines

Hi Martin,

I merged this simple fix.
And I'll ask in "LTP release preparations" thread for merging this.

This patchset is LGTM, I don't see this email and has merged this patchset, sorry.

ps: This patchset is simple change, so I guess it will not affect a lot for "LTP release preparations".

Best Regards
Yang Xu

Quoted 5 lines

Thanks!

Kind regards,
Petr

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