Commit aa0d2721 authored by Mike Rapoport's avatar Mike Rapoport Committed by Linus Torvalds

userfaultfd: non-cooperative: selftest: add ufd parameter to copy_page

With future addition of event tests, copy_page will be called with
different userfault file descriptors

Link: http://lkml.kernel.org/r/20161216144821.5183-40-aarcange@redhat.comSigned-off-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Michael Rapoport <RAPOPORT@il.ibm.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6228b8f2
...@@ -317,7 +317,7 @@ static void *locking_thread(void *arg) ...@@ -317,7 +317,7 @@ static void *locking_thread(void *arg)
return NULL; return NULL;
} }
static int copy_page(unsigned long offset) static int copy_page(int ufd, unsigned long offset)
{ {
struct uffdio_copy uffdio_copy; struct uffdio_copy uffdio_copy;
...@@ -329,7 +329,7 @@ static int copy_page(unsigned long offset) ...@@ -329,7 +329,7 @@ static int copy_page(unsigned long offset)
uffdio_copy.len = page_size; uffdio_copy.len = page_size;
uffdio_copy.mode = 0; uffdio_copy.mode = 0;
uffdio_copy.copy = 0; uffdio_copy.copy = 0;
if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy)) { if (ioctl(ufd, UFFDIO_COPY, &uffdio_copy)) {
/* real retval in ufdio_copy.copy */ /* real retval in ufdio_copy.copy */
if (uffdio_copy.copy != -EEXIST) if (uffdio_copy.copy != -EEXIST)
fprintf(stderr, "UFFDIO_COPY error %Ld\n", fprintf(stderr, "UFFDIO_COPY error %Ld\n",
...@@ -386,7 +386,7 @@ static void *uffd_poll_thread(void *arg) ...@@ -386,7 +386,7 @@ static void *uffd_poll_thread(void *arg)
offset = (char *)(unsigned long)msg.arg.pagefault.address - offset = (char *)(unsigned long)msg.arg.pagefault.address -
area_dst; area_dst;
offset &= ~(page_size-1); offset &= ~(page_size-1);
if (copy_page(offset)) if (copy_page(uffd, offset))
userfaults++; userfaults++;
} }
return (void *)userfaults; return (void *)userfaults;
...@@ -424,7 +424,7 @@ static void *uffd_read_thread(void *arg) ...@@ -424,7 +424,7 @@ static void *uffd_read_thread(void *arg)
offset = (char *)(unsigned long)msg.arg.pagefault.address - offset = (char *)(unsigned long)msg.arg.pagefault.address -
area_dst; area_dst;
offset &= ~(page_size-1); offset &= ~(page_size-1);
if (copy_page(offset)) if (copy_page(uffd, offset))
(*this_cpu_userfaults)++; (*this_cpu_userfaults)++;
} }
return (void *)NULL; return (void *)NULL;
...@@ -438,7 +438,7 @@ static void *background_thread(void *arg) ...@@ -438,7 +438,7 @@ static void *background_thread(void *arg)
for (page_nr = cpu * nr_pages_per_cpu; for (page_nr = cpu * nr_pages_per_cpu;
page_nr < (cpu+1) * nr_pages_per_cpu; page_nr < (cpu+1) * nr_pages_per_cpu;
page_nr++) page_nr++)
copy_page(page_nr * page_size); copy_page(uffd, page_nr * page_size);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment