[PATCH v3 6/8] mm: Selftests for exclusive device memory
Ralph Campbell
rcampbell at nvidia.com
Mon Mar 1 23:14:56 UTC 2021
> From: Alistair Popple <apopple at nvidia.com>
> Sent: Thursday, February 25, 2021 11:19 PM
> To: linux-mm at kvack.org; nouveau at lists.freedesktop.org;
> bskeggs at redhat.com; akpm at linux-foundation.org
> Cc: linux-doc at vger.kernel.org; linux-kernel at vger.kernel.org; dri-
> devel at lists.freedesktop.org; John Hubbard <jhubbard at nvidia.com>; Ralph
> Campbell <rcampbell at nvidia.com>; jglisse at redhat.com; Jason Gunthorpe
> <jgg at nvidia.com>; hch at infradead.org; daniel at ffwll.ch; Alistair Popple
> <apopple at nvidia.com>
> Subject: [PATCH v3 6/8] mm: Selftests for exclusive device memory
>
> Adds some selftests for exclusive device memory.
>
> Signed-off-by: Alistair Popple <apopple at nvidia.com>
One minor nit below, but you can add
Tested-by: Ralph Campbell <rcampbell at nvidia.com>
Reviewed-by: Ralph Campbell <rcampbell at nvidia.com>
> +static int dmirror_exclusive(struct dmirror *dmirror,
> + struct hmm_dmirror_cmd *cmd)
> +{
> + unsigned long start, end, addr;
> + unsigned long size = cmd->npages << PAGE_SHIFT;
> + struct mm_struct *mm = dmirror->notifier.mm;
> + struct page *pages[64];
> + struct dmirror_bounce bounce;
> + unsigned long next;
> + int ret;
> +
> + start = cmd->addr;
> + end = start + size;
> + if (end < start)
> + return -EINVAL;
> +
> + /* Since the mm is for the mirrored process, get a reference first. */
> + if (!mmget_not_zero(mm))
> + return -EINVAL;
> +
> + mmap_read_lock(mm);
> + for (addr = start; addr < end; addr = next) {
> + int i, mapped;
> +
> + if (end < addr + (64 << PAGE_SHIFT))
> + next = end;
> + else
> + next = addr + (64 << PAGE_SHIFT);
I suggest using ARRAY_SIZE(pages) instead of '64' to make the meaning clear.
More information about the dri-devel
mailing list