Skip to content

Commit 8890e03

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm/thp: update pmd_trans_huge to check for pmd_present
We need to make sure pmd_trans_huge returns false for a pmd migration entry. We mark the migration entry by clearing the _PAGE_PRESENT bit. We keep the _PAGE_PTE bit set to indicate a leaf page table entry. Hence we need to make sure we check for pmd_present() so that pmd_trans_huge won't return true on pmd migration entry. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 75646c4 commit 8890e03

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

arch/powerpc/include/asm/book3s/64/pgtable-64k.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*
1111
* Defined in such a way that we can optimize away code block at build time
1212
* if CONFIG_HUGETLB_PAGE=n.
13+
*
14+
* returns true for pmd migration entries, THP, devmap, hugetlb
15+
* But compile time dependent on CONFIG_HUGETLB_PAGE
1316
*/
1417
static inline int pmd_huge(pmd_t pmd)
1518
{

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,10 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp,
11361136
return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set);
11371137
}
11381138

1139+
/*
1140+
* returns true for pmd migration entries, THP, devmap, hugetlb
1141+
* But compile time dependent on THP config
1142+
*/
11391143
static inline int pmd_large(pmd_t pmd)
11401144
{
11411145
return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
@@ -1170,8 +1174,22 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
11701174
pmd_hugepage_update(mm, addr, pmdp, 0, _PAGE_PRIVILEGED);
11711175
}
11721176

1177+
/*
1178+
* Only returns true for a THP. False for pmd migration entry.
1179+
* We also need to return true when we come across a pte that
1180+
* in between a thp split. While splitting THP, we mark the pmd
1181+
* invalid (pmdp_invalidate()) before we set it with pte page
1182+
* address. A pmd_trans_huge() check against a pmd entry during that time
1183+
* should return true.
1184+
* We should not call this on a hugetlb entry. We should check for HugeTLB
1185+
* entry using vma->vm_flags
1186+
* The page table walk rule is explained in Documentation/vm/transhuge.rst
1187+
*/
11731188
static inline int pmd_trans_huge(pmd_t pmd)
11741189
{
1190+
if (!pmd_present(pmd))
1191+
return false;
1192+
11751193
if (radix_enabled())
11761194
return radix__pmd_trans_huge(pmd);
11771195
return hash__pmd_trans_huge(pmd);

0 commit comments

Comments
 (0)