s390/mm: fix pud table accounting
Subsystems (3)
PATCH 1/1 s390/mm: fix pud table accounting
With "mm: account pud page tables" and "mm: consolidate page table accounting" pud page table accounting was introduced which now results in tons of warnings like this one on s390:
BUG: non-zero pgtables_bytes on freeing mm: -16384
Reason for this are our run-time folded page tables: by default new processes start with three page table levels where the allocated pgd is the same as the first pud. In this case there won't ever be a pud allocated and therefore mm_inc_nr_puds() will also never be called.
However when freeing the address space free_pud_range() will call exactly once mm_dec_nr_puds() which leads to misaccounting.
Therefore call mm_inc_nr_puds() within init_new_context() to fix this. This is the same like we have it already for processes that run with two page table levels (aka compat processes).
While at it also adjust the comment, since there is no "mm->nr_pmds" anymore.
--- arch/s390/include/asm/mmu_context.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/include/asm/mmu_context.h +3 -1
@@ -43,6 +43,8 @@ static inline int init_new_context(struct task_struct *tsk, mm->context.asce_limit =STACK_TOP_MAX ; mm->context.asce =__pa (mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_REGION3; +/* pgd_alloc() did not account this pud */ +mm_inc_nr_puds (mm);break ;case -PAGE_SIZE :/* forked 5-level task, set new asce with new_mm->pgd */
@@ -58,7 +60,7 @@ static inline int init_new_context(struct task_struct *tsk,/* forked 2-level compat task, set new asce with new mm->pgd */ mm->context.asce =__pa (mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; -/* pgd_alloc() did not increase mm->nr_pmds */ +/* pgd_alloc() did not account this pmd */ mm_inc_nr_pmds (mm); }crst_table_init ((unsigned long *) mm->pgd,pgd_entry_type (mm));
Signature · 1 line
2.13.5
Quoted 14 lines · Heiko Carstens
With "mm: account pud page tables" and "mm: consolidate page table accounting" pud page table accounting was introduced which now results in tons of warnings like this one on s390:
BUG: non-zero pgtables_bytes on freeing mm: -16384Reason for this are our run-time folded page tables: by default new processes start with three page table levels where the allocated pgd is the same as the first pud. In this case there won't ever be a pud allocated and therefore
mm_inc_nr_puds()will also never be called.However when freeing the address space
free_pud_range()will call exactly oncemm_dec_nr_puds()which leads to misaccounting.
Quoted 6 lines
Therefore call
mm_inc_nr_puds()withininit_new_context()to fix this. This is the same like we have it already for processes that run with two page table levels (aka compat processes).While at it also adjust the comment, since there is no "
mm->nr_pmds" anymore.
Subtle...
Thanks for the fix, I didn't have any idea about this when reviewing.
Quoted 34 lines
Cc Kirill A. Shutemov <[email protected]>Cc Michal Hocko <[email protected]>Cc Gerald Schaefer <[email protected]>Cc Martin Schwidefsky <[email protected]>Signed-off-by Heiko Carstens <[email protected]>--- arch/s390/include/asm/mmu_context.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/s390/include/asm/mmu_context.h +3
-1@@ -43,6 +43,8 @@ static inline int init_new_context(struct task_struct *tsk, mm->context.asce_limit =STACK_TOP_MAX ; mm->context.asce =__pa (mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_REGION3; +/* pgd_alloc() did not account this pud */ +mm_inc_nr_puds (mm);break ;case -PAGE_SIZE :/* forked 5-level task, set new asce with new_mm->pgd */ @@ -58,7 +60,7 @@ static inline int init_new_context(struct task_struct *tsk,/* forked 2-level compat task, set new asce with new mm->pgd */ mm->context.asce =__pa (mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; -/* pgd_alloc() did not increase mm->nr_pmds */ +/* pgd_alloc() did not account this pmd */ mm_inc_nr_pmds (mm); }crst_table_init ((unsigned long *) mm->pgd,pgd_entry_type (mm));Signature · 1 line
2.13.5
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · Heiko Carstens
With "mm: account pud page tables" and "mm: consolidate page table accounting" pud page table accounting was introduced which now results in tons of warnings like this one on s390:
BUG: non-zero pgtables_bytes on freeing mm: -16384Reason for this are our run-time folded page tables: by default new processes start with three page table levels where the allocated pgd is the same as the first pud. In this case there won't ever be a pud allocated and therefore
mm_inc_nr_puds()will also never be called.However when freeing the address space
free_pud_range()will call exactly oncemm_dec_nr_puds()which leads to misaccounting.
Quoted 6 lines
Therefore call
mm_inc_nr_puds()withininit_new_context()to fix this. This is the same like we have it already for processes that run with two page table levels (aka compat processes).While at it also adjust the comment, since there is no "
mm->nr_pmds" anymore.
Thanks for tracking it down.
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>