hugetlb: add new testcase hugeshmat05.c
PATCH v3 1/1 hugetlb: add new testcase hugeshmat05.c
shmget()/shmat() fails to allocate huge pages shared memory segment with EINVAL if its size is not in the range [ N*HUGE_PAGE_SIZE - 4095, N*HUGE_PAGE_SIZE ]. This is a problem in the memory segment size round up algorithm. The requested size is rounded up to PAGE_SIZE (4096), but if this roundup does not match HUGE_PAGE_SIZE (2Mb) boundary - the allocation fails.
This bug is present in all RHEL6 versions, but not in RHEL7. It looks like this was fixed in mainstream kernel > v3.3 by the following patches:
091d0d5 shm: fix null pointer deref when userspace specifies invalid hugepage size af73e4d hugetlbfs: fix mmap failure in unaligned size request
42d7395 mm: support more pagesizes for MAP_HUGETLB/SHM_HUGETLB 40716e2 hugetlbfs: fix alignment of huge page requests
---
Notes:
v2 --> v3
- remove the redundant code comments
- set the test sizes in array tst_sizes[]
runtest/hugetlb | 1 + testcases/kernel/mem/.gitignore | 1 + .../kernel/mem/hugetlb/hugeshmat/hugeshmat05.c | 135 +++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c
runtest/hugetlb +1 -0
@@ -10,6 +10,7 @@ hugeshmat01 hugeshmat01 -i 5 hugeshmat02 hugeshmat02 -i 5 hugeshmat03 hugeshmat03 -i 5 hugeshmat04 hugeshmat04 -i 5 +hugeshmat05 hugeshmat05 -i 5 hugeshmctl01 hugeshmctl01 -i 5 hugeshmctl02 hugeshmctl02 -i 5
testcases/kernel/mem/.gitignore +1 -0
@@ -7,6 +7,7 @@ /hugetlb/hugeshmat/hugeshmat02 /hugetlb/hugeshmat/hugeshmat03 /hugetlb/hugeshmat/hugeshmat04 +/hugetlb/hugeshmat/hugeshmat05 /hugetlb/hugeshmctl/hugeshmctl01 /hugetlb/hugeshmctl/hugeshmctl02 /hugetlb/hugeshmctl/hugeshmctl03
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Alexey Kodanev
AppliedPATCH v3 1/1 hugetlb: add new testcase hugeshmat05.c
Hi,
Quoted 6 lines · Li Wang
shmget()/shmat() fails to allocate huge pages shared memory segment with EINVAL if its size is not in the range [ N*HUGE_PAGE_SIZE - 4095, N*HUGE_PAGE_SIZE ]. This is a problem in the memory segment size round up algorithm. The requested size is rounded up to
PAGE_SIZE(4096), but if this roundup does not matchHUGE_PAGE_SIZE(2Mb) boundary - the allocation fails.
Applied, thanks!
Also fixed some style warns and errors:
ERROR: need consistent spacing around '-' (ctx:WxV)
#177: FILE: testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c:119:
+ N * hpage_size - page_size -1,
ERROR: space required before the open parenthesis '(' #185: FILE: testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c:127:
+ for(i = 0; i < ARRAY_SIZE(tst_sizes); ++i)
Thanks,
Alexey