From: David Hildenbrand <david@redhat.com>
To: Dev Jain <dev.jain@arm.com>,
willy@infradead.org, ziy@nvidia.com, hughd@google.com,
ryan.roberts@arm.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [QUESTION] Plain dereference and READ_ONCE() in fault handler
Date: Wed, 5 Mar 2025 20:59:30 +0100 [thread overview]
Message-ID: <248ab74d-0f5c-4076-bfb2-a5eef8aca757@redhat.com> (raw)
In-Reply-To: <3c3f3cfe-9fa7-41d7-9759-cc67306f13f5@arm.com>
> Oh I just looked at the arm64 definition and assumed ptep_get_lockless()
> == READ_ONCE() :) Now this makes sense. So I am guessing that we can
> still get away with a *vmf.pmd on 64-bit arches?
>
> A separate question: When taking the create_huge_pmd() path with a read
> fault and after taking the pmd lock, why shouldn't we check with
> pmd_none(pmdp_get_lockless(vmf.pmd)) instead of plain *vmf.pmd...surely
> now we must load the actual correct value from memory since we are
> committing into mapping the huge zero folio?
So you mean we go via create_huge_pmd()->do_huge_pmd_anonymous_page(),
to then end up in the path where we do the mm_get_huge_zero_folio().
If we hold the PMD lock, pmd_none() cannot change, so there is no need
for the lockless variant?
So with the lock, you get the actual correct value that cannot change.
> And after looking somewhat more, why even is a pmd_none(*pmd) there in
> set_huge_zero_folio()...it should be the responsibility of the caller to
> verify this? Any caller will just assume that it got the huge zero folio
> mapped so this check should be redundant.
Yes, looks more like a VM_WARN_ON() scenario. So I agree that that one
does not sound useful. (*maybe* the compiler is smart enough to optimize
that check out)
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2025-03-05 19:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 10:21 Dev Jain
2025-03-05 10:46 ` David Hildenbrand
2025-03-05 14:12 ` Matthew Wilcox
2025-03-05 15:02 ` Dev Jain
2025-03-05 19:59 ` David Hildenbrand [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=248ab74d-0f5c-4076-bfb2-a5eef8aca757@redhat.com \
--to=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.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