linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mips: fix HUGETLB function without THP enabled
@ 2021-11-02  8:24 Zhaolong Zhang
  2021-11-02 10:20 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 3+ messages in thread
From: Zhaolong Zhang @ 2021-11-02  8:24 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Alexander Lobakin, Yanteng Si, linux-mips,
	Zhaolong Zhang
  Cc: linux-kernel

ltp test futex_wake04 without THP enabled leads to below bt:
  [<ffffffff80a03728>] BUG+0x0/0x8
  [<ffffffff80a0624c>] internal_get_user_pages_fast+0x81c/0x820
  [<ffffffff8093ac18>] get_futex_key+0xa0/0x480
  [<ffffffff8093b074>] futex_wait_setup+0x7c/0x1a8
  [<ffffffff8093b2c0>] futex_wait+0x120/0x228
  [<ffffffff8093dbe8>] do_futex+0x140/0xbd8
  [<ffffffff8093e78c>] sys_futex+0x10c/0x1c0
  [<ffffffff808703d0>] syscall_common+0x34/0x58

Move pmd_write() and pmd_page() from TRANSPARENT_HUGEPAGE scope to
MIPS_HUGE_TLB_SUPPORT scope, because both THP and HUGETLB will need
them.

Signed-off-by: Zhaolong Zhang <zhangzl2013@126.com>
---
 arch/mips/include/asm/pgtable.h | 40 +++++++++++++++++----------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index 804889b70965..1fcf4be5cd20 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -86,10 +86,12 @@ extern void paging_init(void);
  */
 #define pmd_phys(pmd)		virt_to_phys((void *)pmd_val(pmd))
 
+#ifndef CONFIG_MIPS_HUGE_TLB_SUPPORT
 #define __pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
 #define pmd_page(pmd)		__pmd_page(pmd)
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
+#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
 
 #define pmd_page_vaddr(pmd)	pmd_val(pmd)
 
@@ -416,6 +418,25 @@ static inline pte_t pte_mkhuge(pte_t pte)
 	pte_val(pte) |= _PAGE_HUGE;
 	return pte;
 }
+
+#define pmd_write pmd_write
+static inline int pmd_write(pmd_t pmd)
+{
+	return !!(pmd_val(pmd) & _PAGE_WRITE);
+}
+
+static inline unsigned long pmd_pfn(pmd_t pmd)
+{
+	return pmd_val(pmd) >> _PFN_SHIFT;
+}
+
+static inline struct page *pmd_page(pmd_t pmd)
+{
+	if (pmd_val(pmd) & _PAGE_HUGE)
+		return pfn_to_page(pmd_pfn(pmd));
+
+	return pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT);
+}
 #endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
 
 #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
@@ -591,12 +612,6 @@ static inline pmd_t pmd_mkhuge(pmd_t pmd)
 extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
 		       pmd_t *pmdp, pmd_t pmd);
 
