linux-stable/Documentation/vm
Alistair Popple b756a3b5e7 mm: device exclusive memory access
Some devices require exclusive write access to shared virtual memory (SVM)
ranges to perform atomic operations on that memory.  This requires CPU
page tables to be updated to deny access whilst atomic operations are
occurring.

In order to do this introduce a new swap entry type
(SWP_DEVICE_EXCLUSIVE).  When a SVM range needs to be marked for exclusive
access by a device all page table mappings for the particular range are
replaced with device exclusive swap entries.  This causes any CPU access
to the page to result in a fault.

Faults are resovled by replacing the faulting entry with the original
mapping.  This results in MMU notifiers being called which a driver uses
to update access permissions such as revoking atomic access.  After
notifiers have been called the device will no longer have exclusive access
to the region.

Walking of the page tables to find the target pages is handled by
get_user_pages() rather than a direct page table walk.  A direct page
table walk similar to what migrate_vma_collect()/unmap() does could also
have been utilised.  However this resulted in more code similar in
functionality to what get_user_pages() provides as page faulting is
required to make the PTEs present and to break COW.

[dan.carpenter@oracle.com: fix signedness bug in make_device_exclusive_range()]
  Link: https://lkml.kernel.org/r/YNIz5NVnZ5GiZ3u1@mwanda

Link: https://lkml.kernel.org/r/20210616105937.23201-8-apopple@nvidia.com
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-07-01 11:06:03 -07:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
active_mm.rst docs/vm: fix 'mm_count' vs 'mm_users' counter confusion 2020-10-13 18:38:32 -07:00
arch_pgtable_helpers.rst mm/debug_vm_pgtable/basic: add validation for dirtiness after write protect 2021-02-24 13:38:27 -08:00
balance.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
cleancache.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
free_page_reporting.rst mm/page_reporting: add free page reporting documentation 2020-04-07 10:43:39 -07:00
frontswap.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
highmem.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
hmm.rst mm: device exclusive memory access 2021-07-01 11:06:03 -07:00
hugetlbfs_reserv.rst docs/vm: Minor editorial changes in the THP and hugetlbfs 2019-04-30 06:34:40 -06:00
hwpoison.rst docs/vm: hwpoison.rst: Fix quote formatting 2019-06-20 14:11:32 -06:00
index.rst docs: add some new files to their respective index.rst files 2020-09-10 10:48:20 -06:00
ksm.rst docs: get rid of :c:type explicit declarations for structs 2020-10-15 07:49:40 +02:00
memory-model.rst docs: remove description of DISCONTIGMEM 2021-06-29 10:53:55 -07:00
mmu_notifier.rst docs/vm: trivial fixes to several spelling mistakes 2020-10-22 16:11:04 -06:00
numa.rst docs: cgroup-v1: add it to the admin-guide book 2019-07-15 11:03:02 -03:00
overcommit-accounting.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
page_frags.rst docs: vm: page_frags.rst: Fix the reference of stale function 2020-05-15 11:34:55 -06:00
page_migration.rst docs/vm: trivial fixes to several spelling mistakes 2020-10-22 16:11:04 -06:00
page_owner.rst mm/page_owner: record the timestamp of all pages during free 2021-04-30 11:20:36 -07:00
remap_file_pages.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
slub.rst mm/slub: clarify verification reporting 2021-06-16 09:24:42 -07:00
split_page_table_lock.rst Documentation: fix typos in split page table lock description 2021-01-18 13:27:18 -07:00
swap_numa.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
transhuge.rst mm: gup: remove FOLL_SPLIT 2021-04-30 11:20:37 -07:00
unevictable-lru.rst mm/rmap: split try_to_munlock from try_to_unmap 2021-07-01 11:06:03 -07:00
z3fold.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
zsmalloc.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
zswap.rst zswap: docs/vm: Fix typo accept_threshold_percent in zswap.rst 2020-06-01 09:33:23 -06:00