Message ID | 20200623073017.1951-4-bharata@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | powerpc/mm/radix: Memory unplug fixes | expand |
Bharata B Rao <bharata@linux.ibm.com> writes: > remove_pagetable() isn't freeing PUD table. This causes memory > leak during memory unplug. Fix this. > Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> > Signed-off-by: Bharata B Rao <bharata@linux.ibm.com> > --- > arch/powerpc/mm/book3s64/radix_pgtable.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c > index 58e42393d5e8..8ec2110eaa1a 100644 > --- a/arch/powerpc/mm/book3s64/radix_pgtable.c > +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c > @@ -782,6 +782,21 @@ static void free_pmd_table(pmd_t *pmd_start, pud_t *pud) > pud_clear(pud); > } > > +static void free_pud_table(pud_t *pud_start, p4d_t *p4d) > +{ > + pud_t *pud; > + int i; > + > + for (i = 0; i < PTRS_PER_PUD; i++) { > + pud = pud_start + i; > + if (!pud_none(*pud)) > + return; Should we do a VM_WARN() here? > + } > + > + pud_free(&init_mm, pud_start); > + p4d_clear(p4d); > +} > + > struct change_mapping_params { > pte_t *pte; > unsigned long start; > @@ -956,6 +971,7 @@ static void __meminit remove_pagetable(unsigned long start, unsigned long end) > > pud_base = (pud_t *)p4d_page_vaddr(*p4d); > remove_pud_table(pud_base, addr, next); > + free_pud_table(pud_base, p4d); > } > > spin_unlock(&init_mm.page_table_lock); > -- > 2.21.3
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index 58e42393d5e8..8ec2110eaa1a 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -782,6 +782,21 @@ static void free_pmd_table(pmd_t *pmd_start, pud_t *pud) pud_clear(pud); } +static void free_pud_table(pud_t *pud_start, p4d_t *p4d) +{ + pud_t *pud; + int i; + + for (i = 0; i < PTRS_PER_PUD; i++) { + pud = pud_start + i; + if (!pud_none(*pud)) + return; + } + + pud_free(&init_mm, pud_start); + p4d_clear(p4d); +} + struct change_mapping_params { pte_t *pte; unsigned long start; @@ -956,6 +971,7 @@ static void __meminit remove_pagetable(unsigned long start, unsigned long end) pud_base = (pud_t *)p4d_page_vaddr(*p4d); remove_pud_table(pud_base, addr, next); + free_pud_table(pud_base, p4d); } spin_unlock(&init_mm.page_table_lock);
remove_pagetable() isn't freeing PUD table. This causes memory leak during memory unplug. Fix this. Signed-off-by: Bharata B Rao <bharata@linux.ibm.com> --- arch/powerpc/mm/book3s64/radix_pgtable.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)