Skip to contentSkip to conversation

Hugetlb: Migrating libhugetlbfs shm-perms

PATCH Superseded spoorthy s 2 participants 2 messages Sep 11, 2024

lore
Share & tools
lore

spoorthy s

author
#0 lore raw

PATCH v3 1/1 Hugetlb: Migrating libhugetlbfs shm-perms

Test Description: Tests the behavior of shared memory when multiple threads attach to a segment with different permissions.

At one point, reservation accounting of free hugepages between the parent and child processes may become inconsistent during memory operations. The parent creates 4 hugepages and a shared memory segment (size segment_size, permission 0640), attaches it, and initializes four parts with a pattern (0x55), then detaches it. Child processes are created in a loop, each reattaching the segment in read-only mode with SHM_RDONLY, detaching, and exiting. If attach/detach fails or if the reservation accounting of free hugepages doesn't match between parent and child, the test fails. If all child processes exit successfully and accounting matches, the test passes.

Tested and verified the success of test case

-------
Changes in v2:
1)Make check errors are taken care
2)segment_size is not static
3)Added check to compare the free hugepage memory
-------
Changes in v3:
1)Remove redundant variables and conditional checks 2)Cosmetic changes to Description
-------
 runtest/hugetlb                               |  1 + testcases/kernel/mem/.gitignore               |  1 + .../mem/hugetlb/hugeshmat/hugeshmat06.c       | 97 +++++++++++++++++++

 3 files changed, 99 insertions(+)

 create mode 100644 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat06.c

runtest/hugetlb +0 -0
index 299c07ac9..240701b2b 100644
@@ -44,6 +44,7 @@ hugeshmat02 hugeshmat02 -i 5

 hugeshmat03 hugeshmat03 -i 5
 hugeshmat04 hugeshmat04 -i 5
 hugeshmat05 hugeshmat05 -i 5
+hugeshmat06 hugeshmat06

 hugeshmctl01 hugeshmctl01 -i 5
 hugeshmctl02 hugeshmctl02 -i 5

testcases/kernel/mem/.gitignore +0 -0
index c96fe8bfc..4ad1dc313 100644
@@ -39,6 +39,7 @@

 /hugetlb/hugeshmat/hugeshmat03
 /hugetlb/hugeshmat/hugeshmat04
 /hugetlb/hugeshmat/hugeshmat05
+/hugetlb/hugeshmat/hugeshmat06
 /hugetlb/hugeshmctl/hugeshmctl01
 /hugetlb/hugeshmctl/hugeshmctl02
 /hugetlb/hugeshmctl/hugeshmctl03

testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat06.c new file +97 -0

97 lines not on this page · raw message

Signature · 5 lines
2.43.0


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

Hi!

Quoted 14 lines

Test Description: Tests the behavior of shared memory when
 multiple threads attach to a segment with different permissions.

At one point, reservation accounting of free hugepages between the parent and child processes may become inconsistent during memory operations. The parent creates 4 hugepages and a shared memory segment (size segment_size, permission 0640), attaches it, and initializes four parts with a pattern (0x55), then detaches it. Child processes are created in a loop, each reattaching the segment in read-only mode with SHM_RDONLY, detaching, and exiting. If attach/detach fails or if the reservation accounting of free hugepages doesn't match between parent and child, the test fails. If all child processes exit successfully and accounting matches, the test passes.

Quoted 3 lines

Tested and verified the success of test case

Git complains that this patch is corrupted probably because the "scissors" i.e. --- is missing after the Signed-off-by.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp