From: Zach O'Keefe <zokeefe@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Yang Shi <shy828301@gmail.com>,
vbabka@suse.cz, kirill.shutemov@linux.intel.com,
willy@infradead.org, linmiaohe@huawei.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [v5 PATCH 4/7] mm: thp: kill transparent_hugepage_active()
Date: Wed, 22 Jun 2022 10:52:10 -0700 [thread overview]
Message-ID: <YrNWyqxIKsQq1ky5@google.com> (raw)
In-Reply-To: <20220621175412.02d90df5f381de0cd676adf8@linux-foundation.org>
On 21 Jun 17:54, Andrew Morton wrote:
> On Tue, 21 Jun 2022 11:58:34 -0700 "Zach O'Keefe" <zokeefe@google.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
next prev parent reply other threads:[~2022-06-22 17:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 17:48 [mm-unstable v5 PATCH 0/7] Cleanup transhuge_xxx helpers Yang Shi
2022-06-16 17:48 ` [v5 PATCH 1/7] mm: khugepaged: check THP flag in hugepage_vma_check() Yang Shi
2022-06-16 17:48 ` [v5 PATCH 2/7] mm: thp: consolidate vma size check to transhuge_vma_suitable Yang Shi
2022-06-16 17:48 ` [v5 PATCH 3/7] mm: khugepaged: better comments for anon vma check in hugepage_vma_revalidate Yang Shi
2022-06-16 17:48 ` [v5 PATCH 4/7] mm: thp: kill transparent_hugepage_active() Yang Shi
2022-06-21 18:58 ` Zach O'Keefe
2022-06-22 0:54 ` Andrew Morton
2022-06-22 17:52 ` Zach O'Keefe [this message]
2022-06-16 17:48 ` [v5 PATCH 5/7] mm: thp: kill __transhuge_page_enabled() Yang Shi
2022-06-16 17:48 ` [v5 PATCH 6/7] mm: khugepaged: reorg some khugepaged helpers Yang Shi
2022-06-16 17:48 ` [v5 PATCH 7/7] doc: proc: fix the description to THPeligible Yang Shi
2022-06-16 23:08 ` [mm-unstable v5 PATCH 0/7] Cleanup transhuge_xxx helpers Zach O'Keefe
2022-06-17 17:54 ` Yang Shi
2022-06-21 21:07 ` Mike Kravetz
2022-06-21 22:43 ` Zach O'Keefe
2022-07-03 23:14 ` Andrew Morton
2022-07-05 19:45 ` Yang Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YrNWyqxIKsQq1ky5@google.com \
--to=zokeefe@google.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shy828301@gmail.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox