From: Andrew Morton <akpm@linux-foundation.org>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: "SeongJae Park" <sj@kernel.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
"Mike Rapoport" <rppt@kernel.org>, "Yu Zhao" <yuzhao@google.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Dimitri Sivanich" <dimitri.sivanich@hpe.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Oleksandr Tyshchenko" <oleksandr_tyshchenko@epam.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Mike Kravetz" <mike.kravetz@oracle.com>,
"Muchun Song" <muchun.song@linux.dev>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Ian Rogers" <irogers@google.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Jérôme Glisse" <jglisse@redhat.com>,
"Andrey Ryabinin" <ryabinin.a.a@gmail.com>,
"Alexander Potapenko" <glider@google.com>,
"Andrey Konovalov" <andreyknvl@gmail.com>,
"Dmitry Vyukov" <dvyukov@google.com>,
"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeelb@google.com>,
"Naoya Horiguchi" <naoya.horiguchi@nec.com>,
"Miaohe Lin" <linmiaohe@huawei.com>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Christoph Hellwig" <hch@infradead.org>,
"Lorenzo Stoakes" <lstoakes@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
damon@lists.linux.dev
Subject: Re: [PATCH v3 0/3] Encapsulate PTE contents from non-arch code
Date: Mon, 12 Jun 2023 13:16:56 -0700 [thread overview]
Message-ID: <20230612131656.2ba4f95865f27e6b3b984936@linux-foundation.org> (raw)
In-Reply-To: <20230612151545.3317766-1-ryan.roberts@arm.com>
On Mon, 12 Jun 2023 16:15:42 +0100 Ryan Roberts <ryan.roberts@arm.com> wrote:
> Hi All,
>
> (Including wider audience this time since changes touch a fair few subsystems)
>
> This is the second half of v3 of a series to improve the encapsulation of pte
> entries by disallowing non-arch code from directly dereferencing pte_t pointers.
That's basically all we have here for [0/N] cover letter content. I
stole some words from the [3/3] changelog, so we now have:
: A series to improve the encapsulation of pte entries by disallowing
: non-arch code from directly dereferencing pte_t pointers.
:
: This means that by default, the accesses change from a C dereference to a
: READ_ONCE(). This is technically the correct thing to do since where
: pgtables are modified by HW (for access/dirty) they are volatile and
: therefore we should always ensure READ_ONCE() semantics.
:
: But more importantly, by always using the helper, it can be overridden by
: the architecture to fully encapsulate the contents of the pte. Arch code
: is deliberately not converted, as the arch code knows best. It is
: intended that arch code (arm64) will override the default with its own
: implementation that can (e.g.) hide certain bits from the core code, or
: determine young/dirty status by mixing in state from another source.
> Based on earlier feedback, I split the series in 2; the first part, fixes for
> existing bugs, was already posted at [3] and merged into mm-stable. This second
> part contains the conversion from direct dereferences to instead use
> ptep_get()/ptep_get_lockless().
>
> See the v1 cover letter at [1] for rationale for this work.
>
> Based on feedback at v2, I've removed the new ptep_deref() helper I originally
> added, and am now using the existing ptep_get() and ptep_get_lockless() helpers.
> Testing on Ampere Altra (arm64) showed no difference in performance when using
> ptep_deref() (*pte) vs ptep_get() (READ_ONCE(*pte)).
>
> Patches are based on mm-unstable (49e038b1919e) and a branch is available at [4]
> (Let me know if this is the wrong branch to target - I'm still not familiar with
> the details of the mm- dev process!). Note that Hugh Dickins's "mm: allow
> pte_offset_map[_lock]() to fail" (now in mm-unstable) patch set caused a number
> of conflicts which I've resolved. But due to that, you won't be able to apply
> these patches on top of Linus's tree. I have an alternate branch on top of
> v6.4-rc6 at [5].
Yep, that's all great, thanks.
Is there some clever trick we can do to prevent new open-coded derefs
of pte_t* from being introduced?
I suppose we could convert pte_t to a single-member struct to force a
compile error. That struct will get passed by value to ptep_get() so
that's OK. But this isn't viable unless/until all architectures are
converted :(
Or we rely upon Ryan to grep the tree occasionally ;)
next prev parent reply other threads:[~2023-06-12 20:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 15:15 Ryan Roberts
2023-06-12 15:15 ` [PATCH v3 1/3] mm: ptdump should use ptep_get_lockless() Ryan Roberts
2023-06-12 15:15 ` [PATCH v3 2/3] mm: Move ptep_get() and pmdp_get() helpers Ryan Roberts
2023-06-12 15:15 ` [PATCH v3 3/3] mm: ptep_get() conversion Ryan Roberts
2023-06-12 21:27 ` SeongJae Park
2023-06-12 20:16 ` Andrew Morton [this message]
2023-06-13 8:43 ` [PATCH v3 0/3] Encapsulate PTE contents from non-arch code Ryan Roberts
2023-06-13 2:16 ` Muchun Song
2023-06-13 8:52 ` Ryan Roberts
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=20230612131656.2ba4f95865f27e6b3b984936@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adrian.hunter@intel.com \
--cc=airlied@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andreyknvl@gmail.com \
--cc=brauner@kernel.org \
--cc=damon@lists.linux.dev \
--cc=daniel@ffwll.ch \
--cc=dimitri.sivanich@hpe.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=irogers@google.com \
--cc=jgg@ziepe.ca \
--cc=jglisse@redhat.com \
--cc=jolsa@kernel.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=mark.rutland@arm.com \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=namhyung@kernel.org \
--cc=naoya.horiguchi@nec.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=pasha.tatashin@soleen.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=shakeelb@google.com \
--cc=sj@kernel.org \
--cc=urezki@gmail.com \
--cc=vincenzo.frascino@arm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=yuzhao@google.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