All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: add p?d_leaf() definitions
@ 2023-09-05  6:49 Hongchen Zhang
  2023-09-06  7:42 ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Hongchen Zhang @ 2023-09-05  6:49 UTC (permalink / raw)
  To: Huacai Chen, WANG Xuerui, Andrew Morton, David Hildenbrand,
	Mike Rapoport IBM),
	Feiyang Chen, Hongchen Zhang, Qi Zheng, Matthew Wilcox Oracle),
	Kefeng Wang
  Cc: loongarch, linux-kernel, loongson-kernel

When I do LTP test, LTP test case ksm06 caused panic at
	break_ksm_pmd_entry
	  -> pmd_leaf (Huge page table but False)
	  -> pte_present (panic)

The reason is pmd_leaf is not defined, So like
commit 501b81046701 ("mips: mm: add p?d_leaf() definitions")
add p?d_leaf() definition for LoongArch.

Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
---
 arch/loongarch/include/asm/pgtable.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index 370c6568ceb8..ea54653b7aab 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -243,6 +243,9 @@ static inline void pmd_clear(pmd_t *pmdp)
 
 #define pmd_phys(pmd)		PHYSADDR(pmd_val(pmd))
 
+#define pmd_leaf(pmd)		((pmd_val(pmd) & _PAGE_HUGE) != 0)
+#define pud_leaf(pud)		((pud_val(pud) & _PAGE_HUGE) != 0)
+
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
 #define pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
-- 
2.33.0


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

* Re: [PATCH] LoongArch: add p?d_leaf() definitions
  2023-09-05  6:49 [PATCH] LoongArch: add p?d_leaf() definitions Hongchen Zhang
@ 2023-09-06  7:42 ` David Hildenbrand
  2023-09-06  8:06   ` Hongchen Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2023-09-06  7:42 UTC (permalink / raw)
  To: Hongchen Zhang, Huacai Chen, WANG Xuerui, Andrew Morton,
	Mike Rapoport IBM),
	Feiyang Chen, Qi Zheng, Matthew Wilcox Oracle),
	Kefeng Wang
  Cc: loongarch, linux-kernel, loongson-kernel

On 05.09.23 08:49, Hongchen Zhang wrote:
> When I do LTP test, LTP test case ksm06 caused panic at
> 	break_ksm_pmd_entry
> 	  -> pmd_leaf (Huge page table but False)
> 	  -> pte_present (panic)
> 

Probably there are other problematic bits without that can trigger that? 
I suspect walk_page_range*() callers might be affected,

> The reason is pmd_leaf is not defined, So like
> commit 501b81046701 ("mips: mm: add p?d_leaf() definitions")
> add p?d_leaf() definition for LoongArch.
> 

We most certainly want to cc stable, no?

Can we come up with a Fixes: tag? Probably when we added THP support to 
loongarch.

> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
> ---
>   arch/loongarch/include/asm/pgtable.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
> index 370c6568ceb8..ea54653b7aab 100644
> --- a/arch/loongarch/include/asm/pgtable.h
> +++ b/arch/loongarch/include/asm/pgtable.h
> @@ -243,6 +243,9 @@ static inline void pmd_clear(pmd_t *pmdp)
>   
>   #define pmd_phys(pmd)		PHYSADDR(pmd_val(pmd))
>   
> +#define pmd_leaf(pmd)		((pmd_val(pmd) & _PAGE_HUGE) != 0)
> +#define pud_leaf(pud)		((pud_val(pud) & _PAGE_HUGE) != 0)
> +
>   #ifndef CONFIG_TRANSPARENT_HUGEPAGE
>   #define pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
>   #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH] LoongArch: add p?d_leaf() definitions
  2023-09-06  7:42 ` David Hildenbrand
@ 2023-09-06  8:06   ` Hongchen Zhang
  2023-09-06  8:08     ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Hongchen Zhang @ 2023-09-06  8:06 UTC (permalink / raw)
  To: David Hildenbrand, Huacai Chen, WANG Xuerui, Andrew Morton,
	Mike Rapoport IBM),
	Feiyang Chen, Qi Zheng, Matthew Wilcox Oracle),
	Kefeng Wang
  Cc: loongarch, linux-kernel, loongson-kernel

Hi David,

