Message ID | 20200812063358.369514-1-aneesh.kumar@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/16] powerpc/mm: Add DEBUG_VM WARN for pmd_clear | expand |
On 08/12/2020 12:03 PM, Aneesh Kumar K.V wrote: > With the hash page table, the kernel should not use pmd_clear for clearing > huge pte entries. Add a DEBUG_VM WARN to catch the wrong usage. > > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> This particular change is very much powerpc specific. Hence please drop it from the series which otherwise changes the page table test. Also, this series which is not a RFC, still lacks a proper cover letter with diff stats, tree/tag on which this applies, summary about the proposal etc. All those information will be helpful in reviewing this series better. For now, assuming that this applies cleanly on current master branch. But again, please do include a cover letter in the next version. > --- > arch/powerpc/include/asm/book3s/64/pgtable.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h > index 6de56c3b33c4..079211968987 100644 > --- a/arch/powerpc/include/asm/book3s/64/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h > @@ -868,6 +868,13 @@ static inline bool pte_ci(pte_t pte) > > static inline void pmd_clear(pmd_t *pmdp) > { > + if (IS_ENABLED(CONFIG_DEBUG_VM) && !radix_enabled()) { > + /* > + * Don't use this if we can possibly have a hash page table > + * entry mapping this. > + */ > + WARN_ON((pmd_val(*pmdp) & (H_PAGE_HASHPTE | _PAGE_PTE)) == (H_PAGE_HASHPTE | _PAGE_PTE)); > + } > *pmdp = __pmd(0); > } > > @@ -916,6 +923,13 @@ static inline int pmd_bad(pmd_t pmd) > > static inline void pud_clear(pud_t *pudp) > { > + if (IS_ENABLED(CONFIG_DEBUG_VM) && !radix_enabled()) { > + /* > + * Don't use this if we can possibly have a hash page table > + * entry mapping this. > + */ > + WARN_ON((pud_val(*pudp) & (H_PAGE_HASHPTE | _PAGE_PTE)) == (H_PAGE_HASHPTE | _PAGE_PTE)); > + } > *pudp = __pud(0); > } > >
On 8/12/20 1:16 PM, Anshuman Khandual wrote: > On 08/12/2020 12:03 PM, Aneesh Kumar K.V wrote: >> With the hash page table, the kernel should not use pmd_clear for clearing >> huge pte entries. Add a DEBUG_VM WARN to catch the wrong usage. >> >> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> > > This particular change is very much powerpc specific. Hence please drop it from > the series which otherwise changes the page table test. Also, this series which > is not a RFC, still lacks a proper cover letter with diff stats, tree/tag on > which this applies, summary about the proposal etc. All those information will > be helpful in reviewing this series better. For now, assuming that this applies > cleanly on current master branch. But again, please do include a cover letter > in the next version. The patch series include all sort of fixes. There is no special theme for the series. So all that the cover letter would have is "fixes to make debug_vm_pgtable work on ppc64" I tried to keep each patch simpler explaining why the current code is wrong. > >> --- >> arch/powerpc/include/asm/book3s/64/pgtable.h | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h >> index 6de56c3b33c4..079211968987 100644 >> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h >> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h >> @@ -868,6 +868,13 @@ static inline bool pte_ci(pte_t pte) >> >> static inline void pmd_clear(pmd_t *pmdp) >> { >> + if (IS_ENABLED(CONFIG_DEBUG_VM) && !radix_enabled()) { >> + /* >> + * Don't use this if we can possibly have a hash page table >> + * entry mapping this. >> + */ >> + WARN_ON((pmd_val(*pmdp) & (H_PAGE_HASHPTE | _PAGE_PTE)) == (H_PAGE_HASHPTE | _PAGE_PTE)); >> + } >> *pmdp = __pmd(0); >> } >> >> @@ -916,6 +923,13 @@ static inline int pmd_bad(pmd_t pmd) >> >> static inline void pud_clear(pud_t *pudp) >> { >> + if (IS_ENABLED(CONFIG_DEBUG_VM) && !radix_enabled()) { >> + /* >> + * Don't use this if we can possibly have a hash page table >> + * entry mapping this. >> + */ >> + WARN_ON((pud_val(*pudp) & (H_PAGE_HASHPTE | _PAGE_PTE)) == (H_PAGE_HASHPTE | _PAGE_PTE)); >> + } >> *pudp = __pud(0); >> } >> >> -aneesh
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 6de56c3b33c4..079211968987 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -868,6 +868,13 @@ static inline bool pte_ci(pte_t pte) static inline void pmd_clear(pmd_t *pmdp) { + if (IS_ENABLED(CONFIG_DEBUG_VM) && !radix_enabled()) { + /* + * Don't use this if we can possibly have a hash page table + * entry mapping this. + */ + WARN_ON((pmd_val(*pmdp) & (H_PAGE_HASHPTE | _PAGE_PTE)) == (H_PAGE_HASHPTE | _PAGE_PTE)); + } *pmdp = __pmd(0); } @@ -916,6 +923,13 @@ static inline int pmd_bad(pmd_t pmd) static inline void pud_clear(pud_t *pudp) { + if (IS_ENABLED(CONFIG_DEBUG_VM) && !radix_enabled()) { + /* + * Don't use this if we can possibly have a hash page table + * entry mapping this. + */ + WARN_ON((pud_val(*pudp) & (H_PAGE_HASHPTE | _PAGE_PTE)) == (H_PAGE_HASHPTE | _PAGE_PTE)); + } *pudp = __pud(0); }
With the hash page table, the kernel should not use pmd_clear for clearing huge pte entries. Add a DEBUG_VM WARN to catch the wrong usage. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> --- arch/powerpc/include/asm/book3s/64/pgtable.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)