Commit 1a763615 authored by Jason J. Herne's avatar Jason J. Herne Committed by Linus Torvalds

mm: loosen MADV_NOHUGEPAGE to enable Qemu postcopy on s390

MADV_NOHUGEPAGE processing is too restrictive.  kvm already disables
hugepage but hugepage_madvise() takes the error path when we ask to turn
on the MADV_NOHUGEPAGE bit and the bit is already on.  This causes Qemu's
new postcopy migration feature to fail on s390 because its first action is
to madvise the guest address space as NOHUGEPAGE.  This patch modifies the
code so that the operation succeeds without error now.

For consistency reasons do the same for MADV_HUGEPAGE.
Signed-off-by: default avatarJason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Acked-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7511c3ed
...@@ -2009,7 +2009,7 @@ int hugepage_madvise(struct vm_area_struct *vma, ...@@ -2009,7 +2009,7 @@ int hugepage_madvise(struct vm_area_struct *vma,
/* /*
* Be somewhat over-protective like KSM for now! * Be somewhat over-protective like KSM for now!
*/ */
if (*vm_flags & (VM_HUGEPAGE | VM_NO_THP)) if (*vm_flags & VM_NO_THP)
return -EINVAL; return -EINVAL;
*vm_flags &= ~VM_NOHUGEPAGE; *vm_flags &= ~VM_NOHUGEPAGE;
*vm_flags |= VM_HUGEPAGE; *vm_flags |= VM_HUGEPAGE;
...@@ -2025,7 +2025,7 @@ int hugepage_madvise(struct vm_area_struct *vma, ...@@ -2025,7 +2025,7 @@ int hugepage_madvise(struct vm_area_struct *vma,
/* /*
* Be somewhat over-protective like KSM for now! * Be somewhat over-protective like KSM for now!
*/ */
if (*vm_flags & (VM_NOHUGEPAGE | VM_NO_THP)) if (*vm_flags & VM_NO_THP)
return -EINVAL; return -EINVAL;
*vm_flags &= ~VM_HUGEPAGE; *vm_flags &= ~VM_HUGEPAGE;
*vm_flags |= VM_NOHUGEPAGE; *vm_flags |= VM_NOHUGEPAGE;
......
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