[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <248ab74d-0f5c-4076-bfb2-a5eef8aca757@redhat.com>
Date: Wed, 5 Mar 2025 20:59:30 +0100
From: David Hildenbrand <david@...hat.com>
To: Dev Jain <dev.jain@....com>, willy@...radead.org, ziy@...dia.com,
hughd@...gle.com, ryan.roberts@....com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [QUESTION] Plain dereference and READ_ONCE() in fault handler
> 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
Powered by blists - more mailing lists