From: Mike Kravetz <mike.kravetz@oracle.com>
To: Wei Chen <harperchen1110@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>,
Matthew Wilcox <willy@infradead.org>,
hughd@google.com, dhowells@redhat.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: kernel BUG in page_try_dup_anon_rmap
Date: Thu, 20 Oct 2022 14:59:09 -0700 [thread overview]
Message-ID: <Y1HErfuQox2DfwxV@monkey> (raw)
In-Reply-To: <Y1F+aRB0/ZhHIlE8@monkey>
On 10/20/22 09:59, Mike Kravetz wrote:
> On 10/21/22 00:21, Wei Chen wrote:
> > Dear Vlastimil,
> >
> > Thank you for the reply. The bug persists in v6.0. Here is the
> > information. Luckily I got C reproducer this time.
>
> Ooh. Looks like the reproducer is doing a MADV_DONTNEED on a hugetlb mapping.
> That support was added somewhat recently (5.18). Not sure if it is related in
> any way. Have not looked at the code/implementation around write_protect_seq.
I verified that the new hugetlb MADV_DONTNEED is the root cause. :(
The reproducer calls madvise(MADV_DONTNEED) on the hugetlb mapping before
mapping any pages. madvise(MADV_DONTNEED) ends up calling:
zap_page_range
unmap_single_vma
__unmap_hugepage_range_final
__unmap_hugepage_range_final ends up clearing VM_MAYSHARE. This is
because it assumes the vma is going away and wants to prevent someone from
doing PMD sharing with the vma on it's way out. The causes confusion in
subsequent faults in the vma as sharing or private keys off VM_MAYSHARE.
We then end up with pages in the page table where page_mapping is NULL.
Somewhat good news is that I thought clearing of VM_MAYSHARE as done above
was kludgy and was able to remove it in 6.1 with the introduction of hugetlb
vma_lock for pmd sharing. So, should not be an issue in development
branches.
I'll come up with a way to fix for 5.18 to 6.0 kernels.
--
Mike Kravetz
parent reply other threads:[~2022-10-20 21:59 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <Y1F+aRB0/ZhHIlE8@monkey>]
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=Y1HErfuQox2DfwxV@monkey \
--to=mike.kravetz@oracle.com \
--cc=dhowells@redhat.com \
--cc=harperchen1110@gmail.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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