From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Ralph Campbell <rcampbell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
Jason Gunthorpe <jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] nouveau/hmm: map pages after migration
Date: Thu, 8 Aug 2019 09:07:01 +0200 [thread overview]
Message-ID: <20190808070701.GC29382@lst.de> (raw)
In-Reply-To: <20190807150214.3629-1-rcampbell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On Wed, Aug 07, 2019 at 08:02:14AM -0700, Ralph Campbell wrote:
> When memory is migrated to the GPU it is likely to be accessed by GPU
> code soon afterwards. Instead of waiting for a GPU fault, map the
> migrated memory into the GPU page tables with the same access permissions
> as the source CPU page table entries. This preserves copy on write
> semantics.
>
> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Jason Gunthorpe <jgg@mellanox.com>
> Cc: "Jérôme Glisse" <jglisse@redhat.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> ---
>
> This patch is based on top of Christoph Hellwig's 9 patch series
> https://lore.kernel.org/linux-mm/20190729234611.GC7171@redhat.com/T/#u
> "turn the hmm migrate_vma upside down" but without patch 9
> "mm: remove the unused MIGRATE_PFN_WRITE" and adds a use for the flag.
This looks useful. I've already dropped that patch for the pending
resend.
> static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm,
> - struct vm_area_struct *vma, unsigned long addr,
> - unsigned long src, dma_addr_t *dma_addr)
> + struct vm_area_struct *vma, unsigned long src,
> + dma_addr_t *dma_addr, u64 *pfn)
I'll pick up the removal of the not needed addr argument for the patch
introducing nouveau_dmem_migrate_copy_one, thanks,
> static void nouveau_dmem_migrate_chunk(struct migrate_vma *args,
> - struct nouveau_drm *drm, dma_addr_t *dma_addrs)
> + struct nouveau_drm *drm, dma_addr_t *dma_addrs, u64 *pfns)
> {
> struct nouveau_fence *fence;
> unsigned long addr = args->start, nr_dma = 0, i;
>
> for (i = 0; addr < args->end; i++) {
> args->dst[i] = nouveau_dmem_migrate_copy_one(drm, args->vma,
> - addr, args->src[i], &dma_addrs[nr_dma]);
> + args->src[i], &dma_addrs[nr_dma], &pfns[i]);
Nit: I find the &pfns[i] way to pass the argument a little weird to read.
Why not "pfns + i"?
> +u64 *
> +nouveau_pfns_alloc(unsigned long npages)
> +{
> + struct nouveau_pfnmap_args *args;
> +
> + args = kzalloc(sizeof(*args) + npages * sizeof(args->p.phys[0]),
Can we use struct_size here?
> + int ret;
> +
> + if (!svm)
> + return;
> +
> + mutex_lock(&svm->mutex);
> + svmm = nouveau_find_svmm(svm, mm);
> + if (!svmm) {
> + mutex_unlock(&svm->mutex);
> + return;
> + }
> + mutex_unlock(&svm->mutex);
Given that nouveau_find_svmm doesn't take any kind of reference, what
gurantees svmm doesn't go away after dropping the lock?
> @@ -44,5 +49,19 @@ static inline int nouveau_svmm_bind(struct drm_device *device, void *p,
> {
> return -ENOSYS;
> }
> +
> +u64 *nouveau_pfns_alloc(unsigned long npages)
> +{
> + return NULL;
> +}
> +
> +void nouveau_pfns_free(u64 *pfns)
> +{
> +}
> +
> +void nouveau_pfns_map(struct nouveau_drm *drm, struct mm_struct *mm,
> + unsigned long addr, u64 *pfns, unsigned long npages)
> +{
> +}
> #endif /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
nouveau_dmem.c and nouveau_svm.c are both built conditional on
CONFIG_DRM_NOUVEAU_SVM, so there is no need for stubs here.
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
next prev parent reply other threads:[~2019-08-08 7:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 15:02 [PATCH] nouveau/hmm: map pages after migration Ralph Campbell
[not found] ` <20190807150214.3629-1-rcampbell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2019-08-08 7:07 ` Christoph Hellwig [this message]
[not found] ` <20190808070701.GC29382-jcswGhMUV9g@public.gmane.org>
2019-08-08 21:29 ` Ralph Campbell
[not found] ` <0b96a8d8-86b5-3ce0-db95-669963c1f8a7-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2019-08-10 11:13 ` Christoph Hellwig
2019-08-12 19:42 ` Ralph Campbell
[not found] ` <1a84e6b6-31e6-6955-509f-9883f4a7a322-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2019-08-16 7:11 ` Christoph Hellwig
[not found] ` <20190816071132.GA7513-jcswGhMUV9g@public.gmane.org>
2019-08-17 1:05 ` Ben Skeggs
[not found] ` <CABDvA=n4Y0QticHZowEWFOqiEB3p99nV71GvHAySYdkcgw-Aow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-08-17 6:11 ` Christoph Hellwig
2019-08-13 21:58 ` Jerome Glisse
[not found] ` <20190813215852.GA9823-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2019-08-15 17:43 ` [Nouveau] " Jerome Glisse
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=20190808070701.GC29382@lst.de \
--to=hch-jcswghmuv9g@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=rcampbell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.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