Skip to contentSkip to conversation

Patch "drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration" has been added to the 3.10-stable tree

PATCH [email protected] 1 participant 1 message Feb 24, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration

to the 3.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
drivers-scsi-sg.c-mark-vma-as-vm_io-to-prevent-migration.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 461c7fa126794157484dca48e88effa4963e3af3 Mon Sep 17 00:00:00 2001

From: "Kirill A. Shutemov" <[email protected]>
Date: Tue, 2 Feb 2016 16:57:35 -0800
Subject: drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration

From: Kirill A. Shutemov <[email protected]>

commit 461c7fa126794157484dca48e88effa4963e3af3 upstream.

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.

Cc Doug Gilbert <[email protected]>
Cc David Rientjes <[email protected]>
Cc Naoya Horiguchi <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Shiraz Hashim <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Sasha Levin <[email protected]>
Cc syzkaller <[email protected]>
Cc Kostya Serebryany <[email protected]>
Cc Alexander Potapenko <[email protected]>
Cc James Bottomley <[email protected]>
---
 drivers/scsi/sg.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sg.c +1 -1
@@ -1258,7 +1258,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;

Patches currently in stable-queue which might be from [email protected] are

queue-3.10/drivers-scsi-sg.c-mark-vma-as-vm_io-to-prevent-migration.patch