Commit 6843d925 authored by Xishi Qiu's avatar Xishi Qiu Committed by Greg Kroah-Hartman

mm: fix process accidentally killed by mce because of huge page migration

Based on c8721bbb upstream, but only the
bugfix portion pulled out.

Hi Naoya or Greg,

We found a bug in 3.10.x.
The problem is that we accidentally have a hwpoisoned hugepage in free
hugepage list. It could happend in the the following scenario:

        process A                           process B

  migrate_huge_page
  put_page (old hugepage)
    linked to free hugepage list
                                     hugetlb_fault
                                       hugetlb_no_page
                                         alloc_huge_page
                                           dequeue_huge_page_vma
                                             dequeue_huge_page_node
                                               (steal hwpoisoned hugepage)
  set_page_hwpoison_huge_page
  dequeue_hwpoisoned_huge_page
    (fail to dequeue)

I tested this bug, one process keeps allocating huge page, and I 
use sysfs interface to soft offline a huge page, then received:
"MCE: Killing UCP:2717 due to hardware memory corruption fault at 8200034"

Upstream kernel is free from this bug because of these two commits:

f15bdfa8
mm/memory-failure.c: fix memory leak in successful soft offlining

c8721bbb
mm: memory-hotplug: enable memory hotplug to handle hugepage

The first one, although the problem is about memory leak, this patch
moves unset_migratetype_isolate(), which is important to avoid the race.
The latter is not a bug fix and it's too big, so I rewrite a small one.

The following patch can fix this bug.(please apply f15bdfa8 first)
Signed-off-by: default avatarXishi Qiu <qiuxishi@huawei.com>
Reviewed-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2d9258e4
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/rmap.h> #include <linux/rmap.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/swapops.h> #include <linux/swapops.h>
#include <linux/page-isolation.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -517,9 +518,15 @@ static struct page *dequeue_huge_page_node(struct hstate *h, int nid) ...@@ -517,9 +518,15 @@ static struct page *dequeue_huge_page_node(struct hstate *h, int nid)
{ {
struct page *page; struct page *page;
if (list_empty(&h->hugepage_freelists[nid])) list_for_each_entry(page, &h->hugepage_freelists[nid], lru)
if (!is_migrate_isolate_page(page))
break;
/*
* if 'non-isolated free hugepage' not found on the list,
* the allocation fails.
*/
if (&h->hugepage_freelists[nid] == &page->lru)
return NULL; return NULL;
page = list_entry(h->hugepage_freelists[nid].next, struct page, lru);
list_move(&page->lru, &h->hugepage_activelist); list_move(&page->lru, &h->hugepage_activelist);
set_page_refcounted(page); set_page_refcounted(page);
h->free_huge_pages--; h->free_huge_pages--;
......
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