On 2023/9/6 pm 3:42, David Hildenbrand wrote:
> On 05.09.23 08:49, Hongchen Zhang wrote:
>> When I do LTP test, LTP test case ksm06 caused panic at
>>     break_ksm_pmd_entry
>>       -> pmd_leaf (Huge page table but False)
>>       -> pte_present (panic)
>>
> 
> Probably there are other problematic bits without that can trigger that? 
> I suspect walk_page_range*() callers might be affected,
I rechecked the code and found that other architectures that support
THP have defined pmd_leaf.
So there is not problem on other architectures.
> 
>> The reason is pmd_leaf is not defined, So like
>> commit 501b81046701 ("mips: mm: add p?d_leaf() definitions")
>> add p?d_leaf() definition for LoongArch.
>>
> 
> We most certainly want to cc stable, no?
OK, let me cc stable in V2.
> 
> Can we come up with a Fixes: tag? Probably when we added THP support to 
> loongarch.
OK, let me add Fixes: in commit message in V2.
> 
>> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
>> ---
>>   arch/loongarch/include/asm/pgtable.h | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/loongarch/include/asm/pgtable.h 
>> b/arch/loongarch/include/asm/pgtable.h
>> index 370c6568ceb8..ea54653b7aab 100644
>> --- a/arch/loongarch/include/asm/pgtable.h
>> +++ b/arch/loongarch/include/asm/pgtable.h
>> @@ -243,6 +243,9 @@ static inline void pmd_clear(pmd_t *pmdp)
>>   #define pmd_phys(pmd)        PHYSADDR(pmd_val(pmd))
>> +#define pmd_leaf(pmd)        ((pmd_val(pmd) & _PAGE_HUGE) != 0)
>> +#define pud_leaf(pud)        ((pud_val(pud) & _PAGE_HUGE) != 0)
>> +
>>   #ifndef CONFIG_TRANSPARENT_HUGEPAGE
>>   #define pmd_page(pmd)        (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
>>   #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
> 
> Acked-by: David Hildenbrand <david@redhat.com>
> 


-- 
Best Regards
Hongchen Zhang


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

* Re: [PATCH] LoongArch: add p?d_leaf() definitions
  2023-09-06  8:06   ` Hongchen Zhang
@ 2023-09-06  8:08     ` David Hildenbrand
  2023-09-06  8:22       ` Hongchen Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2023-09-06  8:08 UTC (permalink / raw)
  To: Hongchen Zhang, Huacai Chen, WANG Xuerui, Andrew Morton,
	Mike Rapoport IBM),
	Feiyang Chen, Qi Zheng, Matthew Wilcox Oracle),
	Kefeng Wang
  Cc: loongarch, linux-kernel, loongson-kernel

On 06.09.23 10:06, Hongchen Zhang wrote:
> Hi David,
> 
> On 2023/9/6 pm 3:42, David Hildenbrand wrote:
>> On 05.09.23 08:49, Hongchen Zhang wrote:
>>> When I do LTP test, LTP test case ksm06 caused panic at
>>>      break_ksm_pmd_entry
>>>        -> pmd_leaf (Huge page table but False)
>>>        -> pte_present (panic)
>>>
>>
>> Probably there are other problematic bits without that can trigger that?
>> I suspect walk_page_range*() callers might be affected,
> I rechecked the code and found that other architectures that support
> THP have defined pmd_leaf.
> So there is not problem on other architectures.

I meant other walk_page_range*() callers on loongarch might similarly be 
affected. IOW, KSM might not be the only bit being able to trigger such 
panics on loongarch.

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH] LoongArch: add p?d_leaf() definitions
  2023-09-06  8:08     ` David Hildenbrand
@ 2023-09-06  8:22       ` Hongchen Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Hongchen Zhang @ 2023-09-06  8:22 UTC (permalink / raw)
  To: David Hildenbrand, Huacai Chen, WANG Xuerui, Andrew Morton,
	Mike Rapoport IBM),
	Feiyang Chen, Qi Zheng, Matthew Wilcox Oracle),
	Kefeng Wang
  Cc: loongarch, linux-kernel, loongson-kernel

On 2023/9/6 下午4:08, David Hildenbrand wrote:
> On 06.09.23 10:06, Hongchen Zhang wrote:
>> Hi David,
>>
>> On 2023/9/6 pm 3:42, David Hildenbrand wrote:
>>> On 05.09.23 08:49, Hongchen Zhang wrote:
>>>> When I do LTP test, LTP test case ksm06 caused panic at
>>>>      break_ksm_pmd_entry
>>>>        -> pmd_leaf (Huge page table but False)
>>>>        -> pte_present (panic)
>>>>
>>>
>>> Probably there are other problematic bits without that can trigger that?
>>> I suspect walk_page_range*() callers might be affected,
>> I rechecked the code and found that other architectures that support
>> THP have defined pmd_leaf.
>> So there is not problem on other architectures.
> 
> I meant other walk_page_range*() callers on loongarch might similarly be 
> affected. IOW, KSM might not be the only bit being able to trigger such 
> panics on loongarch.
Yes, perf_get_pgtable_size and vmalloc_to_page also call pmd_leaf.
So they may also trigger this issue on LoongArch.
> 


-- 
Best Regards
Hongchen Zhang


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

end of thread, other threads:[~2023-09-06  8:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05  6:49 [PATCH] LoongArch: add p?d_leaf() definitions Hongchen Zhang
2023-09-06  7:42 ` David Hildenbrand
2023-09-06  8:06   ` Hongchen Zhang
2023-09-06  8:08     ` David Hildenbrand
2023-09-06  8:22       ` Hongchen Zhang

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.