From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
syzbot+7d917f67c05066cec295@syzkaller.appspotmail.com,
Andrew Morton <akpm@linux-foundation.org>,
Jann Horn <jannh@google.com>
Subject: Re: [PATCH v1] mm/pagewalk: fix usage of pmd_leaf()/pud_leaf() without present check
Date: Tue, 15 Oct 2024 17:32:39 +0300 [thread overview]
Message-ID: <bu3aq2gxcfkjxocu3uzowvevlv6rgeihepc36cwuhh44xqydkc@3ghgml6xnlgx> (raw)
In-Reply-To: <20241015111236.1290921-1-david@redhat.com>
On Tue, Oct 15, 2024 at 01:12:36PM +0200, David Hildenbrand wrote:
> pmd_leaf()/pud_leaf() only implies a pmd_present()/pud_present() check on
> some architectures.
Should we clarify what behaviour we actually want from arch code?
> We really should check for
> pmd_present()/pud_present() first.
>
> This should explain the report we got on ppc64 (which has
> CONFIG_PGTABLE_HAS_HUGE_LEAVES set in the config) that triggered:
> VM_WARN_ON_ONCE(pmd_leaf(pmdp_get_lockless(pmdp)));
>
> Likely we had a PMD migration entry for which pmd_leaf() did not
> trigger. We raced with restoring the PMD migration entry, and suddenly
> saw a pmd_leaf(). In this case, pte_offset_map_lock() saved us from more
> trouble, because it rechecks the PMD value, but we would not have processed
> the migration entry -- which is not too bad because the only user of
> FW_MIGRATION is KSM for unsharing, and KSM only applies to small folios.
>
> Further, we shouldn't re-read the PMD/PUD value for our warning, the
> primary purpose of the VM_WARN_ON_ONCE() is to find spurious use of
> pmd_leaf()/pud_leaf() without CONFIG_PGTABLE_HAS_HUGE_LEAVES.
>
> As a side note, we are currently not implementing FW_MIGRATION support
> for PUD migration entries, which likely should exist due to hugetlb. Add
> a TODO so this won't fall through the cracks if more FW_MIGRATION users
> get added.
>
> Fixes: aa39ca6940f1 ("mm/pagewalk: introduce folio_walk_start() + folio_walk_end()")
> Reported-by: syzbot+7d917f67c05066cec295@syzkaller.appspotmail.com
> Closes: https://lkml.kernel.org/r/670d3248.050a0220.3e960.0064.GAE@google.com
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Jann Horn <jannh@google.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2024-10-15 14:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 11:12 David Hildenbrand
2024-10-15 13:13 ` David Hildenbrand
2024-10-16 10:58 ` Qi Zheng
2024-10-16 11:05 ` David Hildenbrand
2024-10-16 22:44 ` Andrew Morton
2024-10-15 14:32 ` Kirill A. Shutemov [this message]
2024-10-15 14:40 ` David Hildenbrand
2024-10-15 14:43 ` Jann Horn
2024-10-15 15:45 ` Zi Yan
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=bu3aq2gxcfkjxocu3uzowvevlv6rgeihepc36cwuhh44xqydkc@3ghgml6xnlgx \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=syzbot+7d917f67c05066cec295@syzkaller.appspotmail.com \
/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