From: Alistair Popple <apopple@nvidia.com>
To: Jordan Niethe <jniethe@nvidia.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
linux-mm@kvack.org, balbirs@nvidia.com, matthew.brost@intel.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, david@redhat.com,
ziy@nvidia.com, lorenzo.stoakes@oracle.com, lyude@redhat.com,
dakr@kernel.org, airlied@gmail.com, simona@ffwll.ch,
rcampbell@nvidia.com, mpenttil@redhat.com, willy@infradead.org
Subject: Re: [RFC PATCH 6/6] mm: Remove device private pages from the physical address space
Date: Tue, 2 Dec 2025 15:10:34 +1100 [thread overview]
Message-ID: <hurxchozs45ufuvp2qhj4d5qfhknfygeadmzgm35yzpdsfjccj@e7rulaymjhf6> (raw)
In-Reply-To: <1d4cb6e3-38d2-45d0-8e27-4f2b9dccd6cf@nvidia.com>
On 2025-12-02 at 13:28 +1100, Jordan Niethe <jniethe@nvidia.com> wrote...
> Hi,
>
> On 29/11/25 04:51, Jason Gunthorpe wrote:
> > On Fri, Nov 28, 2025 at 03:41:46PM +1100, Jordan Niethe wrote:
> > > Introduce helpers:
> > >
> > > - device_private_page_to_offset()
> > > - device_private_folio_to_offset()
> > >
> > > to take a given device private page / folio and return its offset within
> > > the device private address space (this is essentially a PFN within the
> > > device private address space).
> >
> > It would be nice if we rarely/never needed to see number space outside
> > the pte itself or the internal helpers..
>
> Outside of the PTE itself, one of the use cases for the PFNs themselves
> is range checking. Like we see in mm/page_vma_mapped.c:check_pte().
>
> >
> > Like, I don't think there should be stuff like this:
> >
> > > entry = make_writable_migration_device_private_entry(
> > > - page_to_pfn(page));
> > > + device_private_page_to_offset(page));
> >
> > make_writable_migration_device_private_entry() should accept the
> > struct page as the handle?
>
> That would be more clean - I'll give it a try.
>
> >
> > If it really is needed I think it should have its own dedicated type
> > and not be intermixed with normal pfns..
>
> One consideration here is for things like range checking the PFNs, the
> logic remains the same for device PFNs and the normal PFNs.
> If we represent the device PFNs as a unique type, ideally we'd like to
> still avoid introducing too much special handling.
Right, Jordan and I went back and forth on this a little bit prior to posting
but in the end I thought it wasn't worth the overhead of a new type for such a
limited number of use cases for which the actual logic ends up being the same
anyway.
Getting rid of passing the pfn to make_writable_migration_device_private_entry()
makes sense though and should address most of these cases.
> Potentially I could see something like a tagged union for memory indices
> like ...
>
> enum memory_index_type {
> MEMORY_INDEX_TYPE_PFN,
> MEMORY_INDEX_TYPE_DEVICE_MEMORY_INDEX,
> };
>
> union memory_index {
> unsigned long pfn;
> unsigned long device_memory_index;
> enum memory_index_type type;
> };
>
> ... if we wanted to introduce a dedicated type.
>
> Another possibility could be to avoid exposing the PFN for cases like
> this.
>
> For example if we went back to struct page_vma_mapped_walk containing a
> folio / struct page instead of a passing in a pfn then we could introduce
> some helper
> like ...
>
> bool swap_entry_contains_folio(struct folio *folio, swp_entry_t
> entry);
>
> ... that handles both device memory and normal memory and use that in
> check_pte().
>
> Thanks,
> Jordan.
>
>
> >
> > Jason
>
next prev parent reply other threads:[~2025-12-02 4:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 4:41 [RFC PATCH 0/6] Remove device private pages from " Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 1/6] mm/hmm: Add flag to track device private PFNs Jordan Niethe
2025-11-28 18:36 ` Matthew Brost
2025-12-02 1:20 ` Jordan Niethe
2025-12-03 4:25 ` Balbir Singh
2025-11-28 4:41 ` [RFC PATCH 2/6] mm/migrate_device: Add migrate PFN " Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 3/6] mm/page_vma_mapped: Add flags to page_vma_mapped_walk::pfn " Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 4/6] mm: Add a new swap type for migration entries with " Jordan Niethe
2025-12-01 2:43 ` Chih-En Lin
2025-12-02 1:42 ` Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 5/6] mm/util: Add flag to track device private PFNs in page snapshots Jordan Niethe
2025-11-28 4:41 ` [RFC PATCH 6/6] mm: Remove device private pages from the physical address space Jordan Niethe
2025-11-28 17:51 ` Jason Gunthorpe
2025-12-02 2:28 ` Jordan Niethe
2025-12-02 4:10 ` Alistair Popple [this message]
2025-11-28 7:40 ` [RFC PATCH 0/6] Remove device private pages from " David Hildenbrand (Red Hat)
2025-11-30 23:33 ` Alistair Popple
2025-11-28 15:09 ` Matthew Wilcox
2025-12-02 1:31 ` Jordan Niethe
2025-11-28 16:07 ` Mika Penttilä
2025-12-02 1:32 ` Jordan Niethe
2025-11-28 19:22 ` Matthew Brost
2025-11-30 23:23 ` Alistair Popple
2025-12-01 1:51 ` Matthew Brost
2025-12-02 1:40 ` Jordan Niethe
2025-12-02 22:20 ` Balbir Singh
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=hurxchozs45ufuvp2qhj4d5qfhknfygeadmzgm35yzpdsfjccj@e7rulaymjhf6 \
--to=apopple@nvidia.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=balbirs@nvidia.com \
--cc=dakr@kernel.org \
--cc=david@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=jniethe@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=lyude@redhat.com \
--cc=matthew.brost@intel.com \
--cc=mpenttil@redhat.com \
--cc=rcampbell@nvidia.com \
--cc=simona@ffwll.ch \
--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