All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page()
@ 2022-08-19  3:34 Kefeng Wang
  2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-08-19  3:34 UTC (permalink / raw)
  To: Naoya Horiguchi, Miaohe Lin, Andrew Morton
  Cc: linux-mm, linux-kernel, Kefeng Wang

Open-code the page_handle_poison() into soft_offline_page() and
kill unneeded soft_offline_free_page().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/memory-failure.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e48f6f6a259d..1a7d6548ccb2 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2511,16 +2511,6 @@ static int soft_offline_in_use_page(struct page *page)
 	return __soft_offline_page(page);
 }
 
-static int soft_offline_free_page(struct page *page)
-{
-	int rc = 0;
-
-	if (!page_handle_poison(page, true, false))
-		rc = -EBUSY;
-
-	return rc;
-}
-
 static void put_ref_page(struct page *page)
 {
 	if (page)
@@ -2598,7 +2588,7 @@ int soft_offline_page(unsigned long pfn, int flags)
 	if (ret > 0) {
 		ret = soft_offline_in_use_page(page);
 	} else if (ret == 0) {
-		if (soft_offline_free_page(page) && try_again) {
+		if (!page_handle_poison(page, true, false) && try_again) {
 			try_again = false;
 			flags &= ~MF_COUNT_INCREASED;
 			goto retry;
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] mm: memory-failure: kill __soft_offline_page()
  2022-08-19  3:34 [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() Kefeng Wang
@ 2022-08-19  3:34 ` Kefeng Wang
  2022-08-19  6:48   ` HORIGUCHI NAOYA(堀口 直也)
                     ` (2 more replies)
  2022-08-19  6:47 ` [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() HORIGUCHI NAOYA(堀口 直也)
  2022-08-19  7:39 ` Miaohe Lin
  2 siblings, 3 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-08-19  3:34 UTC (permalink / raw)
  To: Naoya Horiguchi, Miaohe Lin, Andrew Morton
  Cc: linux-mm, linux-kernel, Kefeng Wang

Squash the __soft_offline_page() into soft_offline_in_use_page() and
kill __soft_offline_page().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/memory-failure.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 1a7d6548ccb2..5b368124956d 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2432,11 +2432,11 @@ static bool isolate_page(struct page *page, struct list_head *pagelist)
 }
 
 /*
- * __soft_offline_page handles hugetlb-pages and non-hugetlb pages.
+ * soft_offline_in_use_page handles hugetlb-pages and non-hugetlb pages.
  * If the page is a non-dirty unmapped page-cache page, it simply invalidates.
  * If the page is mapped, it migrates the contents over.
  */
-static int __soft_offline_page(struct page *page)
+static int soft_offline_in_use_page(struct page *page)
 {
 	long ret = 0;
 	unsigned long pfn = page_to_pfn(page);
@@ -2449,6 +2449,13 @@ static int __soft_offline_page(struct page *page)
 		.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
 	};
 
+	if (!huge && PageTransHuge(hpage)) {
+		if (try_to_split_thp_page(page)) {
+			pr_info("soft offline: %#lx: thp split failed\n", pfn);
+			return -EBUSY;
+		}
+	}
+
 	lock_page(page);
 	if (!PageHuge(page))
 		wait_on_page_writeback(page);
@@ -2498,19 +2505,6 @@ static int __soft_offline_page(struct page *page)
 	return ret;
 }
 
-static int soft_offline_in_use_page(struct page *page)
-{
-	struct page *hpage = compound_head(page);
-
-	if (!PageHuge(page) && PageTransHuge(hpage))
-		if (try_to_split_thp_page(page) < 0) {
-			pr_info("soft offline: %#lx: thp split failed\n",
-				page_to_pfn(page));
-			return -EBUSY;
-		}
-	return __soft_offline_page(page);
-}
-
 static void put_ref_page(struct page *page)
 {
 	if (page)
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page()
  2022-08-19  3:34 [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() Kefeng Wang
  2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
@ 2022-08-19  6:47 ` HORIGUCHI NAOYA(堀口 直也)
  2022-08-19  7:39 ` Miaohe Lin
  2 siblings, 0 replies; 8+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2022-08-19  6:47 UTC (permalink / raw)
  To: Kefeng Wang; +Cc: Miaohe Lin, Andrew Morton, linux-mm, linux-kernel

On Fri, Aug 19, 2022 at 11:34:01AM +0800, Kefeng Wang wrote:
> Open-code the page_handle_poison() into soft_offline_page() and
> kill unneeded soft_offline_free_page().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Thank you for sending cleanup patches.
This patch looks good to me,

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

> ---
>  mm/memory-failure.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index e48f6f6a259d..1a7d6548ccb2 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2511,16 +2511,6 @@ static int soft_offline_in_use_page(struct page *page)
>  	return __soft_offline_page(page);
>  }
>  
> -static int soft_offline_free_page(struct page *page)
> -{
> -	int rc = 0;
> -
> -	if (!page_handle_poison(page, true, false))
> -		rc = -EBUSY;
> -
> -	return rc;
> -}
> -
>  static void put_ref_page(struct page *page)
>  {
>  	if (page)
> @@ -2598,7 +2588,7 @@ int soft_offline_page(unsigned long pfn, int flags)
>  	if (ret > 0) {
>  		ret = soft_offline_in_use_page(page);
>  	} else if (ret == 0) {
> -		if (soft_offline_free_page(page) && try_again) {
> +		if (!page_handle_poison(page, true, false) && try_again) {
>  			try_again = false;
>  			flags &= ~MF_COUNT_INCREASED;
>  			goto retry;
> -- 
> 2.35.3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memory-failure: kill __soft_offline_page()
  2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
@ 2022-08-19  6:48   ` HORIGUCHI NAOYA(堀口 直也)
  2022-08-19  7:40   ` Miaohe Lin
  2022-08-30  7:15   ` HORIGUCHI NAOYA(堀口 直也)
  2 siblings, 0 replies; 8+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2022-08-19  6:48 UTC (permalink / raw)
  To: Kefeng Wang; +Cc: Miaohe Lin, Andrew Morton, linux-mm, linux-kernel

On Fri, Aug 19, 2022 at 11:34:02AM +0800, Kefeng Wang wrote:
> Squash the __soft_offline_page() into soft_offline_in_use_page() and
> kill __soft_offline_page().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page()
  2022-08-19  3:34 [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() Kefeng Wang
  2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
  2022-08-19  6:47 ` [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() HORIGUCHI NAOYA(堀口 直也)
@ 2022-08-19  7:39 ` Miaohe Lin
  2 siblings, 0 replies; 8+ messages in thread
From: Miaohe Lin @ 2022-08-19  7:39 UTC (permalink / raw)
  To: Kefeng Wang; +Cc: linux-mm, linux-kernel, Naoya Horiguchi, Andrew Morton

On 2022/8/19 11:34, Kefeng Wang wrote:
> Open-code the page_handle_poison() into soft_offline_page() and
> kill unneeded soft_offline_free_page().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

LGTM. Thanks.

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks,
Miaohe Lin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memory-failure: kill __soft_offline_page()
  2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
  2022-08-19  6:48   ` HORIGUCHI NAOYA(堀口 直也)
@ 2022-08-19  7:40   ` Miaohe Lin
  2022-08-30  7:15   ` HORIGUCHI NAOYA(堀口 直也)
  2 siblings, 0 replies; 8+ messages in thread
From: Miaohe Lin @ 2022-08-19  7:40 UTC (permalink / raw)
  To: Kefeng Wang; +Cc: linux-mm, linux-kernel, Naoya Horiguchi, Andrew Morton

On 2022/8/19 11:34, Kefeng Wang wrote:
> Squash the __soft_offline_page() into soft_offline_in_use_page() and
> kill __soft_offline_page().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

LGTM. Thanks.

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks,
Miaohe Lin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memory-failure: kill __soft_offline_page()
  2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
  2022-08-19  6:48   ` HORIGUCHI NAOYA(堀口 直也)
  2022-08-19  7:40   ` Miaohe Lin
@ 2022-08-30  7:15   ` HORIGUCHI NAOYA(堀口 直也)
  2022-08-30  9:26     ` Kefeng Wang
  2 siblings, 1 reply; 8+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2022-08-30  7:15 UTC (permalink / raw)
  To: Kefeng Wang; +Cc: Miaohe Lin, Andrew Morton, linux-mm, linux-kernel

On Fri, Aug 19, 2022 at 11:34:02AM +0800, Kefeng Wang wrote:
> Squash the __soft_offline_page() into soft_offline_in_use_page() and
> kill __soft_offline_page().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  mm/memory-failure.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 1a7d6548ccb2..5b368124956d 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2432,11 +2432,11 @@ static bool isolate_page(struct page *page, struct list_head *pagelist)
>  }
>  
>  /*
> - * __soft_offline_page handles hugetlb-pages and non-hugetlb pages.
> + * soft_offline_in_use_page handles hugetlb-pages and non-hugetlb pages.
>   * If the page is a non-dirty unmapped page-cache page, it simply invalidates.
>   * If the page is mapped, it migrates the contents over.
>   */
> -static int __soft_offline_page(struct page *page)
> +static int soft_offline_in_use_page(struct page *page)
>  {
>  	long ret = 0;
>  	unsigned long pfn = page_to_pfn(page);
> @@ -2449,6 +2449,13 @@ static int __soft_offline_page(struct page *page)
>  		.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
>  	};
>  
> +	if (!huge && PageTransHuge(hpage)) {
> +		if (try_to_split_thp_page(page)) {
> +			pr_info("soft offline: %#lx: thp split failed\n", pfn);
> +			return -EBUSY;
> +		}

I've found that this change causes a regression. After the thp is
successfully split here, hpage no longer points to a proper page.
So hpage should be updated to point to the raw error page.

+		hpage = page;

Could you update the patch?

Thanks,
Naoya Horiguchi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memory-failure: kill __soft_offline_page()
  2022-08-30  7:15   ` HORIGUCHI NAOYA(堀口 直也)
@ 2022-08-30  9:26     ` Kefeng Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Kefeng Wang @ 2022-08-30  9:26 UTC (permalink / raw)
  To: HORIGUCHI NAOYA(堀口 直也)
  Cc: Miaohe Lin, Andrew Morton, linux-mm, linux-kernel


On 2022/8/30 15:15, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Fri, Aug 19, 2022 at 11:34:02AM +0800, Kefeng Wang wrote:
>> Squash the __soft_offline_page() into soft_offline_in_use_page() and
>> kill __soft_offline_page().
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   mm/memory-failure.c | 24 +++++++++---------------
>>   1 file changed, 9 insertions(+), 15 deletions(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 1a7d6548ccb2..5b368124956d 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -2432,11 +2432,11 @@ static bool isolate_page(struct page *page, struct list_head *pagelist)
>>   }
>>   
>>   /*
>> - * __soft_offline_page handles hugetlb-pages and non-hugetlb pages.
>> + * soft_offline_in_use_page handles hugetlb-pages and non-hugetlb pages.
>>    * If the page is a non-dirty unmapped page-cache page, it simply invalidates.
>>    * If the page is mapped, it migrates the contents over.
>>    */
>> -static int __soft_offline_page(struct page *page)
>> +static int soft_offline_in_use_page(struct page *page)
>>   {
>>   	long ret = 0;
>>   	unsigned long pfn = page_to_pfn(page);
>> @@ -2449,6 +2449,13 @@ static int __soft_offline_page(struct page *page)
>>   		.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
>>   	};
>>   
>> +	if (!huge && PageTransHuge(hpage)) {
>> +		if (try_to_split_thp_page(page)) {
>> +			pr_info("soft offline: %#lx: thp split failed\n", pfn);
>> +			return -EBUSY;
>> +		}
> I've found that this change causes a regression. After the thp is
> successfully split here, hpage no longer points to a proper page.
> So hpage should be updated to point to the raw error page.
>
> +		hpage = page;
Sorry for the regression,  will update.
>
> Could you update the patch?
>
> Thanks,
> Naoya Horiguchi

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-08-30  9:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19  3:34 [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() Kefeng Wang
2022-08-19  3:34 ` [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Kefeng Wang
2022-08-19  6:48   ` HORIGUCHI NAOYA(堀口 直也)
2022-08-19  7:40   ` Miaohe Lin
2022-08-30  7:15   ` HORIGUCHI NAOYA(堀口 直也)
2022-08-30  9:26     ` Kefeng Wang
2022-08-19  6:47 ` [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() HORIGUCHI NAOYA(堀口 直也)
2022-08-19  7:39 ` Miaohe Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.