@@ -120,18 +120,17 @@ run_test ./gup_test -a
# Dump pages 0, 19, and 4096, using pin_user_pages:
run_test ./gup_test -ct -F 0x1 0 19 0x1000
-run_test ./userfaultfd anon 20 16
-run_test ./userfaultfd anon:dev 20 16
-# Hugetlb tests require source and destination huge pages. Pass in half the
-# size ($half_ufd_size_MB), which is used for *each*.
-run_test ./userfaultfd hugetlb "$half_ufd_size_MB" 32
-run_test ./userfaultfd hugetlb:dev "$half_ufd_size_MB" 32
-run_test ./userfaultfd hugetlb_shared "$half_ufd_size_MB" 32 "$mnt"/uffd-test
-rm -f "$mnt"/uffd-test
-run_test ./userfaultfd hugetlb_shared:dev "$half_ufd_size_MB" 32 "$mnt"/uffd-test
-rm -f "$mnt"/uffd-test
-run_test ./userfaultfd shmem 20 16
-run_test ./userfaultfd shmem:dev 20 16
+uffd_mods=("" ":dev" ":access_likely" ":access_likely:write_likely" ":write_likely")
+
+for mod in "${uffd_mods[@]}"; do
+ run_test ./userfaultfd anon${mod} 20 16
+ # Hugetlb tests require source and destination huge pages. Pass in half the
+ # size ($half_ufd_size_MB), which is used for *each*.
+ run_test ./userfaultfd hugetlb${mod} "$half_ufd_size_MB" 32
+ run_test ./userfaultfd hugetlb_shared${mod} "$half_ufd_size_MB" 32 "$mnt"/uffd-test
+ rm -f "$mnt"/uffd-test
+ run_test ./userfaultfd shmem${mod} 20 16
+done
#cleanup
umount "$mnt"
@@ -88,6 +88,8 @@ static volatile bool test_uffdio_zeropage_eexist = true;
static bool test_uffdio_wp = true;
/* Whether to test uffd minor faults */
static bool test_uffdio_minor = false;
+static bool test_access_likely;
+static bool test_write_likely;
static bool map_shared;
static int shm_fd;
@@ -550,6 +552,12 @@ static void wp_range(int ufd, __u64 start, __u64 len, bool wp)
/* Undo write-protect, do wakeup after that */
prms.mode = wp ? UFFDIO_WRITEPROTECT_MODE_WP : 0;
+ if (test_access_likely)
+ prms.mode |= UFFDIO_WRITEPROTECT_MODE_ACCESS_LIKELY;
+
+ if (test_write_likely)
+ prms.mode |= UFFDIO_WRITEPROTECT_MODE_WRITE_LIKELY;
+
if (ioctl(ufd, UFFDIO_WRITEPROTECT, &prms))
err("clear WP failed: address=0x%"PRIx64, (uint64_t)start);
}
@@ -563,6 +571,12 @@ static void continue_range(int ufd, __u64 start, __u64 len)
req.range.len = len;
req.mode = 0;
+ if (test_access_likely)
+ req.mode |= UFFDIO_CONTINUE_MODE_ACCESS_LIKELY;
+
+ if (test_write_likely)
+ req.mode |= UFFDIO_CONTINUE_MODE_WRITE_LIKELY;
+
if (ioctl(ufd, UFFDIO_CONTINUE, &req))
err("UFFDIO_CONTINUE failed for address 0x%" PRIx64,
(uint64_t)start);
@@ -653,6 +667,13 @@ static int __copy_page(int ufd, unsigned long offset, bool retry)
uffdio_copy.mode = UFFDIO_COPY_MODE_WP;
else
uffdio_copy.mode = 0;
+
+ if (test_access_likely)
+ uffdio_copy.mode |= UFFDIO_COPY_MODE_ACCESS_LIKELY;
+
+ if (test_write_likely)
+ uffdio_copy.mode |= UFFDIO_COPY_MODE_WRITE_LIKELY;
+
uffdio_copy.copy = 0;
if (ioctl(ufd, UFFDIO_COPY, &uffdio_copy)) {
/* real retval in ufdio_copy.copy */
@@ -1080,6 +1101,13 @@ static int __uffdio_zeropage(int ufd, unsigned long offset, bool retry)
uffdio_zeropage.range.start = (unsigned long) area_dst + offset;
uffdio_zeropage.range.len = page_size;
uffdio_zeropage.mode = 0;
+
+ if (test_access_likely)
+ uffdio_zeropage.mode |= UFFDIO_ZEROPAGE_MODE_ACCESS_LIKELY;
+
+ if (test_write_likely)
+ uffdio_zeropage.mode |= UFFDIO_ZEROPAGE_MODE_WRITE_LIKELY;
+
ret = ioctl(ufd, UFFDIO_ZEROPAGE, &uffdio_zeropage);
res = uffdio_zeropage.zeropage;
if (ret) {
@@ -1648,6 +1676,10 @@ static void parse_test_type_arg(const char *raw_type)
set_test_type(token);
else if (!strcmp(token, "dev"))
test_dev_userfaultfd = true;
+ else if (!strcmp(token, "access_likely"))
+ test_access_likely = true;
+ else if (!strcmp(token, "write_likely"))
+ test_write_likely = true;
else
err("unrecognized test mod '%s'", token);
}