[patch 10/18] drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration
From: akpm@linux-foundation.org
Date: 2016-02-03 00:57:36
From: "Kirill A. Shutemov" <redacted>
Subject: drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration
Reduced testcase:
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <numaif.h>
#define SIZE 0x2000
int main()
{
int fd;
void *p;
fd = open("/dev/sg0", O_RDWR);
p = mmap(NULL, SIZE, PROT_EXEC, MAP_PRIVATE | MAP_LOCKED, fd, 0);
mbind(p, SIZE, 0, NULL, 0, MPOL_MF_MOVE);
return 0;
}
We shouldn't try to migrate pages in sg VMA as we don't have a way to
update Sg_scatter_hold::pages accordingly from mm core.
Let's mark the VMA as VM_IO to indicate to mm core that the VMA is
not migratable.
Signed-off-by: Kirill A. Shutemov <redacted>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Acked-by: Vlastimil Babka <redacted>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Naoya Horiguchi <redacted>
Cc: "Kirill A. Shutemov" <redacted>
Cc: Shiraz Hashim <redacted>
Cc: Hugh Dickins <hughd@google.com>
Cc: Sasha Levin <redacted>
Cc: syzkaller <redacted>
Cc: Kostya Serebryany <redacted>
Cc: Alexander Potapenko <glider@google.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: <redacted>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/scsi/sg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -puN drivers/scsi/sg.c~drivers-scsi-sgc-mark-vma-as-vm_io-to-prevent-migration drivers/scsi/sg.c--- a/drivers/scsi/sg.c~drivers-scsi-sgc-mark-vma-as-vm_io-to-prevent-migration
+++ a/drivers/scsi/sg.c@@ -1261,7 +1261,7 @@ sg_mmap(struct file *filp, struct vm_are } sfp->mmap_called = 1; - vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; + vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP; vma->vm_private_data = sfp; vma->vm_ops = &sg_mmap_vm_ops; return 0;
_