LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mm: fix panic caused by __page_handle_poison()
@ 2021-08-30 10:07 王贇
2021-08-31 9:11 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-31 9:37 ` [PATCH v2] " 王贇
0 siblings, 2 replies; 4+ messages in thread
From: 王贇 @ 2021-08-30 10:07 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton,
open list:HWPOISON MEMORY FAILURE HANDLING, open list
By commit 510d25c92ec4 ("mm/hwpoison: disable pcp for
page_handle_poison()"), __page_handle_poison() was
introduced, and if we mark:
RET_A = dissolve_free_huge_page();
RET_B = take_page_off_buddy();
then __page_handle_poison was supposed to return TRUE When
RET_A == 0 && RET_B == TRUE
But since it failed to take care the case when RET_A is
-EBUSY or -ENOMEM, and just return the ret as a bool which
actually become TRUE, it break the original logical.
The following result is a huge page in freelist but was
referenced as poisoned, and lead into the final panic:
kernel BUG at mm/internal.h:95!
invalid opcode: 0000 [#1] SMP PTI
skip...
RIP: 0010:set_page_refcounted mm/internal.h:95 [inline]
RIP: 0010:remove_hugetlb_page+0x23c/0x240 mm/hugetlb.c:1371
skip...
Call Trace:
remove_pool_huge_page+0xe4/0x110 mm/hugetlb.c:1892
return_unused_surplus_pages+0x8d/0x150 mm/hugetlb.c:2272
hugetlb_acct_memory.part.91+0x524/0x690 mm/hugetlb.c:4017
This patch replace 'bool' with 'int' to handle RET_A correctly.
Reported-by: Abaci <abaci@linux.alibaba.com>
Signed-off-by: Michael Wang <yun.wang@linux.alibaba.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 470400c..0fff717 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -68,7 +68,7 @@
static bool __page_handle_poison(struct page *page)
{
- bool ret;
+ int ret;
zone_pcp_disable(page_zone(page));
ret = dissolve_free_huge_page(page);
@@ -76,7 +76,7 @@ static bool __page_handle_poison(struct page *page)
ret = take_page_off_buddy(page);
zone_pcp_enable(page_zone(page));
- return ret;
+ return ret > 0;
}
static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: fix panic caused by __page_handle_poison()
2021-08-30 10:07 [PATCH] mm: fix panic caused by __page_handle_poison() 王贇
@ 2021-08-31 9:11 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-31 9:35 ` 王贇
2021-08-31 9:37 ` [PATCH v2] " 王贇
1 sibling, 1 reply; 4+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2021-08-31 9:11 UTC (permalink / raw)
To: 王贇
Cc: Andrew Morton, open list:HWPOISON MEMORY FAILURE HANDLING, open list
On Mon, Aug 30, 2021 at 06:07:56PM +0800, 王贇 wrote:
> By commit 510d25c92ec4 ("mm/hwpoison: disable pcp for
> page_handle_poison()"), __page_handle_poison() was
> introduced, and if we mark:
>
> RET_A = dissolve_free_huge_page();
> RET_B = take_page_off_buddy();
>
> then __page_handle_poison was supposed to return TRUE When
> RET_A == 0 && RET_B == TRUE
>
> But since it failed to take care the case when RET_A is
> -EBUSY or -ENOMEM, and just return the ret as a bool which
> actually become TRUE, it break the original logical.
s/logical/logic/ ?
>
> The following result is a huge page in freelist but was
> referenced as poisoned, and lead into the final panic:
>
> kernel BUG at mm/internal.h:95!
> invalid opcode: 0000 [#1] SMP PTI
> skip...
> RIP: 0010:set_page_refcounted mm/internal.h:95 [inline]
> RIP: 0010:remove_hugetlb_page+0x23c/0x240 mm/hugetlb.c:1371
> skip...
> Call Trace:
> remove_pool_huge_page+0xe4/0x110 mm/hugetlb.c:1892
> return_unused_surplus_pages+0x8d/0x150 mm/hugetlb.c:2272
> hugetlb_acct_memory.part.91+0x524/0x690 mm/hugetlb.c:4017
>
> This patch replace 'bool' with 'int' to handle RET_A correctly.
>
> Reported-by: Abaci <abaci@linux.alibaba.com>
> Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com>
Thank you very much, this fix is totally right.
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Could you add the following tags, too?
Fixes: 510d25c92ec4 ("mm/hwpoison: disable pcp for page_handle_poison()")
Cc: <stable@vger.kernel.org> # 5.14
Thanks,
Naoya Horiguchi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: fix panic caused by __page_handle_poison()
2021-08-31 9:11 ` HORIGUCHI NAOYA(堀口 直也)
@ 2021-08-31 9:35 ` 王贇
0 siblings, 0 replies; 4+ messages in thread
From: 王贇 @ 2021-08-31 9:35 UTC (permalink / raw)
To: HORIGUCHI NAOYA(堀口 直也)
Cc: Andrew Morton, open list:HWPOISON MEMORY FAILURE HANDLING, open list
On 2021/8/31 下午5:11, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Mon, Aug 30, 2021 at 06:07:56PM +0800, 王贇 wrote:
>> By commit 510d25c92ec4 ("mm/hwpoison: disable pcp for
>> page_handle_poison()"), __page_handle_poison() was
>> introduced, and if we mark:
>>
>> RET_A = dissolve_free_huge_page();
>> RET_B = take_page_off_buddy();
>>
>> then __page_handle_poison was supposed to return TRUE When
>> RET_A == 0 && RET_B == TRUE
>>
>> But since it failed to take care the case when RET_A is
>> -EBUSY or -ENOMEM, and just return the ret as a bool which
>> actually become TRUE, it break the original logical.
>
> s/logical/logic/ ?
Will Fix it in v2.
>
>>
>> The following result is a huge page in freelist but was
>> referenced as poisoned, and lead into the final panic:
>>
>> kernel BUG at mm/internal.h:95!
>> invalid opcode: 0000 [#1] SMP PTI
>> skip...
>> RIP: 0010:set_page_refcounted mm/internal.h:95 [inline]
>> RIP: 0010:remove_hugetlb_page+0x23c/0x240 mm/hugetlb.c:1371
>> skip...
>> Call Trace:
>> remove_pool_huge_page+0xe4/0x110 mm/hugetlb.c:1892
>> return_unused_surplus_pages+0x8d/0x150 mm/hugetlb.c:2272
>> hugetlb_acct_memory.part.91+0x524/0x690 mm/hugetlb.c:4017
>>
>> This patch replace 'bool' with 'int' to handle RET_A correctly.
>>
>> Reported-by: Abaci <abaci@linux.alibaba.com>
>> Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com>
>
> Thank you very much, this fix is totally right.
>
> Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
>
> Could you add the following tags, too?
>
> Fixes: 510d25c92ec4 ("mm/hwpoison: disable pcp for page_handle_poison()")
> Cc: <stable@vger.kernel.org> # 5.14
Thanks for the review, will add in v2 and send out soon.
Regards,
Michael Wang
>
> Thanks,
> Naoya Horiguchi
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] mm: fix panic caused by __page_handle_poison()
2021-08-30 10:07 [PATCH] mm: fix panic caused by __page_handle_poison() 王贇
2021-08-31 9:11 ` HORIGUCHI NAOYA(堀口 直也)
@ 2021-08-31 9:37 ` 王贇
1 sibling, 0 replies; 4+ messages in thread
From: 王贇 @ 2021-08-31 9:37 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton,
open list:HWPOISON MEMORY FAILURE HANDLING, open list
By commit 510d25c92ec4 ("mm/hwpoison: disable pcp for
page_handle_poison()"), __page_handle_poison() was
introduced, and if we mark:
RET_A = dissolve_free_huge_page();
RET_B = take_page_off_buddy();
then __page_handle_poison was supposed to return TRUE When
RET_A == 0 && RET_B == TRUE
But since it failed to take care the case when RET_A is
-EBUSY or -ENOMEM, and just return the ret as a bool which
actually become TRUE, it break the original logic.
The following result is a huge page in freelist but was
referenced as poisoned, and lead into the final panic:
kernel BUG at mm/internal.h:95!
invalid opcode: 0000 [#1] SMP PTI
skip...
RIP: 0010:set_page_refcounted mm/internal.h:95 [inline]
RIP: 0010:remove_hugetlb_page+0x23c/0x240 mm/hugetlb.c:1371
skip...
Call Trace:
remove_pool_huge_page+0xe4/0x110 mm/hugetlb.c:1892
return_unused_surplus_pages+0x8d/0x150 mm/hugetlb.c:2272
hugetlb_acct_memory.part.91+0x524/0x690 mm/hugetlb.c:4017
This patch replace 'bool' with 'int' to handle RET_A correctly.
Fixes: 510d25c92ec4 ("mm/hwpoison: disable pcp for page_handle_poison()")
Cc: <stable@vger.kernel.org> # 5.14
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Reported-by: Abaci <abaci@linux.alibaba.com>
Signed-off-by: Michael Wang <yun.wang@linux.alibaba.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 470400c..0fff717 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -68,7 +68,7 @@
static bool __page_handle_poison(struct page *page)
{
- bool ret;
+ int ret;
zone_pcp_disable(page_zone(page));
ret = dissolve_free_huge_page(page);
@@ -76,7 +76,7 @@ static bool __page_handle_poison(struct page *page)
ret = take_page_off_buddy(page);
zone_pcp_enable(page_zone(page));
- return ret;
+ return ret > 0;
}
static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-31 9:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 10:07 [PATCH] mm: fix panic caused by __page_handle_poison() 王贇
2021-08-31 9:11 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-31 9:35 ` 王贇
2021-08-31 9:37 ` [PATCH v2] " 王贇
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).