All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 00/10] Add support for SVM atomics in Nouveau
@ 2021-05-24 13:27 ` Alistair Popple
  0 siblings, 0 replies; 123+ messages in thread
From: Alistair Popple @ 2021-05-24 13:27 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: nouveau, bskeggs, rcampbell, linux-doc, jhubbard, bsingharora,
	linux-kernel, dri-devel, hch, jglisse, willy, jgg, peterx, hughd,
	Alistair Popple

This is a repost of the previous series to rebase on v5.13-rc2 and to
address comments.

Outside of some code comment updates the primary change was to split the
renaming of migrate_pgmap_owner into a separate patch and to further
simplify the handling of device exclusive entries in copy_pte_range(). This
may result in temporary fork() failures if the process is using a device
whilst forking, but such usage is unlikely to be practical.

This resulted in a new clean-up patch for the series (patch 6) so that
device exclusive entries can be handled inside copy_nonpresent_pte(),
although more extensive clean-ups of copy_pte_range() are planned as
further development work in future.

Introduction
============

Some devices have features such as atomic PTE bits that can be used to
implement atomic access to system memory. To support atomic operations to a
shared virtual memory page such a device needs access to that page which is
exclusive of the CPU. This series introduces a mechanism to temporarily
unmap pages granting exclusive access to a device.

These changes are required to support OpenCL atomic operations in Nouveau
to shared virtual memory (SVM) regions allocated with the
CL_MEM_SVM_ATOMICS clSVMAlloc flag. A more complete description of the
OpenCL SVM feature is available at
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/
OpenCL_API.html#_shared_virtual_memory .

Implementation
==============

Exclusive device access is implemented by adding a new swap entry type
(SWAP_DEVICE_EXCLUSIVE) which is similar to a migration entry. The main
difference is that on fault the original entry is immediately restored by
the fault handler instead of waiting.

Restoring the entry triggers calls to MMU notifers which allows a device
driver to revoke the atomic access permission from the GPU prior to the CPU
finalising the entry.

Patches
=======

Patches 1 & 2 refactor existing migration and device private entry
functions.

Patches 3 & 4 rework try_to_unmap_one() by splitting out unrelated
functionality into separate functions - try_to_migrate_one() and
try_to_munlock_one().

Patch 5 renames some existing code but does not introduce functionality.

Patch 6 is a small clean-up to swap entry handling in copy_pte_range().

Patch 7 contains the bulk of the implementation for device exclusive
memory.

Patch 8 contains some additions to the HMM selftests to ensure everything
works as expected.

Patch 9 is a cleanup for the Nouveau SVM implementation.

Patch 10 contains the implementation of atomic access for the Nouveau
driver.

Testing
=======

This has been tested with upstream Mesa 21.1.0 and a simple OpenCL program
which checks that GPU atomic accesses to system memory are atomic. Without
this series the test fails as there is no way of write-protecting the page
mapping which results in the device clobbering CPU writes. For reference
the test is available at https://ozlabs.org/~apopple/opencl_svm_atomics/

Further testing has been performed by adding support for testing exclusive
access to the hmm-tests kselftests.

Alistair Popple (10):
  mm: Remove special swap entry functions
  mm/swapops: Rework swap entry manipulation code
  mm/rmap: Split try_to_munlock from try_to_unmap
  mm/rmap: Split migration into its own function
  mm: Rename migrate_pgmap_owner
  mm/memory.c: Allow different return codes for copy_nonpresent_pte()
  mm: Device exclusive memory access
  mm: Selftests for exclusive device memory
  nouveau/svm: Refactor nouveau_range_fault
  nouveau/svm: Implement atomic SVM access

 Documentation/vm/hmm.rst                      |  19 +-
 Documentation/vm/unevictable-lru.rst          |  33 +-
 arch/s390/mm/pgtable.c                        |   2 +-
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |   1 +
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 156 ++++-
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h |   1 +
 .../drm/nouveau/nvkm/subdev/mmu/vmmgp100.c    |   6 +
 fs/proc/task_mmu.c                            |  23 +-
 include/linux/mmu_notifier.h                  |  26 +-
 include/linux/rmap.h                          |  11 +-
 include/linux/swap.h                          |  11 +-
 include/linux/swapops.h                       | 123 ++--
 lib/test_hmm.c                                | 126 +++-
 lib/test_hmm_uapi.h                           |   2 +
 mm/debug_vm_pgtable.c                         |  12 +-
 mm/hmm.c                                      |  12 +-
 mm/huge_memory.c                              |  45 +-
 mm/hugetlb.c                                  |  10 +-
 mm/memcontrol.c                               |   2 +-
 mm/memory.c                                   | 160 ++++-
 mm/migrate.c                                  |  51 +-
 mm/mlock.c                                    |  10 +-
 mm/mprotect.c                                 |  18 +-
 mm/page_vma_mapped.c                          |  15 +-
 mm/rmap.c                                     | 601 +++++++++++++++---
 tools/testing/selftests/vm/hmm-tests.c        | 158 +++++
 26 files changed, 1317 insertions(+), 317 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 123+ messages in thread

end of thread, other threads:[~2021-06-07  4:52 UTC | newest]

Thread overview: 123+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 13:27 [PATCH v9 00/10] Add support for SVM atomics in Nouveau Alistair Popple
2021-05-24 13:27 ` Alistair Popple
2021-05-24 13:27 ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 01/10] mm: Remove special swap entry functions Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 02/10] mm/swapops: Rework swap entry manipulation code Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 03/10] mm/rmap: Split try_to_munlock from try_to_unmap Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-25 18:39   ` Liam Howlett
2021-05-25 18:39     ` Liam Howlett
2021-05-25 18:39     ` [Nouveau] " Liam Howlett
2021-05-25 23:45     ` Shakeel Butt
2021-05-25 23:45       ` Shakeel Butt
2021-05-25 23:45       ` [Nouveau] " Shakeel Butt
2021-05-25 23:45       ` Shakeel Butt
2021-06-04 20:49       ` Liam Howlett
2021-06-04 20:49         ` Liam Howlett
2021-06-04 20:49         ` [Nouveau] " Liam Howlett
2021-06-05  0:41         ` Shakeel Butt
2021-06-05  0:41           ` Shakeel Butt
2021-06-05  0:41           ` [Nouveau] " Shakeel Butt
2021-06-05  0:41           ` Shakeel Butt
2021-06-05  3:39           ` Liam Howlett
2021-06-05  3:39             ` Liam Howlett
2021-06-05  3:39             ` [Nouveau] " Liam Howlett
2021-06-05  4:19             ` Shakeel Butt
2021-06-05  4:19               ` Shakeel Butt
2021-06-05  4:19               ` [Nouveau] " Shakeel Butt
2021-06-05  4:19               ` Shakeel Butt
2021-06-07  4:51           ` Alistair Popple
2021-06-07  4:51             ` Alistair Popple
2021-06-07  4:51             ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 04/10] mm/rmap: Split migration into its own function Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 05/10] mm: Rename migrate_pgmap_owner Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-26 19:41   ` Peter Xu
2021-05-26 19:41     ` Peter Xu
2021-05-26 19:41     ` [Nouveau] " Peter Xu
2021-05-24 13:27 ` [PATCH v9 06/10] mm/memory.c: Allow different return codes for copy_nonpresent_pte() Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-26 19:50   ` Peter Xu
2021-05-26 19:50     ` Peter Xu
2021-05-26 19:50     ` [Nouveau] " Peter Xu
2021-05-27  1:20     ` Alistair Popple
2021-05-27  1:20       ` Alistair Popple
2021-05-27  1:20       ` [Nouveau] " Alistair Popple
2021-05-27  1:44       ` Peter Xu
2021-05-27  1:44         ` Peter Xu
2021-05-27  1:44         ` [Nouveau] " Peter Xu
2021-05-24 13:27 ` [PATCH v9 07/10] mm: Device exclusive memory access Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-24 22:11   ` Andrew Morton
2021-05-24 22:11     ` Andrew Morton
2021-05-24 22:11     ` [Nouveau] " Andrew Morton
2021-05-25  1:31     ` John Hubbard
2021-05-25  1:31       ` John Hubbard
2021-05-25  1:31       ` [Nouveau] " John Hubbard
2021-05-25  9:21       ` Alistair Popple
2021-05-25  9:21         ` Alistair Popple
2021-05-25  9:21         ` [Nouveau] " Alistair Popple
2021-05-25 11:51     ` Balbir Singh
2021-05-25 11:51       ` Balbir Singh
2021-05-25 11:51       ` [Nouveau] " Balbir Singh
2021-05-26  7:17       ` John Hubbard
2021-05-26  7:17         ` John Hubbard
2021-05-26  7:17         ` [Nouveau] " John Hubbard
2021-05-26 13:30         ` Alistair Popple
2021-05-26 13:30           ` Alistair Popple
2021-05-26 13:30           ` [Nouveau] " Alistair Popple
2021-06-02  8:50         ` Balbir Singh
2021-06-02  8:50           ` Balbir Singh
2021-06-02  8:50           ` [Nouveau] " Balbir Singh
2021-06-02 14:37           ` Peter Xu
2021-06-02 14:37             ` Peter Xu
2021-06-02 14:37             ` [Nouveau] " Peter Xu
2021-06-03 11:39             ` Alistair Popple
2021-06-03 11:39               ` Alistair Popple
2021-06-03 11:39               ` [Nouveau] " Alistair Popple
2021-06-03 14:47               ` Peter Xu
2021-06-03 14:47                 ` Peter Xu
2021-06-03 14:47                 ` [Nouveau] " Peter Xu
2021-06-04  1:07                 ` Alistair Popple
2021-06-04  1:07                   ` Alistair Popple
2021-06-04  1:07                   ` [Nouveau] " Alistair Popple
2021-06-04 15:20                   ` Peter Xu
2021-06-04 15:20                     ` Peter Xu
2021-06-04 15:20                     ` [Nouveau] " Peter Xu
2021-06-03  8:37           ` John Hubbard
2021-06-03  8:37             ` John Hubbard
2021-06-03  8:37             ` [Nouveau] " John Hubbard
2021-05-26 19:28   ` Peter Xu
2021-05-26 19:28     ` Peter Xu
2021-05-26 19:28     ` [Nouveau] " Peter Xu
2021-05-27  3:35     ` Alistair Popple
2021-05-27  3:35       ` Alistair Popple
2021-05-27  3:35       ` [Nouveau] " Alistair Popple
2021-05-27 13:04       ` Peter Xu
2021-05-27 13:04         ` Peter Xu
2021-05-27 13:04         ` [Nouveau] " Peter Xu
2021-05-28  1:48         ` Alistair Popple
2021-05-28  1:48           ` Alistair Popple
2021-05-28  1:48           ` [Nouveau] " Alistair Popple
2021-05-28 13:11           ` Peter Xu
2021-05-28 13:11             ` Peter Xu
2021-05-28 13:11             ` [Nouveau] " Peter Xu
2021-05-24 13:27 ` [PATCH v9 08/10] mm: Selftests for exclusive device memory Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 09/10] nouveau/svm: Refactor nouveau_range_fault Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple
2021-05-24 13:27 ` [PATCH v9 10/10] nouveau/svm: Implement atomic SVM access Alistair Popple
2021-05-24 13:27   ` Alistair Popple
2021-05-24 13:27   ` [Nouveau] " Alistair Popple

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.