mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-26 20:40:24 +09:00
FROMGIT: userfaultfd/selftests: exercise minor fault handling shmem support
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Link: https://lkml.kernel.org/r/20210302000133.272579-6-axelrasmussen@google.com Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Brian Geffon <bgeffon@google.com> Cc: Cannon Matthews <cannonmatthews@google.com> Cc: David Rientjes <rientjes@google.com> Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: Joe Perches <joe@perches.com> Cc: Lokesh Gidra <lokeshgidra@google.com> Cc: Michel Lespinasse <walken@google.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Mina Almasry <almasrymina@google.com> Cc: Oliver Upton <oupton@google.com> Cc: Peter Xu <peterx@redhat.com> Cc: Shaohua Li <shli@fb.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Wang Qing <wangqing@vivo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> (cherry picked from commit 01d5af3a0bc027d51d729cefe3105c7054182df7 https: //git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm) Link: https://lore.kernel.org/patchwork/patch/1388148/ Signed-off-by: Lokesh Gidra <lokeshgidra@google.com> Bug: 160737021 Bug: 169683130 Change-Id: I545c6b7058f59fe5bc21d2dd37202209253f1a92
This commit is contained in:
committed by
Todd Kjos
parent
91b66856b8
commit
2039d96cb7
@@ -1422,7 +1422,7 @@ static int userfaultfd_minor_test(void)
|
||||
void *expected_page;
|
||||
char c;
|
||||
struct uffd_stats stats = { 0 };
|
||||
uint64_t features = UFFD_FEATURE_MINOR_HUGETLBFS;
|
||||
uint64_t req_features, features_out;
|
||||
|
||||
if (!test_uffdio_minor)
|
||||
return 0;
|
||||
@@ -1430,10 +1430,18 @@ static int userfaultfd_minor_test(void)
|
||||
printf("testing minor faults: ");
|
||||
fflush(stdout);
|
||||
|
||||
if (uffd_test_ctx_clear() || uffd_test_ctx_init_ext(&features))
|
||||
if (test_type == TEST_HUGETLB)
|
||||
req_features = UFFD_FEATURE_MINOR_HUGETLBFS;
|
||||
else if (test_type == TEST_SHMEM)
|
||||
req_features = UFFD_FEATURE_MINOR_SHMEM;
|
||||
else
|
||||
return 1;
|
||||
/* If kernel reports the feature isn't supported, skip the test. */
|
||||
if (!(features & UFFD_FEATURE_MINOR_HUGETLBFS)) {
|
||||
|
||||
features_out = req_features;
|
||||
if (uffd_test_ctx_clear() || uffd_test_ctx_init_ext(&features_out))
|
||||
return 1;
|
||||
/* If kernel reports required features aren't supported, skip test. */
|
||||
if ((features_out & req_features) != req_features) {
|
||||
printf("skipping test due to lack of feature support\n");
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
@@ -1443,7 +1451,7 @@ static int userfaultfd_minor_test(void)
|
||||
uffdio_register.range.len = nr_pages * page_size;
|
||||
uffdio_register.mode = UFFDIO_REGISTER_MODE_MINOR;
|
||||
if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register)) {
|
||||
fprintf(stderr, "register failure\n");
|
||||
perror("register failure");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1705,6 +1713,7 @@ static void set_test_type(const char *type)
|
||||
map_shared = true;
|
||||
test_type = TEST_SHMEM;
|
||||
uffd_test_ops = &shmem_uffd_test_ops;
|
||||
test_uffdio_minor = true;
|
||||
} else {
|
||||
fprintf(stderr, "Unknown test type: %s\n", type); exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user