diff mbox series

[SRU,B] mm/page_idle.c: skip offline pages

Message ID 20201124163803.557117-2-frank.heimes@canonical.com
State New
Headers show
Series [SRU,B] mm/page_idle.c: skip offline pages | expand

Commit Message

Frank Heimes Nov. 24, 2020, 4:38 p.m. UTC
From: SeongJae Park <sjpark@amazon.de>

BugLink: https://bugs.launchpad.net/bugs/1904884

'Idle page tracking' users can pass random pfn that might be mapped to an
offline page.  To avoid accessing such pages, this commit modifies the
'page_idle_get_page()' to use 'pfn_to_online_page()' instead of
'pfn_valid()' and 'pfn_to_page()' combination, so that the pfn mapped to
an offline page can be skipped.

Reported-by: David Hildenbrand <david@redhat.com>
Signed-off-by: SeongJae Park <sjpark@amazon.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Link: http://lkml.kernel.org/r/20200605092502.18018-2-sjpark@amazon.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(backported from commit 92fb1db26eefc11554820f11ce8e92007da2fbf4)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
 mm/page_idle.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff mbox series


diff --git a/mm/page_idle.c b/mm/page_idle.c
index 504684181827..112f36367adc 100644
--- a/mm/page_idle.c
+++ b/mm/page_idle.c
@@ -4,6 +4,7 @@ 
 #include <linux/fs.h>
 #include <linux/sysfs.h>
 #include <linux/kobject.h>
+#include <linux/memory_hotplug.h>
 #include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/pagemap.h>
@@ -30,13 +31,9 @@ 
 static struct page *page_idle_get_page(unsigned long pfn)
-	struct page *page;
+	struct page *page = pfn_to_online_page(pfn);
 	struct zone *zone;
-	if (!pfn_valid(pfn))
-		return NULL;
-	page = pfn_to_page(pfn);
 	if (!page || !PageLRU(page) ||
 		return NULL;