[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190703190045.GN18688@mellanox.com>
Date: Wed, 3 Jul 2019 19:00:50 +0000
From: Jason Gunthorpe <jgg@...lanox.com>
To: Christoph Hellwig <hch@....de>
CC: Jérôme Glisse <jglisse@...hat.com>,
Ben Skeggs <bskeggs@...hat.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"nouveau@...ts.freedesktop.org" <nouveau@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Ralph Campbell <rcampbell@...dia.com>
Subject: Re: [PATCH 1/5] mm: return valid info from hmm_range_unregister
On Wed, Jul 03, 2019 at 11:44:58AM -0700, Christoph Hellwig wrote:
> Checking range->valid is trivial and has no meaningful cost, but
> nicely simplifies the fastpath in typical callers.
It should not be the typical caller..
> hmm_vma_range_done function, which now is a trivial wrapper around
> hmm_range_unregister.
>
> Signed-off-by: Christoph Hellwig <hch@....de>
> Reviewed-by: Ralph Campbell <rcampbell@...dia.com>
> drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +-
> include/linux/hmm.h | 11 +----------
> mm/hmm.c | 7 ++++++-
> 3 files changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
> index 8c92374afcf2..9d40114d7949 100644
> +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
> @@ -652,7 +652,7 @@ nouveau_svm_fault(struct nvif_notify *notify)
> ret = hmm_vma_fault(&svmm->mirror, &range, true);
> if (ret == 0) {
> mutex_lock(&svmm->mutex);
> - if (!hmm_vma_range_done(&range)) {
> + if (!hmm_range_unregister(&range)) {
> mutex_unlock(&svmm->mutex);
> goto again;
> }
In this case if we take the 'goto again' then we are pointlessly
removing and re-adding the range.
The pattern is supposed to be:
hmm_range_register()
again:
.. read page tables ..
lock
if (!hmm_range_valid())
unlock
goto again
.. setup device ..
unlock
hmm_range_unregister()
I don't think the API should be encouraging some shortcut here..
We can't do the above pattern because the old hmm_vma API didn't allow
it, which is presumably a reason why it is obsolete.
I'd rather see drivers move to a consistent pattern so we can then
easily hoist the seqcount lock scheme into some common mmu notifier
code, as discussed.
Jason
Powered by blists - more mailing lists