-#define pmd_write pmd_write
-static inline int pmd_write(pmd_t pmd)
-{
-	return !!(pmd_val(pmd) & _PAGE_WRITE);
-}
-
 static inline pmd_t pmd_wrprotect(pmd_t pmd)
 {
 	pmd_val(pmd) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
@@ -677,19 +692,6 @@ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
 /* Extern to avoid header file madness */
 extern pmd_t mk_pmd(struct page *page, pgprot_t prot);
 
-static inline unsigned long pmd_pfn(pmd_t pmd)
-{
-	return pmd_val(pmd) >> _PFN_SHIFT;
-}
-
-static inline struct page *pmd_page(pmd_t pmd)
-{
-	if (pmd_trans_huge(pmd))
-		return pfn_to_page(pmd_pfn(pmd));
-
-	return pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT);
-}
-
 static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
 {
 	pmd_val(pmd) = (pmd_val(pmd) & (_PAGE_CHG_MASK | _PAGE_HUGE)) |
-- 
2.27.0


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

* Re: [PATCH] mips: fix HUGETLB function without THP enabled
  2021-11-02  8:24 [PATCH] mips: fix HUGETLB function without THP enabled Zhaolong Zhang
@ 2021-11-02 10:20 ` Thomas Bogendoerfer
  2021-11-02 12:17   ` Zhaolong Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Bogendoerfer @ 2021-11-02 10:20 UTC (permalink / raw)
  To: Zhaolong Zhang; +Cc: Alexander Lobakin, Yanteng Si, linux-mips, linux-kernel

On Tue, Nov 02, 2021 at 04:24:37PM +0800, Zhaolong Zhang wrote:
> ltp test futex_wake04 without THP enabled leads to below bt:
>   [<ffffffff80a03728>] BUG+0x0/0x8
>   [<ffffffff80a0624c>] internal_get_user_pages_fast+0x81c/0x820
>   [<ffffffff8093ac18>] get_futex_key+0xa0/0x480
>   [<ffffffff8093b074>] futex_wait_setup+0x7c/0x1a8
>   [<ffffffff8093b2c0>] futex_wait+0x120/0x228
>   [<ffffffff8093dbe8>] do_futex+0x140/0xbd8
>   [<ffffffff8093e78c>] sys_futex+0x10c/0x1c0
>   [<ffffffff808703d0>] syscall_common+0x34/0x58
> 
> Move pmd_write() and pmd_page() from TRANSPARENT_HUGEPAGE scope to
> MIPS_HUGE_TLB_SUPPORT scope, because both THP and HUGETLB will need
> them.
> 
> Signed-off-by: Zhaolong Zhang <zhangzl2013@126.com>
> ---
>  arch/mips/include/asm/pgtable.h | 40 +++++++++++++++++----------------
>  1 file changed, 21 insertions(+), 19 deletions(-)

applied to mips-next.

> 
> diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
> index 804889b70965..1fcf4be5cd20 100644
> --- a/arch/mips/include/asm/pgtable.h
> +++ b/arch/mips/include/asm/pgtable.h
> @@ -86,10 +86,12 @@ extern void paging_init(void);
>   */
>  #define pmd_phys(pmd)		virt_to_phys((void *)pmd_val(pmd))
>  
> +#ifndef CONFIG_MIPS_HUGE_TLB_SUPPORT
>  #define __pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
>  #ifndef CONFIG_TRANSPARENT_HUGEPAGE
>  #define pmd_page(pmd)		__pmd_page(pmd)
>  #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
> +#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */

While applying I've simplified that hunk to

-#define __pmd_page(pmd)                (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
-#ifndef CONFIG_TRANSPARENT_HUGEPAGE
-#define pmd_page(pmd)          __pmd_page(pmd)
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
+#ifndef CONFIG_MIPS_HUGE_TLB_SUPPORT
+#define pmd_page(pmd)          (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
+#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

* Re: [PATCH] mips: fix HUGETLB function without THP enabled
  2021-11-02 10:20 ` Thomas Bogendoerfer
@ 2021-11-02 12:17   ` Zhaolong Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Zhaolong Zhang @ 2021-11-02 12:17 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Alexander Lobakin, Yanteng Si, linux-mips, linux-kernel


At 2021-11-02 18:20:51, "Thomas Bogendoerfer" <tsbogend@alpha.franken.de> wrote:
>On Tue, Nov 02, 2021 at 04:24:37PM +0800, Zhaolong Zhang wrote:
>> ltp test futex_wake04 without THP enabled leads to below bt:
>>   [<ffffffff80a03728>] BUG+0x0/0x8
>>   [<ffffffff80a0624c>] internal_get_user_pages_fast+0x81c/0x820
>>   [<ffffffff8093ac18>] get_futex_key+0xa0/0x480
>>   [<ffffffff8093b074>] futex_wait_setup+0x7c/0x1a8
>>   [<ffffffff8093b2c0>] futex_wait+0x120/0x228
>>   [<ffffffff8093dbe8>] do_futex+0x140/0xbd8
>>   [<ffffffff8093e78c>] sys_futex+0x10c/0x1c0
>>   [<ffffffff808703d0>] syscall_common+0x34/0x58
>> 
>> Move pmd_write() and pmd_page() from TRANSPARENT_HUGEPAGE scope to
>> MIPS_HUGE_TLB_SUPPORT scope, because both THP and HUGETLB will need
>> them.
>> 
>> Signed-off-by: Zhaolong Zhang <zhangzl2013@126.com>
>> ---
>>  arch/mips/include/asm/pgtable.h | 40 +++++++++++++++++----------------
>>  1 file changed, 21 insertions(+), 19 deletions(-)
>
>applied to mips-next.
>
>> 
>> diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
>> index 804889b70965..1fcf4be5cd20 100644
>> --- a/arch/mips/include/asm/pgtable.h
>> +++ b/arch/mips/include/asm/pgtable.h
>> @@ -86,10 +86,12 @@ extern void paging_init(void);
>>   */
>>  #define pmd_phys(pmd)		virt_to_phys((void *)pmd_val(pmd))
>>  
>> +#ifndef CONFIG_MIPS_HUGE_TLB_SUPPORT
>>  #define __pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
>>  #ifndef CONFIG_TRANSPARENT_HUGEPAGE
>>  #define pmd_page(pmd)		__pmd_page(pmd)
>>  #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
>> +#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
>
>While applying I've simplified that hunk to
>
>-#define __pmd_page(pmd)                (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
>-#ifndef CONFIG_TRANSPARENT_HUGEPAGE
>-#define pmd_page(pmd)          __pmd_page(pmd)
>-#endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
>+#ifndef CONFIG_MIPS_HUGE_TLB_SUPPORT
>+#define pmd_page(pmd)          (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
>+#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
>

It is much better.
Thanks for your kind reply.

Regards,
Zhaolong

>Thomas.
>
>-- 
>Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
>good idea.                                                [ RFC1925, 2.3 ]

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

end of thread, other threads:[~2021-11-02 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02  8:24 [PATCH] mips: fix HUGETLB function without THP enabled Zhaolong Zhang
2021-11-02 10:20 ` Thomas Bogendoerfer
2021-11-02 12:17   ` Zhaolong Zhang

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).