Skip to content

Commit f69fa4c

Browse files
zhangzl2013tsbogend
authored andcommitted
mips: fix HUGETLB function without THP enabled
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 <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 18b8f5b commit f69fa4c

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

arch/mips/include/asm/pgtable.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@ extern void paging_init(void);
8686
*/
8787
#define pmd_phys(pmd) virt_to_phys((void *)pmd_val(pmd))
8888

89-
#define __pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
90-
#ifndef CONFIG_TRANSPARENT_HUGEPAGE
91-
#define pmd_page(pmd) __pmd_page(pmd)
92-
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
89+
#ifndef CONFIG_MIPS_HUGE_TLB_SUPPORT
90+
#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
91+
#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
9392

9493
#define pmd_page_vaddr(pmd) pmd_val(pmd)
9594

@@ -416,6 +415,25 @@ static inline pte_t pte_mkhuge(pte_t pte)
416415
pte_val(pte) |= _PAGE_HUGE;
417416
return pte;
418417
}
418+
419+
#define pmd_write pmd_write
420+
static inline int pmd_write(pmd_t pmd)
421+
{
422+
return !!(pmd_val(pmd) & _PAGE_WRITE);
423+
}
424+
425+
static inline unsigned long pmd_pfn(pmd_t pmd)
426+
{
427+
return pmd_val(pmd) >> _PFN_SHIFT;
428+
}
429+
430+
static inline struct page *pmd_page(pmd_t pmd)
431+
{
432+
if (pmd_val(pmd) & _PAGE_HUGE)
433+
return pfn_to_page(pmd_pfn(pmd));
434+
435+
return pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT);
436+
}
419437
#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
420438

421439
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
@@ -591,12 +609,6 @@ static inline pmd_t pmd_mkhuge(pmd_t pmd)
591609
extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
592610
pmd_t *pmdp, pmd_t pmd);
593611

594-
#define pmd_write pmd_write
595-
static inline int pmd_write(pmd_t pmd)
596-
{
597-
return !!(pmd_val(pmd) & _PAGE_WRITE);
598-
}
599-
600612
static inline pmd_t pmd_wrprotect(pmd_t pmd)
601613
{
602614
pmd_val(pmd) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
@@ -677,19 +689,6 @@ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
677689
/* Extern to avoid header file madness */
678690
extern pmd_t mk_pmd(struct page *page, pgprot_t prot);
679691

680-
static inline unsigned long pmd_pfn(pmd_t pmd)
681-
{
682-
return pmd_val(pmd) >> _PFN_SHIFT;
683-
}
684-
685-
static inline struct page *pmd_page(pmd_t pmd)
686-
{
687-
if (pmd_trans_huge(pmd))
688-
return pfn_to_page(pmd_pfn(pmd));
689-
690-
return pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT);
691-
}
692-
693692
static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
694693
{
695694
pmd_val(pmd) = (pmd_val(pmd) & (_PAGE_CHG_MASK | _PAGE_HUGE)) |

0 commit comments

Comments
 (0)