Skip to contentSkip to conversation

semctl: use IPC_PRIVATE to minimize interference.

PATCH In review Stephen Bertram via ltp 3 participants 3 messages Apr 14 – Apr 15

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 semctl: use IPC_PRIVATE to minimize interference.

This update solves previous issues when tests were run in parallel with multiple workers in tmt.

---
 testcases/kernel/syscalls/ipc/semctl/semctl03.c | 5 +----
 testcases/kernel/syscalls/ipc/semctl/semctl05.c | 6 +-----
 testcases/kernel/syscalls/ipc/semctl/semctl07.c | 3 +--
 3 files changed, 3 insertions(+), 11 deletions(-)
testcases/kernel/syscalls/ipc/semctl/semctl03.c +1 -4
index 5a11b95ef..dc11d0823 100644
@@ -84,14 +84,11 @@ static void verify_semctl(unsigned int n)
 
 static void setup(void)
 {
-	static key_t semkey;
 	struct test_variants *tv = &variants[tst_variant];
 
 	tst_res(TINFO, "Testing variant: %s", tv->desc);
 
-	semkey = GETIPCKEY();
-
-	sem_id = SAFE_SEMGET(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
+	sem_id = SAFE_SEMGET(IPC_PRIVATE, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
 
 	bad_ptr = tst_get_bad_addr(NULL);
 }
testcases/kernel/syscalls/ipc/semctl/semctl05.c +1 -5
index 985c1f039..f1ab69f59 100644
@@ -45,11 +45,7 @@ static void verify_semctl(unsigned int n)
 
 static void setup(void)
 {
-	static key_t semkey;
-
-	semkey = GETIPCKEY();
-
-	sem_id = SAFE_SEMGET(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
+	sem_id = SAFE_SEMGET(IPC_PRIVATE, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
 }
 
 static void cleanup(void)
testcases/kernel/syscalls/ipc/semctl/semctl07.c +1 -2
index 1b03f0ab2..a0b5f4928 100644
@@ -130,10 +130,9 @@ static void verify_semctl(void)
 
 static void setup(void)
 {
-	key_t key = GETIPCKEY();
 	nsems = 1;
 
-	semid = SAFE_SEMGET(key, nsems, SEM_RA | IPC_CREAT);
+	semid = SAFE_SEMGET(IPC_PRIVATE, nsems, SEM_RA | IPC_CREAT);
 }
 
 static void cleanup(void)
Signature · 5 lines
2.53.0


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

Hi Stephen,

Quoted 4 lines · Stephen Bertram

semctl: use IPC_PRIVATE to minimize interference.

This update solves previous issues when tests were run in parallel with multiple workers in tmt.

Since you describe this as fixing a bug, a Fixes: tag is expected. Please add one pointing to the commit that introduced the named-key usage. If that commit predates LTP's git history, mention it in the cover letter.

---
Note:

Our agent completed the review of the patch. The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

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