diff mbox series

[6/6] mm, hwpoison: avoid trying to unpoison reserved page

Message ID 20220818130016.45313-7-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few fixup patches for hugetlb | expand

Commit Message

Miaohe Lin Aug. 18, 2022, 1 p.m. UTC
For reserved pages, HWPoison flag will be set without increasing the page
refcnt. So we shouldn't even try to unpoison these pages and thus decrease
the page refcnt unexpectly. Add a PageReserved() check to filter this case
out and remove the below unneeded zero page (zero page is reserved) check.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

HORIGUCHI NAOYA(堀口 直也) Aug. 19, 2022, 5:24 a.m. UTC | #1
On Thu, Aug 18, 2022 at 09:00:16PM +0800, Miaohe Lin wrote:
> For reserved pages, HWPoison flag will be set without increasing the page
> refcnt. So we shouldn't even try to unpoison these pages and thus decrease
> the page refcnt unexpectly. Add a PageReserved() check to filter this case
> out and remove the below unneeded zero page (zero page is reserved) check.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Looks good to me, thank you.

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

> ---
>  mm/memory-failure.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 5f9615a86296..c831c41bb092 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2355,7 +2355,7 @@ int unpoison_memory(unsigned long pfn)
>  		goto unlock_mutex;
>  	}
>  
> -	if (PageSlab(page) || PageTable(page))
> +	if (PageSlab(page) || PageTable(page) || PageReserved(page))
>  		goto unlock_mutex;
>  
>  	ret = get_hwpoison_page(p, MF_UNPOISON);
> @@ -2386,7 +2386,7 @@ int unpoison_memory(unsigned long pfn)
>  		freeit = !!TestClearPageHWPoison(p);
>  
>  		put_page(page);
> -		if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) {
> +		if (freeit) {
>  			put_page(page);
>  			ret = 0;
>  		}
> -- 
> 2.23.0
diff mbox series

Patch

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 5f9615a86296..c831c41bb092 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2355,7 +2355,7 @@  int unpoison_memory(unsigned long pfn)
 		goto unlock_mutex;
 	}
 
-	if (PageSlab(page) || PageTable(page))
+	if (PageSlab(page) || PageTable(page) || PageReserved(page))
 		goto unlock_mutex;
 
 	ret = get_hwpoison_page(p, MF_UNPOISON);
@@ -2386,7 +2386,7 @@  int unpoison_memory(unsigned long pfn)
 		freeit = !!TestClearPageHWPoison(p);
 
 		put_page(page);
-		if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) {
+		if (freeit) {
 			put_page(page);
 			ret = 0;
 		}