From: John Hubbard <jhubbard@nvidia.com>
To: Alistair Popple <apopple@nvidia.com>,
akpm@linux-foundation.org, linux-mm@kvack.org
Cc: Felix.Kuehling@amd.com, rcampbell@nvidia.com,
linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
hch@lst.de, jgg@nvidia.com, jglisse@redhat.com,
willy@infradead.org, alex.sierra@amd.com
Subject: Re: [PATCH v2 1/3] migrate.c: Remove vma check in migrate_vma_setup()
Date: Tue, 15 Feb 2022 13:50:44 -0800 [thread overview]
Message-ID: <487fdaad-0873-142a-cf3a-a065bc8acff6@nvidia.com> (raw)
In-Reply-To: <6831bf69f7c7699be83b31c9c56212b5fb07f873.1644207242.git-series.apopple@nvidia.com>
On 2/6/22 20:26, Alistair Popple wrote:
> migrate_vma_setup() checks that a valid vma is passed so that the page
> tables can be walked to find the pfns associated with a given address
> range. However in some cases the pfns are already known, such as when
> migrating device coherent pages during pin_user_pages() meaning a valid
> vma isn't required.
>
> Signed-off-by: Alistair Popple <apopple@nvidia.com>
> Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
> ---
>
> Changes for v2:
>
> - Added Felix's Acked-by
>
> mm/migrate.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
Hi Alistair,
Another late-breaking review question, below. :)
> diff --git a/mm/migrate.c b/mm/migrate.c
> index a9aed12..0d6570d 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2602,24 +2602,24 @@ int migrate_vma_setup(struct migrate_vma *args)
>
> args->start &= PAGE_MASK;
> args->end &= PAGE_MASK;
> - if (!args->vma || is_vm_hugetlb_page(args->vma) ||
> - (args->vma->vm_flags & VM_SPECIAL) || vma_is_dax(args->vma))
> - return -EINVAL;
> - if (nr_pages <= 0)
> - return -EINVAL;
Was the above check left out intentionally? If so, then it needs a
commit description note. And maybe even a separate patch, because it
changes the behavior.
If you do want to change the behavior:
* The kerneldoc comment above this function supports such a change: it
requires returning 0 for the case of zero pages requested. So your
change would bring the comments into alignment with the code.
* I don't think memset deals properly with a zero length input arg, so
it's probably better to return 0, before that point.
thanks,
--
John Hubbard
NVIDIA
> - if (args->start < args->vma->vm_start ||
> - args->start >= args->vma->vm_end)
> - return -EINVAL;
> - if (args->end <= args->vma->vm_start || args->end > args->vma->vm_end)
> - return -EINVAL;
> if (!args->src || !args->dst)
> return -EINVAL;
> -
> - memset(args->src, 0, sizeof(*args->src) * nr_pages);
> - args->cpages = 0;
> - args->npages = 0;
> -
> - migrate_vma_collect(args);
> + if (args->vma) {
> + if (is_vm_hugetlb_page(args->vma) ||
> + (args->vma->vm_flags & VM_SPECIAL) || vma_is_dax(args->vma))
> + return -EINVAL;
> + if (args->start < args->vma->vm_start ||
> + args->start >= args->vma->vm_end)
> + return -EINVAL;
> + if (args->end <= args->vma->vm_start || args->end > args->vma->vm_end)
> + return -EINVAL;
> +
> + memset(args->src, 0, sizeof(*args->src) * nr_pages);
> + args->cpages = 0;
> + args->npages = 0;
> +
> + migrate_vma_collect(args);
> + }
>
> if (args->cpages)
> migrate_vma_unmap(args);
> @@ -2804,7 +2804,7 @@ void migrate_vma_pages(struct migrate_vma *migrate)
> continue;
> }
>
> - if (!page) {
> + if (!page && migrate->vma) {
> if (!(migrate->src[i] & MIGRATE_PFN_MIGRATE))
> continue;
> if (!notified) {
next prev parent reply other threads:[~2022-02-15 21:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-07 4:26 [PATCH v2 0/3] Migrate device coherent pages on get_user_pages() Alistair Popple
2022-02-07 4:26 ` [PATCH v2 1/3] migrate.c: Remove vma check in migrate_vma_setup() Alistair Popple
2022-02-15 21:50 ` John Hubbard [this message]
2022-02-07 4:26 ` [PATCH v2 2/3] mm/gup.c: Migrate device coherent pages when pinning instead of failing Alistair Popple
2022-02-10 10:53 ` David Hildenbrand
2022-02-10 11:39 ` Alistair Popple
2022-02-10 11:47 ` David Hildenbrand
2022-02-10 23:41 ` Alistair Popple
2022-02-15 12:03 ` David Hildenbrand
2022-02-12 2:10 ` John Hubbard
2022-02-12 2:51 ` Alistair Popple
2022-02-12 3:04 ` John Hubbard
2022-02-14 0:05 ` Alistair Popple
2022-02-07 4:26 ` [PATCH v2 3/3] tools: add hmm gup test for long term pinned device pages Alistair Popple
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=487fdaad-0873-142a-cf3a-a065bc8acff6@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=Felix.Kuehling@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alex.sierra@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=apopple@nvidia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@lst.de \
--cc=jgg@nvidia.com \
--cc=jglisse@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=rcampbell@nvidia.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox