HWPOISON: Use get_user_page_fast in hwpoison madvise
authorAndi Kleen <andi@firstfloor.org>
Wed, 16 Dec 2009 11:20:00 +0000 (12:20 +0100)
committerAndi Kleen <ak@linux.intel.com>
Wed, 16 Dec 2009 11:20:00 +0000 (12:20 +0100)
The previous version didn't take the mmap_sem before calling gup(),
which is racy.

Use get_user_pages_fast() instead which doesn't need any locks.
This is also faster of course, but then it doesn't really matter
because this is just a testing path.

Based on report from Nick Piggin.
Cc: npiggin@suse.de
Signed-off-by: Andi Kleen <ak@linux.intel.com>
mm/madvise.c

index 6ca34f0cd4aaa74f07dab4208880b20345e423cc..7964e36ba915b20c89afdb23eb23dfef067b40f8 100644 (file)
@@ -230,8 +230,7 @@ static int madvise_hwpoison(unsigned long start, unsigned long end)
                return -EPERM;
        for (; start < end; start += PAGE_SIZE) {
                struct page *p;
-               int ret = get_user_pages(current, current->mm, start, 1,
-                                               0, 0, &p, NULL);
+               int ret = get_user_pages_fast(start, 1, 0, &p);
                if (ret != 1)
                        return ret;
                printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n",