[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <419c7a17-b20f-41b9-88af-f9f83c8611ef@nvidia.com>
Date: Tue, 22 Jul 2025 08:42:30 +0300
From: Yonatan Maman <ymaman@...dia.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: Jérôme Glisse <jglisse@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>, Jason Gunthorpe <jgg@...pe.ca>,
Leon Romanovsky <leon@...nel.org>, Lyude Paul <lyude@...hat.com>,
Danilo Krummrich <dakr@...nel.org>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, Alistair Popple <apopple@...dia.com>,
Ben Skeggs <bskeggs@...dia.com>, Michael Guralnik <michaelgur@...dia.com>,
Or Har-Toov <ohartoov@...dia.com>, Daisuke Matsuda <dskmtsd@...il.com>,
Shay Drory <shayd@...dia.com>, linux-mm@...ck.org,
linux-rdma@...r.kernel.org, dri-devel@...ts.freedesktop.org,
nouveau@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Gal Shalom <GalShalom@...dia.com>
Subject: Re: [PATCH v2 1/5] mm/hmm: HMM API to enable P2P DMA for device
private pages
On 21/07/2025 9:59, Christoph Hellwig wrote:
> On Fri, Jul 18, 2025 at 02:51:08PM +0300, Yonatan Maman wrote:
>> From: Yonatan Maman <Ymaman@...dia.com>
>>
>> hmm_range_fault() by default triggered a page fault on device private
>> when HMM_PFN_REQ_FAULT flag was set. pages, migrating them to RAM. In some
>> cases, such as with RDMA devices, the migration overhead between the
>> device (e.g., GPU) and the CPU, and vice-versa, significantly degrades
>> performance. Thus, enabling Peer-to-Peer (P2P) DMA access for device
>> private page might be crucial for minimizing data transfer overhead.
>
> You don't enable DMA for device private pages. You allow discovering
> a DMAable alias for device private pages.
>
> Also absolutely nothing GPU specific here.
>
Ok, understood, I will change it (v3).
>> + /*
>> + * Don't fault in device private pages owned by the caller,
>> + * just report the PFN.
>> + */
>> + if (pgmap->owner == range->dev_private_owner) {
>> + *hmm_pfn = swp_offset_pfn(entry);
>> + goto found;
>
> This is dangerous because it mixes actual DMAable alias PFNs with the
> device private fake PFNs. Maybe your hardware / driver can handle
> it, but just leaking this out is not a good idea.
>
In the current implementation, regular pci_p2p pages are returned as-is
from hmm_range_fault() - for virtual address backed by pci_p2p page, it
will return the corresponding PFN.
That said, we can mark these via the hmm_pfn output flags so the caller
can handle them appropriately.
>> + hmm_handle_device_private(range, pfn_req_flags, entry, hmm_pfn))
>
> Overly long line here.
>
will be fixed (v3)
Powered by blists - more mailing lists