mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
mm, hwpoison: use __PageMovable() to detect non-lru movable pages
It's more recommended to use __PageMovable() to detect non-lru movable pages. We can avoid bumping page refcnt via isolate_movable_page() for the isolated lru pages. Also if pages become PageLRU just after they're checked but before trying to isolate them, isolate_lru_page() will be called to do the right work. [linmiaohe@huawei.com: fixes per Naoya Horiguchi] Link: https://lkml.kernel.org/r/1f7ee86e-7d28-0d8c-e0de-b7a5a94519e8@huawei.com Link: https://lkml.kernel.org/r/20220830123604.25763-3-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Cc: Naoya Horiguchi <naoya.horiguchi@nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
2fe62e2226
commit
da29499124
@ -2407,24 +2407,26 @@ EXPORT_SYMBOL(unpoison_memory);
|
||||
static bool isolate_page(struct page *page, struct list_head *pagelist)
|
||||
{
|
||||
bool isolated = false;
|
||||
bool lru = PageLRU(page);
|
||||
|
||||
if (PageHuge(page)) {
|
||||
isolated = !isolate_hugetlb(page, pagelist);
|
||||
} else {
|
||||
bool lru = !__PageMovable(page);
|
||||
|
||||
if (lru)
|
||||
isolated = !isolate_lru_page(page);
|
||||
else
|
||||
isolated = !isolate_movable_page(page, ISOLATE_UNEVICTABLE);
|
||||
isolated = !isolate_movable_page(page,
|
||||
ISOLATE_UNEVICTABLE);
|
||||
|
||||
if (isolated)
|
||||
if (isolated) {
|
||||
list_add(&page->lru, pagelist);
|
||||
if (lru)
|
||||
inc_node_page_state(page, NR_ISOLATED_ANON +
|
||||
page_is_file_lru(page));
|
||||
}
|
||||
}
|
||||
|
||||
if (isolated && lru)
|
||||
inc_node_page_state(page, NR_ISOLATED_ANON +
|
||||
page_is_file_lru(page));
|
||||
|
||||
/*
|
||||
* If we succeed to isolate the page, we grabbed another refcount on
|
||||
* the page, so we can safely drop the one we got from get_any_pages().
|
||||
|
Loading…
Reference in New Issue
Block a user