提交 244969a3 编写于 作者: O Oscar Salvador 提交者: Yang Yingliang

mm,hwpoison: drain pcplists before bailing out for non-buddy zero-refcount page

mainline inclusion
from linux-v5.11-rc1
commit 17e395b6
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4LE22
CVE: NA

--------------------------------

A page with 0-refcount and !PageBuddy could perfectly be a pcppage.
Currently, we bail out with an error if we encounter such a page, meaning
that we do not handle pcppages neither from hard-offline nor from
soft-offline path.

Fix this by draining pcplists whenever we find this kind of page and retry
the check again.  It might be that pcplists have been spilled into the
buddy allocator and so we can handle it.
Signed-off-by: NOscar Salvador <osalvador@suse.de>
Acked-by: NNaoya Horiguchi <naoya.horiguchi@nec.com>
Acked-by: NVlastimil Babka <vbabka@suse.cz>
Signed-off-by: NMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 24f70c68
......@@ -953,13 +953,13 @@ static int page_action(struct page_state *ps, struct page *p,
}
/**
* get_hwpoison_page() - Get refcount for memory error handling:
* __get_hwpoison_page() - Get refcount for memory error handling:
* @page: raw error page (hit by memory error)
*
* Return: return 0 if failed to grab the refcount, otherwise true (some
* non-zero value.)
*/
int get_hwpoison_page(struct page *page)
static int __get_hwpoison_page(struct page *page)
{
struct page *head = compound_head(page);
......@@ -988,6 +988,26 @@ int get_hwpoison_page(struct page *page)
return 0;
}
int get_hwpoison_page(struct page *p)
{
int ret;
bool drained = false;
retry:
ret = __get_hwpoison_page(p);
if (!ret && !is_free_buddy_page(p) && !page_count(p) && !drained) {
/*
* The page might be in a pcplist, so try to drain those
* and see if we are lucky.
*/
drain_all_pages(page_zone(p));
drained = true;
goto retry;
}
return ret;
}
EXPORT_SYMBOL_GPL(get_hwpoison_page);
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册