* [PATCH] mm/huge_memory: Return from zap_huge_pmd after WARN_ONCE.
@ 2022-07-15 9:22 Zhou Guanghui
2022-07-15 17:50 ` Matthew Wilcox
0 siblings, 1 reply; 3+ messages in thread
From: Zhou Guanghui @ 2022-07-15 9:22 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-mm, zhouguanghui1
After WARN_ONCE is processed, the subsequent page judgment results
in NULL pointer access. It is more reasonable to return from the
function here.
Signed-off-by: Zhou Guanghui <zhouguanghui1@huawei.com>
---
mm/huge_memory.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 834f288b3769..7f5ccca6792a 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1601,8 +1601,11 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
entry = pmd_to_swp_entry(orig_pmd);
page = pfn_swap_entry_to_page(entry);
flush_needed = 0;
- } else
+ } else {
+ spin_unlock(ptl);
WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!");
+ return 1;
+ }
if (PageAnon(page)) {
zap_deposited_table(tlb->mm, pmd);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/huge_memory: Return from zap_huge_pmd after WARN_ONCE.
2022-07-15 9:22 [PATCH] mm/huge_memory: Return from zap_huge_pmd after WARN_ONCE Zhou Guanghui
@ 2022-07-15 17:50 ` Matthew Wilcox
2022-07-18 6:49 ` Zhou Guanghui
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2022-07-15 17:50 UTC (permalink / raw)
To: Zhou Guanghui; +Cc: akpm, linux-kernel, linux-mm
On Fri, Jul 15, 2022 at 09:22:38AM +0000, Zhou Guanghui wrote:
> After WARN_ONCE is processed, the subsequent page judgment results
> in NULL pointer access. It is more reasonable to return from the
> function here.
I'm not sure this is a good idea. Probably better to crash than
continue.
> Signed-off-by: Zhou Guanghui <zhouguanghui1@huawei.com>
> ---
> mm/huge_memory.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 834f288b3769..7f5ccca6792a 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1601,8 +1601,11 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
> entry = pmd_to_swp_entry(orig_pmd);
> page = pfn_swap_entry_to_page(entry);
> flush_needed = 0;
> - } else
> + } else {
> + spin_unlock(ptl);
> WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!");
> + return 1;
> + }
>
> if (PageAnon(page)) {
> zap_deposited_table(tlb->mm, pmd);
> --
> 2.17.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/huge_memory: Return from zap_huge_pmd after WARN_ONCE.
2022-07-15 17:50 ` Matthew Wilcox
@ 2022-07-18 6:49 ` Zhou Guanghui
0 siblings, 0 replies; 3+ messages in thread
From: Zhou Guanghui @ 2022-07-18 6:49 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: akpm, linux-kernel, linux-mm, zi.yan
On 2022/7/16 1:50, Matthew Wilcox wrote:
> On Fri, Jul 15, 2022 at 09:22:38AM +0000, Zhou Guanghui wrote:
>> After WARN_ONCE is processed, the subsequent page judgment results
>> in NULL pointer access. It is more reasonable to return from the
>> function here.
>
> I'm not sure this is a good idea. Probably better to crash than
> continue.
Except present pmd and pmd migration entry, there should be no other possible scenarios. Whether crash or warn is unnecessary. However, the current process that crashes after a warning is reported is not reasonable.
Like this:
if (pmd_present(orig_pmd)) {
xxx
} else {
swp_entry_t entry;
VM_BUG_ON(!is_pmd_migration_entry(orig_pmd));
entry = pmd_to_swp_entry(orig_pmd);
page = pfn_to_page(swp_offset(entry));
flush_needed = 0;
}
Thanks.
>
>> Signed-off-by: Zhou Guanghui <zhouguanghui1@huawei.com>
>> ---
>> mm/huge_memory.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 834f288b3769..7f5ccca6792a 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -1601,8 +1601,11 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
>> entry = pmd_to_swp_entry(orig_pmd);
>> page = pfn_swap_entry_to_page(entry);
>> flush_needed = 0;
>> - } else
>> + } else {
>> + spin_unlock(ptl);
>> WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!");
>> + return 1;
>> + }
>>
>> if (PageAnon(page)) {
>> zap_deposited_table(tlb->mm, pmd);
>> --
>> 2.17.1
>>
>>
>
> .
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-18 6:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 9:22 [PATCH] mm/huge_memory: Return from zap_huge_pmd after WARN_ONCE Zhou Guanghui
2022-07-15 17:50 ` Matthew Wilcox
2022-07-18 6:49 ` Zhou Guanghui
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.