[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <MN2PR12MB43449C6419A839E4F5605B6EC29A9@MN2PR12MB4344.namprd12.prod.outlook.com>
Date: Mon, 1 Mar 2021 22:55:48 +0000
From: Ralph Campbell <rcampbell@...dia.com>
To: Alistair Popple <apopple@...dia.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"nouveau@...ts.freedesktop.org" <nouveau@...ts.freedesktop.org>,
"bskeggs@...hat.com" <bskeggs@...hat.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
CC: "linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"John Hubbard" <jhubbard@...dia.com>,
"jglisse@...hat.com" <jglisse@...hat.com>,
Jason Gunthorpe <jgg@...dia.com>,
"hch@...radead.org" <hch@...radead.org>,
"daniel@...ll.ch" <daniel@...ll.ch>
Subject: RE: [PATCH v3 5/8] mm: Device exclusive memory access
> From: Alistair Popple <apopple@...dia.com>
> Sent: Thursday, February 25, 2021 11:18 PM
> To: linux-mm@...ck.org; nouveau@...ts.freedesktop.org;
> bskeggs@...hat.com; akpm@...ux-foundation.org
> Cc: linux-doc@...r.kernel.org; linux-kernel@...r.kernel.org; dri-
> devel@...ts.freedesktop.org; John Hubbard <jhubbard@...dia.com>; Ralph
> Campbell <rcampbell@...dia.com>; jglisse@...hat.com; Jason Gunthorpe
> <jgg@...dia.com>; hch@...radead.org; daniel@...ll.ch; Alistair Popple
> <apopple@...dia.com>
> Subject: [PATCH v3 5/8] 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.
>
> Signed-off-by: Alistair Popple <apopple@...dia.com>
> ---
> Documentation/vm/hmm.rst | 15 ++++
> include/linux/rmap.h | 3 +
> include/linux/swap.h | 4 +-
> include/linux/swapops.h | 44 ++++++++++-
> mm/hmm.c | 5 ++
> mm/memory.c | 108 +++++++++++++++++++++++++-
> mm/mprotect.c | 8 ++
> mm/page_vma_mapped.c | 9 ++-
> mm/rmap.c | 163 +++++++++++++++++++++++++++++++++++++++
> 9 files changed, 352 insertions(+), 7 deletions(-)
...
> +int make_device_exclusive_range(struct mm_struct *mm, unsigned long start,
> + unsigned long end, struct page **pages) {
> + long npages = (end - start) >> PAGE_SHIFT;
> + long i;
Nit: you should use unsigned long for 'i' and 'npages' to match start/end.
Powered by blists - more mailing lists