From: Nicholas Piggin <npiggin@gmail.com>
To: Daniel Axtens <dja@axtens.net>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/64s/radix: Fix unmapping huge vmaps when CONFIG_HUGETLB_PAGE=n
Date: Fri, 26 Nov 2021 20:55:08 +1000 [thread overview]
Message-ID: <1637923590.e73r0616uz.astroid@bobo.none> (raw)
In-Reply-To: <87tufzzbwh.fsf@linkitivity.dja.id.au>
Excerpts from Daniel Axtens's message of November 26, 2021 4:09 pm:
> Hi,
>
>> pmd_huge is defined out to false when HUGETLB_PAGE is not configured,
>> but the vmap code still installs huge PMDs. This leads to errors
>> encountering bad PMDs when vunmapping because it is not seen as a
>> huge PTE, and the bad PMD check catches it. The end result may not
>> be much more serious than some bad pmd warning messages, because the
>> pmd_none_or_clear_bad() does what we wanted and clears the huge PTE
>> anyway.
>
> Huh. So vmap seems to key off arch_vmap_p?d_supported which checks for
> radix and HAVE_ARCH_HUGE_VMAP.
>
>> Fix this by checking pmd_is_leaf(), which checks for a PTE regardless
>> of config options. The whole huge/large/leaf stuff is a tangled mess
>> but that's kernel-wide and not something we can improve much in
>> arch/powerpc code.
>
> I guess I'm a bit late to the party here because p?d_is_leaf was added
> in 2019 in commit d6eacedd1f0e ("powerpc/book3s: Use config independent
> helpers for page table walk") but why wouldn't we just make pmd_huge()
> not config dependent?
I guess so it constant folds code if hugetlbfs is not configured
(and maybe so !huge kernels would correctly print a bad PMD warning if
they got huge PMD in user mappings).
>
> Also, looking at that commit, there are a few places that might still
> throw warnings, e.g. find_linux_pte, find_current_mm_pte, pud_page which
> seem like they might still throw warnings if they were to encounter a
> huge vmap page:
>
> struct page *pud_page(pud_t pud)
> {
> if (pud_is_leaf(pud)) {
> VM_WARN_ON(!pud_huge(pud));
Oh, hmm. That is used in vmalloc.c so maybe that warning should be
removed as a false positive. Good catch.
> Do these functions need special treatment for huge vmappings()?
find_linux_pte etc could be called for vmaps. I'm not sure I see a
problem in that function.
Thanks,
Nick
>
> Apart from those questions, the patch itself makes sense to me and I can
> follow how it would fix a problem.
>
> Reviewed-by: Daniel Axtens <dja@axtens.net>
>
> Kind regards,
> Daniel
>
prev parent reply other threads:[~2021-11-26 10:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-26 2:28 [PATCH] powerpc/64s/radix: Fix unmapping huge vmaps when CONFIG_HUGETLB_PAGE=n Nicholas Piggin
2021-11-26 6:09 ` Daniel Axtens
2021-11-26 10:55 ` Nicholas Piggin [this message]
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=1637923590.e73r0616uz.astroid@bobo.none \
--to=npiggin@gmail.com \
--cc=dja@axtens.net \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).