diff mbox series

[1/2] mm/page_idle.c: Skip offline pages

Message ID 20200605092502.18018-2-sjpark@amazon.com (mailing list archive)
State New, archived
Headers show
Series Trivial fixups | expand

Commit Message

SeongJae Park June 5, 2020, 9:25 a.m. UTC
From: SeongJae Park <sjpark@amazon.de>

'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.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
Reported-by: David Hildenbrand <david@redhat.com>
---
 mm/page_idle.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

David Hildenbrand June 5, 2020, 9:27 a.m. UTC | #1
On 05.06.20 11:25, SeongJae Park wrote:
> From: SeongJae Park <sjpark@amazon.de>
> 
> '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.
> 
> Signed-off-by: SeongJae Park <sjpark@amazon.de>
> Reported-by: David Hildenbrand <david@redhat.com>
> ---
>  mm/page_idle.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/page_idle.c b/mm/page_idle.c
> index 295512465065..057c61df12db 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);
>  	pg_data_t *pgdat;
>  
> -	if (!pfn_valid(pfn))
> -		return NULL;
> -
> -	page = pfn_to_page(pfn);
>  	if (!page || !PageLRU(page) ||
>  	    !get_page_unless_zero(page))
>  		return NULL;
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
Pankaj Gupta June 5, 2020, 9:31 a.m. UTC | #2
> From: SeongJae Park <sjpark@amazon.de>
>
> '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.
>
> Signed-off-by: SeongJae Park <sjpark@amazon.de>
> Reported-by: David Hildenbrand <david@redhat.com>
> ---
>  mm/page_idle.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/mm/page_idle.c b/mm/page_idle.c
> index 295512465065..057c61df12db 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);
>         pg_data_t *pgdat;
>
> -       if (!pfn_valid(pfn))
> -               return NULL;
> -
> -       page = pfn_to_page(pfn);
>         if (!page || !PageLRU(page) ||
>             !get_page_unless_zero(page))
>                 return NULL;

Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
diff mbox series

Patch

diff --git a/mm/page_idle.c b/mm/page_idle.c
index 295512465065..057c61df12db 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);
 	pg_data_t *pgdat;
 
-	if (!pfn_valid(pfn))
-		return NULL;
-
-	page = pfn_to_page(pfn);
 	if (!page || !PageLRU(page) ||
 	    !get_page_unless_zero(page))
 		return NULL;