Skip to contentSkip to conversation

syscalls/shmget: Add shmget07 to test SHM_HUGETLB with raw device read

PATCH In review Pavithra 2 participants 2 messages Sep 19

lore
Share & tools
lore

Pavithra

author
#0 lore raw

PATCH v7 1/1 syscalls/shmget: Add shmget07 to test SHM_HUGETLB with raw device read

Test that a hugepage-backed shared memory segment can be created, attached, written to via /dev/zero, detached and removed without errors.

---
v6 -> v7:
- Fix read() destination not advancing per iteration (shmaddr ->
shmaddr + i)
- Add SAFE_SHMCTL(IPC_RMID) and reset shmid = -1 at end of run_test()
to fix hugepage pool leak between iterations (ENOMEM on -i 2)
- Add SAFE_CLOSE(raw_fd) to fix fd leak
- Use NR_HUGEPAGES in .hugepages struct instead of magic literal 2
Link to v6: https://lore.kernel.org/ltp/[email protected]/

---
 runtest/syscalls                            |  1 +
 testcases/kernel/syscalls/shmget/.gitignore |  1 +
 testcases/kernel/syscalls/shmget/shmget07.c | 76 +++++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 testcases/kernel/syscalls/shmget/shmget07.c
runtest/syscalls +1 -0
index accdf2df9..e6b0f3f0b 100644
@@ -1593,6 +1593,7 @@ shmget03 shmget03
 shmget04 shmget04
 shmget05 shmget05
 shmget06 shmget06
+shmget07 shmget07
 
 shutdown01 shutdown01
 shutdown02 shutdown02
testcases/kernel/syscalls/shmget/.gitignore +1 -0
index 768d1c69d..23ba002b5 100644
@@ -3,3 +3,4 @@
 /shmget04
 /shmget05
 /shmget06
+/shmget07
testcases/kernel/syscalls/shmget/shmget07.c new file +76 -0

76 lines not on this page · raw message

Signature · 5 lines
2.55.0


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

Hi Pavithra,

Quoted 1 line · Pavithra

syscalls/shmget: Add shmget07 to test SHM_HUGETLB with raw device read

This test exercises hugetlb shared memory functionality rather than the shmget syscall itself. Move this test to testcases/kernel/mem/hugetlb/hugeshmget/ and rename it (e.g. hugeshmget07). Also, replace "raw device" with /dev/zero as /dev/zero is a character device, not a raw device.

runtest/syscalls shmget06 shmget06 · line 1596

Quoted 5 lines
runtest/syscalls +1 -0
@@ -1596,3 +1596,4 @@ shmget06 shmget06
+shmget07 shmget07

Move this entry to runtest/hugetlb alongside the other hugeshmget tests instead of runtest/syscalls.

runtest/syscalls shmget06 shmget06 · line 1597

Quoted 1 line
runtest/syscalls +1 -0
+ * from :file:`/dev/zero` directly into the shared memory region,

Replace :file:/dev/zero with ``/dev/zero``. :file: is not a supported documentation role in LTP.

runtest/syscalls shmget06 shmget06 · line 1599

Quoted 2 lines
runtest/syscalls +2 -0
+#include "tst_test.h"
+#include "tst_hugepage.h"

Remove "tst_hugepage.h" as it is already included by "tst_test.h".

runtest/syscalls shmget06 shmget06

Quoted 1 line
runtest/syscalls +1 -0
+	shmid = SAFE_SHMGET(IPC_PRIVATE, size, SHM_HUGETLB|SHM_R|SHM_W);

Add spaces around the '|' operators to follow kernel coding style.

runtest/syscalls

Quoted 8 lines
runtest/syscalls +8 -0
+	for (i = 0; i < size; i += hpage_size) {
+		TEST(read(raw_fd, shmaddr + i, hpage_size));
+		if (TST_RET != hpage_size) {
+			tst_res(TFAIL | TERRNO, "Can't read full page from raw device!");
+			break;
+		}
+		tst_res(TPASS, "Read full page from raw device");
+	}

Replace manual TEST() and if/else reporting with:
TST_EXP_VAL(read(raw_fd, shmaddr + i, hpage_size), (ssize_t)hpage_size); Also, update the message to refer to /dev/zero instead of "raw device".

Verdict - Needs revision

---
Note:

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.

Regards,
LTP AI Reviewer

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