diff mbox series

回复:[PATCH] hibernate: pageoffline may be first judged

Message ID 08ec8325a38106cebd68431519c9fbf418431d7e.camel@kylinos.cn (mailing list archive)
State New
Headers show
Series 回复:[PATCH] hibernate: pageoffline may be first judged | expand

Commit Message

lijun April 2, 2025, 8:36 a.m. UTC
From e5b2d7aa9b66cac66314165fee12999f432b29d8 Mon Sep 17 00:00:00 2001
From: Li Jun <lijun01@kylinos.cn>
Date: Mon, 10 Feb 2025 10:40:58 +0800
Subject: [PATCH v2] hibernate: pageoffline may be first judged

'PageReserved' and 'PageOffline' have weights greater
than 'is_forbidden' and 'is_free'.so,PageReserved
and PageOffline should be first judged.
just as the page is free,but is reserved.

Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
 kernel/power/snapshot.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

    if (page_is_guard(page))
@@ -1387,9 +1387,6 @@ static struct page *saveable_page(struct zone
*zone, unsigned long pfn)
 
    BUG_ON(PageHighMem(page));
 
-   if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
-       return NULL;
-
    if (PageOffline(page))
        return NULL;
 
@@ -1397,6 +1394,9 @@ static struct page *saveable_page(struct zone
*zone, unsigned long pfn)
        && (!kernel_page_present(page) || pfn_is_nosave(pfn)))
        return NULL;
 
+   if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
+       return NULL;
+                                                                      
                                                                       
                                                                       
                         
    if (page_is_guard(page))
        return NULL;

Comments

Rafael J. Wysocki April 2, 2025, 9:57 a.m. UTC | #1
On Wed, Apr 2, 2025 at 10:38 AM lijun <lijun01@kylinos.cn> wrote:
>
> From e5b2d7aa9b66cac66314165fee12999f432b29d8 Mon Sep 17 00:00:00 2001
> From: Li Jun <lijun01@kylinos.cn>
> Date: Mon, 10 Feb 2025 10:40:58 +0800
> Subject: [PATCH v2] hibernate: pageoffline may be first judged
>
> 'PageReserved' and 'PageOffline' have weights greater
> than 'is_forbidden' and 'is_free'.so,PageReserved
> and PageOffline should be first judged.
> just as the page is free,but is reserved.

I fail to see why this matters.

NULL is returned if any of these conditions is met, so why would the
ordering of checks matter here?

> Signed-off-by: Li Jun <lijun01@kylinos.cn>
> ---
>  kernel/power/snapshot.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> index c9fb559a6399..dfbccddb28f1 100644
> --- a/kernel/power/snapshot.c
> +++ b/kernel/power/snapshot.c
> @@ -1328,10 +1328,10 @@ static struct page
> *saveable_highmem_page(struct zone *zone, unsigned long pfn)
>
>     BUG_ON(!PageHighMem(page));
>
> -   if (swsusp_page_is_forbidden(page) ||  swsusp_page_is_free(page))
> +   if (PageReserved(page) || PageOffline(page))
>         return NULL;
>
> -   if (PageReserved(page) || PageOffline(page))
> +   if (swsusp_page_is_forbidden(page) ||  swsusp_page_is_free(page))
>         return NULL;
>
>     if (page_is_guard(page))
> @@ -1387,9 +1387,6 @@ static struct page *saveable_page(struct zone
> *zone, unsigned long pfn)
>
>     BUG_ON(PageHighMem(page));
>
> -   if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
> -       return NULL;
> -
>     if (PageOffline(page))
>         return NULL;
>
> @@ -1397,6 +1394,9 @@ static struct page *saveable_page(struct zone
> *zone, unsigned long pfn)
>         && (!kernel_page_present(page) || pfn_is_nosave(pfn)))
>         return NULL;
>
> +   if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
> +       return NULL;
> +
>
>
>
>     if (page_is_guard(page))
>         return NULL;
>
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index c9fb559a6399..dfbccddb28f1 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1328,10 +1328,10 @@  static struct page
*saveable_highmem_page(struct zone *zone, unsigned long pfn)
 
    BUG_ON(!PageHighMem(page));
 
-   if (swsusp_page_is_forbidden(page) ||  swsusp_page_is_free(page))
+   if (PageReserved(page) || PageOffline(page))
        return NULL;
 
-   if (PageReserved(page) || PageOffline(page))
+   if (swsusp_page_is_forbidden(page) ||  swsusp_page_is_free(page))
        return NULL;