Re: [Nouveau] [PATCH v9 07/10] mm: Device exclusive memory access

2021-05-25 Thread Balbir Singh
ce exclusive access? Do we have any numbers for the worst case page fault latency when something is marked away for exclusive access? I presume for now this is anonymous memory only? SWP_DEVICE_EXCLUSIVE would only impact the address space of programs using the GPU. Should the exclusively marked range live i

Re: [Nouveau] [PATCH v9 07/10] mm: Device exclusive memory access

2021-06-02 Thread Balbir Singh
On Wed, May 26, 2021 at 12:17:18AM -0700, John Hubbard wrote: > On 5/25/21 4:51 AM, Balbir Singh wrote: > ... > > > How beneficial is this code to nouveau users? I see that it permits a > > > part of OpenCL to be implemented, but how useful/important is this in > > &

Re: [RFC 00/11] THP support for zone device pages

2025-03-06 Thread Balbir Singh
On 3/7/25 10:08, Matthew Brost wrote: > On Thu, Mar 06, 2025 at 03:42:28PM +1100, Balbir Singh wrote: > > This is an exciting series to see. As of today, we have just merged this > series into the DRM subsystem / Xe [2], which adds very basic SVM > support. One of the performance

[RFC 00/11] THP support for zone device pages

2025-03-05 Thread Balbir Singh
c: Matthew Wilcox Cc: Peter Xu Cc: Zi Yan Cc: Kefeng Wang Cc: Jane Chu Cc: Alistair Popple Cc: Donet Tom Balbir Singh (11): mm/zone_device: support large zone device private folios mm/migrate_device: flags for selecting device private THP pages mm/thp: zone_device awareness in THP han

[RFC 02/11] mm/migrate_device: flags for selecting device private THP pages

2025-03-05 Thread Balbir Singh
Add flags to mark zone device migration pages. MIGRATE_VMA_SELECT_COMPOUND will be used to select THP pages during migrate_vma_setup() and MIGRATE_PFN_COMPOUND will make migrating device pages as compound pages during device pfn migration. Signed-off-by: Balbir Singh --- include/linux

[RFC 06/11] lib/test_hmm: test cases and support for zone device private THP

2025-03-05 Thread Balbir Singh
will be added in future patches in this series. Signed-off-by: Balbir Singh --- lib/test_hmm.c | 342 +++-- 1 file changed, 273 insertions(+), 69 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 5b144bc5c4ec..a81d2f8a0426 100644 --- a/lib

[RFC 07/11] mm/memremap: Add folio_split support

2025-03-05 Thread Balbir Singh
requires a mechanism of reorganizing the backing pages (backing pages are used to create a mirror device) again into the right sized order pages. This is supported by exporting prep_compound_page(). Signed-off-by: Balbir Singh --- include/linux/memremap.h | 7 +++ include/linux/mm.h

[RFC 08/11] mm/thp: add split during migration support

2025-03-05 Thread Balbir Singh
code paths, an extra reference count is added to the split folio pages, which will be dropped in the finalize phase. Signed-off-by: Balbir Singh --- include/linux/huge_mm.h | 11 ++-- mm/huge_memory.c| 53 +--- mm/migrate_device.c | 60

[RFC 05/11] mm/memory/fault: Add support for zone device THP fault handling

2025-03-05 Thread Balbir Singh
When the CPU touches a zone device THP entry, the data needs to be migrated back to the CPU, call migrate_to_ram() on these pages via do_huge_pmd_device_private() fault handling helper. Signed-off-by: Balbir Singh --- include/linux/huge_mm.h | 7 +++ mm/huge_memory.c| 35

[RFC 04/11] mm/migrate_device: THP migration of zone device pages

2025-03-05 Thread Balbir Singh
re is fallback support to split the folio and migrate it. migrate_vma_insert_huge_pmd_page() closely follows the logic of migrate_vma_insert_page() Support for splitting pages as needed for migration will follow in later patches in this series. Signed-off-by: Balbir Singh --- mm/migrate_device.c

[RFC 11/11] gpu/drm/nouveau: Add THP migration support

2025-03-05 Thread Balbir Singh
Change the code to add support for MIGRATE_VMA_SELECT_COMPOUND and appropriately handling page sizes in the migrate/evict code paths. Signed-off-by: Balbir Singh --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 244 + drivers/gpu/drm/nouveau/nouveau_svm.c | 6 +- drivers

[RFC 09/11] lib/test_hmm: add test case for split pages

2025-03-05 Thread Balbir Singh
Add a new flag HMM_DMIRROR_FLAG_FAIL_ALLOC to emulate failure of allocating a large page. This tests the code paths involving split migration. Signed-off-by: Balbir Singh --- lib/test_hmm.c | 12 +++- lib/test_hmm_uapi.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion

