userfaultfd: Add new test using UFFDIO_CONTINUE
PATCH v3 1/1 userfaultfd: Add new test using UFFDIO_CONTINUE
Add test to exercise UFFDIO_CONTINUE on a shared-memory mapping with UFFD_PAGEFAULT_FLAG_MINOR. The test populates a memfd-backed page, drops only the PTEs with MADV_DONTNEED, verifies that the resulting fault is reported as MINOR, updates the page cache from the handler thread, and resumes execution with UFFDIO_CONTINUE.
--- include/lapi/userfaultfd.h | 1 + runtest/syscalls | 1 + .../kernel/syscalls/userfaultfd/.gitignore | 1 + .../kernel/syscalls/userfaultfd/Makefile | 1 + .../syscalls/userfaultfd/userfaultfd07.c | 152 ++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 testcases/kernel/syscalls/userfaultfd/userfaultfd07.c
include/lapi/userfaultfd.h +1 -0
@@ -171,6 +171,7 @@ struct uffdio_zeropage {#ifndef UFFD_PAGEFAULT_FLAG_MINOR #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9)#define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) +#define UFFD_PAGEFAULT_FLAG_MINOR (1<<2)#define _UFFDIO_CONTINUE (0x07)#define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \
runtest/syscalls +1 -0
@@ -1780,6 +1780,7 @@ userfaultfd03 userfaultfd03 userfaultfd04 userfaultfd04 userfaultfd05 userfaultfd05 userfaultfd06 userfaultfd06 +userfaultfd07 userfaultfd07 ustat01 ustat01 ustat02 ustat02
testcases/kernel/syscalls/userfaultfd/.gitignore +1 -0
@@ -4,3 +4,4 @@ /userfaultfd04 /userfaultfd05 /userfaultfd06 +/userfaultfd07
testcases/kernel/syscalls/userfaultfd/Makefile +1 -0
@@ -17,3 +17,4 @@ userfaultfd03: CFLAGS += -pthread userfaultfd04: CFLAGS += -pthread userfaultfd05: CFLAGS += -pthread userfaultfd06: CFLAGS += -pthread +userfaultfd07: CFLAGS += -pthread
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +152 -0
152 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/2 memfd_create: move sys_memfd_create() to lapi/memfd.h
Add the static inline wrapper to include/lapi/memfd.h and include the required headers so other tests can reuse it.
Also fix some minor issues detected by make check.
--- include/lapi/memfd.h | 8 ++++++++ testcases/kernel/syscalls/memfd_create/memfd_create01.c | 1 - .../kernel/syscalls/memfd_create/memfd_create_common.c | 5 ----- .../kernel/syscalls/memfd_create/memfd_create_common.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)
include/lapi/memfd.h +8 -0
@@ -6,6 +6,9 @@#ifndef LAPI_MEMFD_H__ #define LAPI_MEMFD_H__ +#include "tst_test.h" +#include "lapi/syscalls.h" +/* flags for memfd_create(2) (unsigned int) */ #ifndef MFD_CLOEXEC # define MFD_CLOEXEC 0x0001U
@@ -47,4 +50,9 @@#define MFD_HUGE_16GB (34 << 26)#endif +static inline int sys_memfd_create (const char *name,unsigned int flags) +{ +return tst_syscall (__NR_memfd_create, name, flags); +} +#endif /* LAPI_MEMFD_H__ */
testcases/kernel/syscalls/memfd_create/memfd_create01.c +0 -1
@@ -212,7 +212,6 @@ static void test_share_open(int fd)SAFE_CLOSE (fd2); } - static const struct tcase { int flags; void (*func)(int fd);
testcases/kernel/syscalls/memfd_create/memfd_create_common.c +0 -5
@@ -24,11 +24,6 @@#include "memfd_create_common.h" -int sys_memfd_create (const char *name,unsigned int flags) -{ -return tst_syscall (__NR_memfd_create, name, flags); -} -int check_fallocate (const char *filename,const int lineno,int fd,int mode,off_t offset,off_t len) {
testcases/kernel/syscalls/memfd_create/memfd_create_common.h +1 -1
@@ -50,7 +50,7 @@ check_munmap(__FILE__, __LINE__, (p), (length))#define CHECK_MFD_HAS_SEALS (fd, seals) \ - check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals)); + check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals))#define CHECK_MFD_ADD_SEALS (fd, seals) \ ({int r = SAFE_FCNTL((fd), F_ADD_SEALS, (seals)); \
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 2/2 userfaultfd: Add new test using UFFDIO_CONTINUE
Add test to exercise UFFDIO_CONTINUE on a shared-memory mapping with UFFD_PAGEFAULT_FLAG_MINOR. The test populates a memfd-backed page, drops only the PTEs with MADV_DONTNEED, verifies that the resulting fault is reported as MINOR, updates the page cache from the handler thread, and resumes execution with UFFDIO_CONTINUE.
--- include/lapi/userfaultfd.h | 1 + runtest/syscalls | 1 + .../kernel/syscalls/userfaultfd/.gitignore | 1 + .../kernel/syscalls/userfaultfd/Makefile | 1 + .../syscalls/userfaultfd/userfaultfd07.c | 152 ++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 testcases/kernel/syscalls/userfaultfd/userfaultfd07.c
include/lapi/userfaultfd.h +1 -0
@@ -171,6 +171,7 @@ struct uffdio_zeropage {#ifndef UFFD_PAGEFAULT_FLAG_MINOR #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9)#define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) +#define UFFD_PAGEFAULT_FLAG_MINOR (1<<2)#define _UFFDIO_CONTINUE (0x07)#define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \
runtest/syscalls +1 -0
@@ -1780,6 +1780,7 @@ userfaultfd03 userfaultfd03 userfaultfd04 userfaultfd04 userfaultfd05 userfaultfd05 userfaultfd06 userfaultfd06 +userfaultfd07 userfaultfd07 ustat01 ustat01 ustat02 ustat02
testcases/kernel/syscalls/userfaultfd/.gitignore +1 -0
@@ -4,3 +4,4 @@ /userfaultfd04 /userfaultfd05 /userfaultfd06 +/userfaultfd07
testcases/kernel/syscalls/userfaultfd/Makefile +1 -0
@@ -17,3 +17,4 @@ userfaultfd03: CFLAGS += -pthread userfaultfd04: CFLAGS += -pthread userfaultfd05: CFLAGS += -pthread userfaultfd06: CFLAGS += -pthread +userfaultfd07: CFLAGS += -pthread
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +152 -0
152 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Ricardo,
there must be something wrong with the patches you sent. I see v4 (last one was v2) and patch #2 in a set of 2 patches (but only one is available).
Can you send the correct verion please? I will set the v3 as broken because LTP is not compiling with that one.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
sorry I was confused by the patchwork interface (sigh). All good, I will review the v4.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/2 memfd_create: move sys_memfd_create() to lapi/memfd.h
In reply to Ricardo BrancoAdd the static inline wrapper to include/lapi/memfd.h and include the required headers so other tests can reuse it.
Also fix some minor issues detected by make check.
--- include/lapi/memfd.h | 8 ++++++++ testcases/kernel/syscalls/memfd_create/memfd_create01.c | 1 - .../kernel/syscalls/memfd_create/memfd_create_common.c | 5 ----- .../kernel/syscalls/memfd_create/memfd_create_common.h | 4 +--- 4 files changed, 9 insertions(+), 9 deletions(-)
include/lapi/memfd.h +8 -0
@@ -6,6 +6,9 @@#ifndef LAPI_MEMFD_H__ #define LAPI_MEMFD_H__ +#include "tst_test.h" +#include "lapi/syscalls.h" +/* flags for memfd_create(2) (unsigned int) */ #ifndef MFD_CLOEXEC # define MFD_CLOEXEC 0x0001U
@@ -47,4 +50,9 @@#define MFD_HUGE_16GB (34 << 26)#endif +static inline int sys_memfd_create (const char *name,unsigned int flags) +{ +return tst_syscall (__NR_memfd_create, name, flags); +} +#endif /* LAPI_MEMFD_H__ */
testcases/kernel/syscalls/memfd_create/memfd_create01.c +0 -1
@@ -212,7 +212,6 @@ static void test_share_open(int fd)SAFE_CLOSE (fd2); } - static const struct tcase { int flags; void (*func)(int fd);
testcases/kernel/syscalls/memfd_create/memfd_create_common.c +0 -5
@@ -24,11 +24,6 @@#include "memfd_create_common.h" -int sys_memfd_create (const char *name,unsigned int flags) -{ -return tst_syscall (__NR_memfd_create, name, flags); -} -int check_fallocate (const char *filename,const int lineno,int fd,int mode,off_t offset,off_t len) {
testcases/kernel/syscalls/memfd_create/memfd_create_common.h +1 -3
@@ -50,7 +50,7 @@ check_munmap(__FILE__, __LINE__, (p), (length))#define CHECK_MFD_HAS_SEALS (fd, seals) \ - check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals)); + check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals))#define CHECK_MFD_ADD_SEALS (fd, seals) \ ({int r = SAFE_FCNTL((fd), F_ADD_SEALS, (seals)); \
@@ -101,8 +101,6 @@ int mfd_flags_available(const char *filename, const int lineno,int get_mfd_all_available_flags (const char *filename,const int lineno); -int sys_memfd_create (const char *name,unsigned int flags); -int check_fallocate (const char *filename,const int lineno,int fd,int mode,off_t offset,off_t len); int check_fallocate_fail(const char *filename, const int lineno, int fd,
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 2/2 userfaultfd: Add new test using UFFDIO_CONTINUE
Add test to exercise UFFDIO_CONTINUE on a shared-memory mapping with UFFD_PAGEFAULT_FLAG_MINOR. The test populates a memfd-backed page, drops only the PTEs with MADV_DONTNEED, verifies that the resulting fault is reported as MINOR, updates the page cache from the handler thread, and resumes execution with UFFDIO_CONTINUE.
--- include/lapi/userfaultfd.h | 1 + runtest/syscalls | 1 + .../kernel/syscalls/userfaultfd/.gitignore | 1 + .../kernel/syscalls/userfaultfd/Makefile | 1 + .../syscalls/userfaultfd/userfaultfd07.c | 152 ++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 testcases/kernel/syscalls/userfaultfd/userfaultfd07.c
include/lapi/userfaultfd.h +1 -0
@@ -171,6 +171,7 @@ struct uffdio_zeropage {#ifndef UFFD_PAGEFAULT_FLAG_MINOR #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9)#define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) +#define UFFD_PAGEFAULT_FLAG_MINOR (1<<2)#define _UFFDIO_CONTINUE (0x07)#define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \
runtest/syscalls +1 -0
@@ -1780,6 +1780,7 @@ userfaultfd03 userfaultfd03 userfaultfd04 userfaultfd04 userfaultfd05 userfaultfd05 userfaultfd06 userfaultfd06 +userfaultfd07 userfaultfd07 ustat01 ustat01 ustat02 ustat02
testcases/kernel/syscalls/userfaultfd/.gitignore +1 -0
@@ -4,3 +4,4 @@ /userfaultfd04 /userfaultfd05 /userfaultfd06 +/userfaultfd07
testcases/kernel/syscalls/userfaultfd/Makefile +1 -0
@@ -17,3 +17,4 @@ userfaultfd03: CFLAGS += -pthread userfaultfd04: CFLAGS += -pthread userfaultfd05: CFLAGS += -pthread userfaultfd06: CFLAGS += -pthread +userfaultfd07: CFLAGS += -pthread
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +152 -0
152 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 1/2 memfd_create: move sys_memfd_create() to lapi/memfd.h
In reply to Ricardo BrancoAdd the static inline wrapper to include/lapi/memfd.h and include the required headers so other tests can reuse it.
Also fix some minor issues detected by make check.
--- include/lapi/memfd.h | 8 ++++++++ testcases/kernel/syscalls/memfd_create/memfd_create01.c | 1 - .../kernel/syscalls/memfd_create/memfd_create_common.c | 5 ----- .../kernel/syscalls/memfd_create/memfd_create_common.h | 4 +--- 4 files changed, 9 insertions(+), 9 deletions(-)
include/lapi/memfd.h +8 -0
@@ -6,6 +6,9 @@#ifndef LAPI_MEMFD_H__ #define LAPI_MEMFD_H__ +#include "tst_test.h" +#include "lapi/syscalls.h" +/* flags for memfd_create(2) (unsigned int) */ #ifndef MFD_CLOEXEC # define MFD_CLOEXEC 0x0001U
@@ -47,4 +50,9 @@#define MFD_HUGE_16GB (34 << 26)#endif +static inline int sys_memfd_create (const char *name,unsigned int flags) +{ +return tst_syscall (__NR_memfd_create, name, flags); +} +#endif /* LAPI_MEMFD_H__ */
testcases/kernel/syscalls/memfd_create/memfd_create01.c +0 -1
@@ -212,7 +212,6 @@ static void test_share_open(int fd)SAFE_CLOSE (fd2); } - static const struct tcase { int flags; void (*func)(int fd);
testcases/kernel/syscalls/memfd_create/memfd_create_common.c +0 -5
@@ -24,11 +24,6 @@#include "memfd_create_common.h" -int sys_memfd_create (const char *name,unsigned int flags) -{ -return tst_syscall (__NR_memfd_create, name, flags); -} -int check_fallocate (const char *filename,const int lineno,int fd,int mode,off_t offset,off_t len) {
testcases/kernel/syscalls/memfd_create/memfd_create_common.h +1 -3
@@ -50,7 +50,7 @@ check_munmap(__FILE__, __LINE__, (p), (length))#define CHECK_MFD_HAS_SEALS (fd, seals) \ - check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals)); + check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals))#define CHECK_MFD_ADD_SEALS (fd, seals) \ ({int r = SAFE_FCNTL((fd), F_ADD_SEALS, (seals)); \
@@ -101,8 +101,6 @@ int mfd_flags_available(const char *filename, const int lineno,int get_mfd_all_available_flags (const char *filename,const int lineno); -int sys_memfd_create (const char *name,unsigned int flags); -int check_fallocate (const char *filename,const int lineno,int fd,int mode,off_t offset,off_t len); int check_fallocate_fail(const char *filename, const int lineno, int fd,
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 2/2 userfaultfd: Add new test using UFFDIO_CONTINUE
Add test to exercise UFFDIO_CONTINUE on a shared-memory mapping with UFFD_PAGEFAULT_FLAG_MINOR. The test populates a memfd-backed page, drops only the PTEs with MADV_DONTNEED, verifies that the resulting fault is reported as MINOR, updates the page cache from the handler thread, and resumes execution with UFFDIO_CONTINUE.
--- include/lapi/userfaultfd.h | 1 + runtest/syscalls | 1 + .../kernel/syscalls/userfaultfd/.gitignore | 1 + .../kernel/syscalls/userfaultfd/Makefile | 1 + .../syscalls/userfaultfd/userfaultfd07.c | 157 ++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 testcases/kernel/syscalls/userfaultfd/userfaultfd07.c
include/lapi/userfaultfd.h +1 -0
@@ -171,6 +171,7 @@ struct uffdio_zeropage {#ifndef UFFD_PAGEFAULT_FLAG_MINOR #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9)#define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) +#define UFFD_PAGEFAULT_FLAG_MINOR (1<<2)#define _UFFDIO_CONTINUE (0x07)#define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \
runtest/syscalls +1 -0
@@ -1781,6 +1781,7 @@ userfaultfd03 userfaultfd03 userfaultfd04 userfaultfd04 userfaultfd05 userfaultfd05 userfaultfd06 userfaultfd06 +userfaultfd07 userfaultfd07 ustat01 ustat01 ustat02 ustat02
testcases/kernel/syscalls/userfaultfd/.gitignore +1 -0
@@ -4,3 +4,4 @@ /userfaultfd04 /userfaultfd05 /userfaultfd06 +/userfaultfd07
testcases/kernel/syscalls/userfaultfd/Makefile +1 -0
@@ -17,3 +17,4 @@ userfaultfd03: CFLAGS += -pthread userfaultfd04: CFLAGS += -pthread userfaultfd05: CFLAGS += -pthread userfaultfd06: CFLAGS += -pthread +userfaultfd07: CFLAGS += -pthread
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +157 -0
157 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Ricardo,
for some reasons we didn't receive the email from the review agent, probably because agent was still work-in-progress when we received your email. Please take a look at:
https://github.com/linux-test-project/ltp-agent/actions/runs/24280634858/job/70901877922
it spotted a couple of issues.
regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 8 lines
Hi Ricardo,
for some reasons we didn't receive the email from the review agent, probably because agent was still work-in-progress when we received your email. Please take a look at:
https://github.com/linux-test-project/ltp-agent/actions/runs/24280634858/job/70901877922
Quoted 7 lines
it spotted a couple of issues.
regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Sorry I was reading the wrong message. Please ignore this comment. The patch LGTM.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 11 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +11
-0+static void *handle_thread(void *arg LTP_ATTRIBUTE_UNUSED) +{ +static struct uffd_msg msg; +struct uffdio_continue uffdio_continue = {}; +struct pollfd pollfd; +int nready; +char z ='Z' ; + + pollfd.fd = uffd; + pollfd.events =POLLIN ; + nready =poll (&pollfd,1 ,-1 );
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c line 83
Quoted 10 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +10
-0+if (nready ==-1 ) +tst_brk (TBROK |TERRNO ,"Error on poll" ); + +SAFE_READ (1 , uffd, &msg,sizeof (msg)); + +if (msg.event !=UFFD_EVENT_PAGEFAULT ) +tst_brk (TFAIL ,"Received unexpected UFFD_EVENT %d" , msg.event); + +if (!(msg.arg.pagefault.flags &UFFD_PAGEFAULT_FLAG_MINOR )) { + tst_brk(TBROK, "expected MINOR fault, got flags=0x%llx",
^ TFAIL
This is clearly a test assertion and thus a test failure.
Quoted 62 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +62
-0+ (unsigned long long)msg.arg.pagefault.flags); + } + +/* Update the shmem page in page cache before resuming the fault. */ +SAFE_PWRITE (1 , memfd, &z,1 ,0 ); + + uffdio_continue.range.start = + msg.arg.pagefault.address & ~((unsigned long )page_size -1 ); + uffdio_continue.range.len = page_size; + +SAFE_IOCTL (uffd,UFFDIO_CONTINUE , &uffdio_continue); + +SAFE_CLOSE (uffd); +return NULL ; +} + +static void run (void ) +{ +pthread_t thr; +struct uffdio_api uffdio_api = {}; +struct uffdio_register uffdio_register; + +set_pages (); + + uffd =SAFE_USERFAULTFD (O_CLOEXEC |O_NONBLOCK , true); + uffdio_api.api =UFFD_API ; + uffdio_api.features =0 ; +SAFE_IOCTL (uffd,UFFDIO_API , &uffdio_api); +if (!(uffdio_api.features &UFFD_FEATURE_MINOR_SHMEM )) +tst_brk (TCONF ,"UFFD_FEATURE_MINOR_SHMEM not supported" ); +SAFE_CLOSE (uffd); + + uffd =SAFE_USERFAULTFD (O_CLOEXEC |O_NONBLOCK , false); + + uffdio_api.api =UFFD_API ; + uffdio_api.features =UFFD_FEATURE_MINOR_SHMEM ; + +SAFE_IOCTL (uffd,UFFDIO_API , &uffdio_api); + + uffdio_register.range.start = (unsigned long ) page; + uffdio_register.range.len = page_size; + uffdio_register.mode =UFFDIO_REGISTER_MODE_MINOR ; + +SAFE_IOCTL (uffd,UFFDIO_REGISTER , &uffdio_register); + +/* +* Drop PTEs while retaining the cached shmem page so the next access +* faults in MINOR mode. +*/ +if (madvise (page, page_size,MADV_DONTNEED ) <0 ) +tst_brk (TBROK |TERRNO ,"madvise MADV_DONTNEED failed" ); + +SAFE_PTHREAD_CREATE (&thr,NULL , (void *) handle_thread,NULL ); + +char c = page[0 ]; + +if (c =='Z' ) +tst_res (TPASS ,"Pagefault handled via UFFDIO_CONTINUE" ); +else +tst_res (TFAIL ,"pagefault not handled via UFFDIO_CONTINUE, got '%c'" , c); + +SAFE_PTHREAD_JOIN (thr,NULL );
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c line 155
Quoted 10 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +10
-0+reset_pages (); +} + +static struct tst_test test = { + .test_all = run, +/* +* UFFDIO_CONTINUE is available since 5.13 but +* UFFD_FEATURE_MINOR_SHMEM appeared in 5.14 +*/ + .min_kver ="5.14" ,
Should we do a runtime check in the test setup here as well?
Quoted 8 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +2
-0+ .cleanup = reset_pages, +};Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 49 lines · Cyril Hrubis
Quoted 49 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +49
-0+static void run (void ) +{ +pthread_t thr; +struct uffdio_api uffdio_api = {}; +struct uffdio_register uffdio_register; + +set_pages (); + + uffd =SAFE_USERFAULTFD (O_CLOEXEC |O_NONBLOCK , true); + uffdio_api.api =UFFD_API ; + uffdio_api.features =0 ; +SAFE_IOCTL (uffd,UFFDIO_API , &uffdio_api); +if (!(uffdio_api.features &UFFD_FEATURE_MINOR_SHMEM )) +tst_brk (TCONF ,"UFFD_FEATURE_MINOR_SHMEM not supported" ); +SAFE_CLOSE (uffd); + + uffd =SAFE_USERFAULTFD (O_CLOEXEC |O_NONBLOCK , false); + + uffdio_api.api =UFFD_API ; + uffdio_api.features =UFFD_FEATURE_MINOR_SHMEM ; + +SAFE_IOCTL (uffd,UFFDIO_API , &uffdio_api); + + uffdio_register.range.start = (unsigned long ) page; + uffdio_register.range.len = page_size; + uffdio_register.mode =UFFDIO_REGISTER_MODE_MINOR ; + +SAFE_IOCTL (uffd,UFFDIO_REGISTER , &uffdio_register); + +/* +* Drop PTEs while retaining the cached shmem page so the next access +* faults in MINOR mode. +*/ +if (madvise (page, page_size,MADV_DONTNEED ) <0 ) +tst_brk (TBROK |TERRNO ,"madvise MADV_DONTNEED failed" ); + +SAFE_PTHREAD_CREATE (&thr,NULL , (void *) handle_thread,NULL ); + +char c = page[0 ]; + +if (c =='Z' ) +tst_res (TPASS ,"Pagefault handled via UFFDIO_CONTINUE" ); +else +tst_res (TFAIL ,"pagefault not handled via UFFDIO_CONTINUE, got '%c'" , c); + +SAFE_PTHREAD_JOIN (thr,NULL ); +reset_pages (); +} +
Quoted 8 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c line 155
Quoted 7 lines
testcases/kernel/syscalls/userfaultfd/userfaultfd07.c new file +7
-0+static struct tst_test test = { + .test_all = run, +/* +* UFFDIO_CONTINUE is available since 5.13 but +* UFFD_FEATURE_MINOR_SHMEM appeared in 5.14 +*/ + .min_kver ="5.14" ,Should we do a runtime check in the test setup here as well?
We're checking for UFFD_FEATURE_MINOR_SHMEM it the 2 step handshake.
Cheers,
R
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 3 lines
Quoted 1 line
Should we do a runtime check in the test setup here as well?
We're checking for UFFD_FEATURE_MINOR_SHMEM it the 2 step handshake.
Yes, but we are moving the code into a macro and test setup in the other tests we should do so here as well, but that would require the fix to be commited before this test.
So we either make this test dependent on the fix patch or the other way make the fix patch dependent on this one and fix all tests in it.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] memfd_create: move sys_memfd_create() to lapi/memfd.h
In reply to Ricardo BrancoHi Ricardo,
our agent completed the review of the patch.
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.
--- [PATCH 1/2] ---
Quoted 6 lines · Ricardo Branco
memfd_create: movesys_memfd_create()tolapi/memfd.hAdd the static inline wrapper to
include/lapi/memfd.hand include the required headers so other tests can reuse it.Also fix some minor issues detected by make check.
The commit bundles two logical changes: the main refactoring (moving sys_memfd_create() to lapi/memfd.h) and unrelated minor fixes (blank line in memfd_create01.c, trailing semicolon in CHECK_MFD_HAS_SEALS). Please split them into separate commits.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] memfd_create: move sys_memfd_create() to lapi/memfd.h
Hi!
Quoted 11 lines
Quoted 6 lines
memfd_create: movesys_memfd_create()tolapi/memfd.hAdd the static inline wrapper to
include/lapi/memfd.hand include the required headers so other tests can reuse it.Also fix some minor issues detected by make check.
The commit bundles two logical changes: the main refactoring (moving
sys_memfd_create()tolapi/memfd.h) and unrelated minor fixes (blank line inmemfd_create01.c, trailing semicolon inCHECK_MFD_HAS_SEALS). Please split them into separate commits.
In this case it's a single semicolon removal, so I would let it as it is.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v6 1/2] memfd_create: move sys_memfd_create() to lapi/memfd.h
In reply to Ricardo BrancoHi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp