Skip to contentSkip to conversation

Test for memfd_create() syscall with MFD_HUGETLB flag.

PATCH Superseded Vishnu K 2 participants 3 messages Aug 1, 2018 – Aug 9, 2018

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Vishnu K

author
#0 lore raw

PATCH v4 1/1 Test for memfd_create() syscall with MFD_HUGETLB flag.

* memfd_create03: Tests the syscall for the flag MFD_HUGETLB.

* memfd_create04: Tests the syscall for the flags MFD_HUGE_2MB, MFD_HUGE_1GB,... used in conjunction with MFD_HUGETLB flag.

-- major changes from v3 to v4 --

* memfd_create03:

** OR TERRNO with TFAIL for debugging purpose.

** Move helper functions from memfd_create_hugetlb.c to the
main test code.

* memfd_create04:

** Replace huge pages support check using procfs with sysfs.

---
 include/lapi/memfd.h                          |  33 +++
 runtest/syscalls                              |   2 +
 .../kernel/syscalls/memfd_create/.gitignore   |   2 +
 .../syscalls/memfd_create/memfd_create03.c    | 263 ++++++++++++++++++
 .../syscalls/memfd_create/memfd_create04.c    | 105 +++++++
 5 files changed, 405 insertions(+)
 create mode 100644 testcases/kernel/syscalls/memfd_create/memfd_create03.c
 create mode 100644 testcases/kernel/syscalls/memfd_create/memfd_create04.c
include/lapi/memfd.h +33 -0
index 18ed40fc6..12a91f4a9 100644
@@ -24,4 +24,37 @@
 # define MFD_ALLOW_SEALING       0x0002U
 #endif
 
+/* flags for memfd_create(3) and memfd_create(4) */
+#ifndef MFD_HUGETLB
+#define MFD_HUGETLB 0x0004U
+#endif
+
+#ifndef MFD_HUGE_64KB
+#define MFD_HUGE_64KB (16 << 26)
+#endif
+#ifndef MFD_HUGE_512KB
+#define MFD_HUGE_512KB (19 << 26)
+#endif
+#ifndef MFD_HUGE_2MB
+#define MFD_HUGE_2MB (21 << 26)
+#endif
+#ifndef MFD_HUGE_8MB
+#define MFD_HUGE_8MB (23 << 26)
+#endif
+#ifndef MFD_HUGE_16MB
+#define MFD_HUGE_16MB (24 << 26)
+#endif
+#ifndef MFD_HUGE_256MB
+#define MFD_HUGE_256MB (28 << 26)
+#endif
+#ifndef MFD_HUGE_1GB
+#define MFD_HUGE_1GB (30 << 26)
+#endif
+#ifndef MFD_HUGE_2GB
+#define MFD_HUGE_2GB (31 << 26)
+#endif
+#ifndef MFD_HUGE_16GB
+#define MFD_HUGE_16GB (34 << 26)
+#endif
+
 #endif
runtest/syscalls +2 -0
index dc72484cb..24661e2b1 100644
@@ -1481,5 +1481,7 @@ futex_wait_bitset02 futex_wait_bitset02
 
 memfd_create01 memfd_create01
 memfd_create02 memfd_create02
+memfd_create03 memfd_create03
+memfd_create04 memfd_create04
 
 copy_file_range01 copy_file_range01
testcases/kernel/syscalls/memfd_create/.gitignore +2 -0
index 9b20604ab..71b898c34 100644
@@ -1,2 +1,4 @@
 /memfd_create01
 /memfd_create02
+/memfd_create03
+/memfd_create04
\ No newline@end of file
testcases/kernel/syscalls/memfd_create/memfd_create03.c new file +263 -0

263 lines not on this page · raw message

testcases/kernel/syscalls/memfd_create/memfd_create04.c new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH v4 1/1 Test for memfd_create() syscall with MFD_HUGETLB flag.

----- Original Message -----

Quoted 11 lines

* memfd_create03: Tests the syscall for the flag MFD_HUGETLB.

* memfd_create04: Tests the syscall for the flags MFD_HUGE_2MB, MFD_HUGE_1GB,... used in conjunction with MFD_HUGETLB flag.

-- major changes from v3 to v4 --

* memfd_create03:

Quoted 8 lines

** OR TERRNO with TFAIL for debugging purpose.

** Move helper functions from memfd_create_hugetlb.c to the
main test code.

* memfd_create04:

** Replace huge pages support check using procfs with sysfs.

Hi,

+1 for making it simpler (code has been reduced by ~33%).

There is a small problem with setup() in memfd_create03:

# ./memfd_create03
tst_test.c:1017: INFO: Timeout per run is 0h 05m 00s
safe_file_ops.c:220: BROK: Expected 1 conversions got 0 at memfd_create03.c:211

We should check also that "/sys/kernel/mm/hugepages" exists. "/proc/sys/vm/nr_hugepages" exists even on systems which do not support huge pages.

# cat /proc/sys/vm/nr_hugepages
cat: /proc/sys/vm/nr_hugepages: Operation not supported

memfd_create04 is checking for it already, and reports TCONF.

---

Other than that v4 looks OK to me. I'm still looking at testing it on aarch64.

Regards,
Jan

author
#2 lore raw

PATCH v4 1/1 Test for memfd_create() syscall withMFD_HUGETLBflag.

Hi,

We will work on that and update.

Thanks and Regards,
Vishnu K