[RFC 10/11] selftests/mm/hmm-tests: new tests for zone device THP migration

2025-03-05 Thread Balbir Singh
Add new tests for migrating anon THP pages, including anon_huge, anon_huge_zero and error cases involving forced splitting of pages during migration. Signed-off-by: Balbir Singh --- tools/testing/selftests/mm/hmm-tests.c | 407 + 1 file changed, 407 insertions(+) diff

[RFC 01/11] mm/zone_device: support large zone device private folios

2025-03-05 Thread Balbir Singh
freed, this is true for both PAGE_SIZE and higher order pages. Signed-off-by: Balbir Singh --- include/linux/memremap.h | 22 +- mm/memremap.c| 50 +--- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/include/linux

Re: [RFC 04/11] mm/migrate_device: THP migration of zone device pages

2025-03-06 Thread Balbir Singh
On 3/6/25 20:24, Mika Penttilä wrote: > Hi, > > On 3/6/25 06:42, Balbir Singh wrote: > ... > >> >> /* >> * The only time there is no vma is when called from >> @@ -728,15 +1000,47 @@ static void __migrate_d

[RFC 03/11] mm/thp: zone_device awareness in THP handling code

2025-03-06 Thread Balbir Singh
. try_to_map_to_unused_zeropage() does not apply to zone device entries, zone device entries are ignored in the call. Signed-off-by: Balbir Singh --- mm/huge_memory.c | 151 +++ mm/migrate.c | 2 + mm/page_vma_mapped.c | 10 +++ mm/rmap.c| 19 +- 4

Re: [RFC 07/11] mm/memremap: Add folio_split support

2025-03-11 Thread Balbir Singh
On 3/6/25 19:16, Mika Penttilä wrote: > Hi, > > On 3/6/25 06:42, Balbir Singh wrote: >> When a zone device page is split (via huge pmd folio split). The >> driver callback for folio_split is invoked to let the device driver >> know that the folio size has been

Re: [RFC 01/11] mm/zone_device: support large zone device private folios

2025-07-08 Thread Balbir Singh
On 7/8/25 23:37, David Hildenbrand wrote: > On 06.03.25 05:42, Balbir Singh wrote: >> Add routines to support allocation of large order zone device folios >> and helper functions for zone device folios, to check if a folio is >> device private and helpers for setting zone de

Re: [RFC 02/11] mm/migrate_device: flags for selecting device private THP pages

2025-07-08 Thread Balbir Singh
On 7/8/25 23:41, David Hildenbrand wrote: > On 06.03.25 05:42, Balbir Singh wrote: >> Add flags to mark zone device migration pages. >> >> MIGRATE_VMA_SELECT_COMPOUND will be used to select THP pages during >> migrate_vma_setup() and MIGRATE_PFN_COMPOUND will make m

Re: [RFC 03/11] mm/thp: zone_device awareness in THP handling code

2025-07-09 Thread Balbir Singh
On 7/9/25 00:10, David Hildenbrand wrote: > On 06.03.25 05:42, Balbir Singh wrote: >> Make THP handling code in the mm subsystem for THP pages >> aware of zone device pages. Although the code is >> designed to be generic when it comes to handling splitting >> of pages, t

Re: [RFC 05/11] mm/memory/fault: Add support for zone device THP fault handling

2025-07-09 Thread Balbir Singh
On 7/9/25 00:40, David Hildenbrand wrote: > On 06.03.25 05:42, Balbir Singh wrote: >> When the CPU touches a zone device THP entry, the data needs to >> be migrated back to the CPU, call migrate_to_ram() on these pages >> via do_huge_pmd_device_private() fault handling helper

Re: [RFC 07/11] mm/memremap: Add folio_split support

2025-07-09 Thread Balbir Singh
On 7/9/25 00:31, David Hildenbrand wrote: > On 06.03.25 05:42, Balbir Singh wrote: >> When a zone device page is split (via huge pmd folio split). The >> driver callback for folio_split is invoked to let the device driver >> know that the folio size has been split into a sma

Re: [RFC 00/11] THP support for zone device pages

2025-07-05 Thread Balbir Singh
On 7/5/25 02:17, Zi Yan wrote: > On 4 Jul 2025, at 9:52, Francois Dugast wrote: > >> Hi, >> >> On Fri, Mar 07, 2025 at 10:20:30AM +1100, Balbir Singh wrote: >>> On 3/7/25 10:08, Matthew Brost wrote: >>>> On Thu, Mar 06, 2025 at 03:42:28PM +1100, Balb