[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YrNWyqxIKsQq1ky5@google.com>
Date: Wed, 22 Jun 2022 10:52:10 -0700
From: Zach O'Keefe <zokeefe@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Yang Shi <shy828301@...il.com>, vbabka@...e.cz,
kirill.shutemov@...ux.intel.com, willy@...radead.org,
linmiaohe@...wei.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [v5 PATCH 4/7] mm: thp: kill transparent_hugepage_active()
On 21 Jun 17:54, Andrew Morton wrote:
> On Tue, 21 Jun 2022 11:58:34 -0700 "Zach O'Keefe" <zokeefe@...gle.com> wrote:
>
> > > -bool transparent_hugepage_active(struct vm_area_struct *vma)
> > > +bool hugepage_vma_check(struct vm_area_struct *vma,
> > > + unsigned long vm_flags,
> > > + bool smaps)
> > > {
> > > - /* The addr is used to check if the vma size fits */
> > > - unsigned long addr = (vma->vm_end & HPAGE_PMD_MASK) - HPAGE_PMD_SIZE;
> > > + if (!transhuge_vma_enabled(vma, vm_flags))
> > > + return false;
> > > +
> >
> > During testing my work on top this patch, I found a small bug here.
> >
> > Namely, transhuge_vma_enabled() will check vma->vm_mm->flags (to see if
> > MMF_DISABLE_THP is set); however, for vDSO vmas, vma->vm_mm is NULL.
> >
> > Previously, transparent_hugepage_active() in smaps path would check
> > transhuge_vma_suitable() before checking these flags, which would fail for vDSO
> > vma since we'd take the !vma_is_anonymous() branch and find the vma (most
> > likely) wasn't suitably aligned (by chance ?).
> >
> > Anyways, I think we need to check vma->vm_mm.
>
> Like this?
>
> --- a/mm/huge_memory.c~mm-thp-kill-transparent_hugepage_active-fix
> +++ a/mm/huge_memory.c
> @@ -73,6 +73,9 @@ bool hugepage_vma_check(struct vm_area_s
> unsigned long vm_flags,
> bool smaps)
> {
> + if (!vma->vm_mm)
> + return false;
> +
> if (!transhuge_vma_enabled(vma, vm_flags))
> return false;
>
> _
>
Hey Andrew,
In principle, yes that would fix this. I don't know precisely how this fix will
be applied, but note that the subsequent patch "mm: thp: kill
__transhuge_page_enabled()" won't apply on top of this automatically. Also, I
wonder if we should add a comment for future travellers who wonder what kind of
vmas don't have an associated mm (it was news to me); though, I'm not sure if
vDSO is the only such case (though show_map_vma() seems to think so), or if this
just asking for stale comments down the road. Maybe it's fine as is.
Thanks,
Zach
Powered by blists - more mailing lists