Re: [PATCH v2 06/10] mm/thp: unmap_mapping_page() to fix THP truncate_cleanup_page()

From: Hugh Dickins
Date: Wed Jun 09 2021 - 17:12:17 EST


On Wed, 9 Jun 2021, Yang Shi wrote:
> On Tue, Jun 8, 2021 at 9:19 PM Hugh Dickins <hughd@xxxxxxxxxx> wrote:
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -1361,7 +1361,17 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
> > else if (zap_huge_pmd(tlb, vma, pmd, addr))
> > goto next;
> > /* fall through */
> > + } else if (details && details->single_page &&
> > + PageTransCompound(details->single_page) &&
> > + next - addr == HPAGE_PMD_SIZE && pmd_none(*pmd)) {
> > + /*
> > + * Take and drop THP pmd lock so that we cannot return
> > + * prematurely, while zap_huge_pmd() has cleared *pmd,
> > + * but not yet decremented compound_mapcount().
> > + */
> > + spin_unlock(pmd_lock(tlb->mm, pmd));
>
> Just a nit, why not follow the style of patch #3 to have lock and
> unlock with separate lines?

Good point. Doing it on one line is my own preferred style (particularly
with the "take and drop lock" comment just above), carried forward from
before. I simply didn't think to change this one when I agreed to change
the other. You're right to question it: v3 of just this 06/10 follows.

And thank you to Kirill and to you for these rapid further reviews (and
for silently forgiving my screwup in omitting to Cc linux-mm and lkml
on those early ones).

Hugh