[PATCH 2/2] mm, page_alloc: fail has_unmovable_pages when seeing reserved pages

From: Michal Hocko
Date: Fri Oct 13 2017 - 08:00:38 EST


From: Michal Hocko <mhocko@xxxxxxxx>

Reserved pages should be completely ignored by the core mm because they
have a special meaning for their owners. has_unmovable_pages doesn't
check those so we rely on other tests (reference count, or PageLRU) to
fail on such pages. Althought this happens to work it is safer to simply
check for those explicitly and do not rely on the owner of the page
to abuse those fields for special purposes.

Please note that this is more of a further fortification of the code
rahter than a fix of an existing issue.

Signed-off-by: Michal Hocko <mhocko@xxxxxxxx>
---
mm/page_alloc.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ad0294ab3e4f..a8800b0a5619 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7365,6 +7365,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,

page = pfn_to_page(check);

+ if (PageReferenced(page))
+ return true;
+
/*
* Hugepages are not in LRU lists, but they're movable.
* We need not scan over tail pages bacause we don't
--
2.14.2