Migrating the libhugetlbfs/testcases/stack_grow_into_huge.c test
PATCH v4 1/1 Migrating the libhugetlbfs/testcases/stack_grow_into_huge.c test
Test Description:On PowerPC, the address space is divided into segments. These segments can contain either huge pages or normal pages, but not both.
All segments are initially set up to map normal pages. When a huge page mapping is created within a set of empty segments, they are "enabled" for huge pages at that time. Once enabled for huge pages, they can not be used again for normal pages for the remaining lifetime of the process.
If the segment immediately preceeding the segment containing the stack is converted to huge pages and the stack is made to grow into the this preceeding segment, some kernels may attempt to map normal pages into the huge page-only segment -- resulting in bugs.
---
v4:
---Addressed the below requested changes
1. Added support for running architecture-specific test cases using the supported_archs member of the tst_test structure.
2. Replaced the exit -1 condition with a simple return statement when there is insufficient memory for the test.
--- runtest/hugetlb | 1 + testcases/kernel/mem/.gitignore | 1 + .../kernel/mem/hugetlb/hugemmap/hugemmap34.c | 138 ++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c
runtest/hugetlb +1 -0
@@ -35,6 +35,7 @@ hugemmap29 hugemmap29 hugemmap30 hugemmap30 hugemmap31 hugemmap31 hugemmap32 hugemmap32 +hugemmap34 hugemmap34 hugemmap05_1 hugemmap05 -m hugemmap05_2 hugemmap05 -s hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
@@ -34,6 +34,7 @@ /hugetlb/hugemmap/hugemmap30 /hugetlb/hugemmap/hugemmap31 /hugetlb/hugemmap/hugemmap32 +/hugetlb/hugemmap/hugemmap34 /hugetlb/hugeshmat/hugeshmat01 /hugetlb/hugeshmat/hugeshmat02 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c new file +138 -0
138 lines not on this page · raw message
Signature · 5 lines
2.43.5 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c line 10
Quoted 4 lines
+ /*\
testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c new file +3
-0+* [Description] +* +* Test Name: stack_grow_into_huge
Drop the test name please, it has no value in the description.
Quoted 31 lines
+ * On PowerPC, the address space is divided into segments. These segments can
+ * contain either huge pages or normal pages, but not both. All segments are
+ * initially set up to map normal pages. When a huge page mapping is created
+ * within a set of empty segments, they are "enabled" for huge pages at that
+ * time. Once enabled for huge pages, they can not be used again for normal
+ * pages for the remaining lifetime of the process.
+ *
+ * If the segment immediately preceeding the segment containing the stack is
+ * converted to huge pages and the stack is made to grow into the this
+ * preceeding segment, some kernels may attempt to map normal pages into the
+ * huge page-only segment -- resulting in bugs.
+ */testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c new file +19
-0+ +#include "hugetlb.h" +#include <errno.h> + +#ifdef __LP64__ +#define STACK_ALLOCATION_SIZE (256*1024*1024) +#else +#define STACK_ALLOCATION_SIZE (16*1024*1024) +#endif +#define PALIGN (p, a) ((void *)LTP_ALIGN((unsigned long)(p), (a))) +#define MNTPOINT "hugetlbfs/" +static int fd =-1 ; +static unsigned long long hpage_size; +static int page_size; + + +void do_child (void *stop_address) +{ +struct rlimit r;
testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c line 52
Quoted 10 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c new file +10
-0+volatile int *x; + +/* corefile from this process is not interesting and limiting +* its size can save a lot of time. '1' is a special value, +* that will also abort dumping via pipe, which by default +* sets limit to RLIM_INFINITY. +*/ + r.rlim_cur =1 ; + r.rlim_max =1 ; +SAFE_SETRLIMIT (RLIMIT_CORE , &r);
We have a library function tst_no_corefile() exactly for this purpose, please use that one instead.
The rest looks good. You can add my Reviewed-by: Cyril Hrubis <[email protected]> with these minor changes added.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp