@@ -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);
}
@@ -653,6 +661,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 +1095,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 +1670,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);
}