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

userfaultfd: report UFFDIO_ZEROPAGE as available for shmem VMAs

Now when shmem VMAs can be filled with zero page via userfaultfd we can
report that UFFDIO_ZEROPAGE is available for those VMAs

Link: http://lkml.kernel.org/r/1497939652-16528-7-git-send-email-rppt@linux.vnet.ibm.comSigned-off-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8fb44e54
...@@ -1194,7 +1194,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, ...@@ -1194,7 +1194,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
struct uffdio_register __user *user_uffdio_register; struct uffdio_register __user *user_uffdio_register;
unsigned long vm_flags, new_flags; unsigned long vm_flags, new_flags;
bool found; bool found;
bool non_anon_pages; bool basic_ioctls;
unsigned long start, end, vma_end; unsigned long start, end, vma_end;
user_uffdio_register = (struct uffdio_register __user *) arg; user_uffdio_register = (struct uffdio_register __user *) arg;
...@@ -1260,7 +1260,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, ...@@ -1260,7 +1260,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
* Search for not compatible vmas. * Search for not compatible vmas.
*/ */
found = false; found = false;
non_anon_pages = false; basic_ioctls = false;
for (cur = vma; cur && cur->vm_start < end; cur = cur->vm_next) { for (cur = vma; cur && cur->vm_start < end; cur = cur->vm_next) {
cond_resched(); cond_resched();
...@@ -1299,8 +1299,8 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, ...@@ -1299,8 +1299,8 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
/* /*
* Note vmas containing huge pages * Note vmas containing huge pages
*/ */
if (is_vm_hugetlb_page(cur) || vma_is_shmem(cur)) if (is_vm_hugetlb_page(cur))
non_anon_pages = true; basic_ioctls = true;
found = true; found = true;
} }
...@@ -1371,7 +1371,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, ...@@ -1371,7 +1371,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
* userland which ioctls methods are guaranteed to * userland which ioctls methods are guaranteed to
* succeed on this range. * succeed on this range.
*/ */
if (put_user(non_anon_pages ? UFFD_API_RANGE_IOCTLS_BASIC : if (put_user(basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC :
UFFD_API_RANGE_IOCTLS, UFFD_API_RANGE_IOCTLS,
&user_uffdio_register->ioctls)) &user_uffdio_register->ioctls))
ret = -EFAULT; ret = -EFAULT;
......
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