All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: David Hildenbrand <david@redhat.com>
Cc: Alex Sierra <alex.sierra@amd.com>,
	jgg@nvidia.com, Felix.Kuehling@amd.com, linux-mm@kvack.org,
	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, jglisse@redhat.com,
	willy@infradead.org, akpm@linux-foundation.org
Subject: Re: [PATCH v7 04/14] mm: add device coherent vma selection for memory migration
Date: Thu, 30 Jun 2022 21:44:55 +1000	[thread overview]
Message-ID: <878rpe73t3.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <956b1c51-b8f1-0480-81ca-5d03b45110f7@redhat.com>


David Hildenbrand <david@redhat.com> writes:

> On 29.06.22 05:54, Alex Sierra wrote:
>> This case is used to migrate pages from device memory, back to system
>> memory. Device coherent type memory is cache coherent from device and CPU
>> point of view.
>>
>> Signed-off-by: Alex Sierra <alex.sierra@amd.com>
>> Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
>> Reviewed-by: Alistair Poppple <apopple@nvidia.com>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
>
> I'm not too familiar with this code, please excuse my naive questions:
>
>> @@ -148,15 +148,21 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
>>  			if (is_writable_device_private_entry(entry))
>>  				mpfn |= MIGRATE_PFN_WRITE;
>>  		} else {
>> -			if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))
>> -				goto next;
>
> Why not exclude MIGRATE_VMA_SELECT_DEVICE_PRIVATE here? IIRC that would
> have happened before this change.

I might be missing something as I don't quite follow - this path is for
normal system pages so we only want to skip selecting them if
MIGRATE_VMA_SELECT_SYSTEM or MIGRATE_VMA_SELECT_DEVICE_COHERENT aren't
set.

Note that MIGRATE_VMA_SELECT_DEVICE_PRIVATE doesn't apply here because
we already know it's not a device private page by virtue of
pte_present(pte) == True.

>>  			pfn = pte_pfn(pte);
>> -			if (is_zero_pfn(pfn)) {
>> +			if (is_zero_pfn(pfn) &&
>> +			    (migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) {
>>  				mpfn = MIGRATE_PFN_MIGRATE;
>>  				migrate->cpages++;
>>  				goto next;
>>  			}
>>  			page = vm_normal_page(migrate->vma, addr, pte);
>> +			if (page && !is_zone_device_page(page) &&
>
> I'm wondering if that check logically belongs into patch #2.

I don't think so as it would break functionality until the below
conditionals are added - we explicitly don't want to skip
is_zone_device_page(page) == False here because that is the pages we are
trying to select.

You could add in this:

>> +			    !(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))

But then in patch 2 we know this can never be true because we've already
checked for !MIGRATE_VMA_SELECT_SYSTEM there.

>> +				goto next;
>> +			else if (page && is_device_coherent_page(page) &&
>> +			    (!(migrate->flags & MIGRATE_VMA_SELECT_DEVICE_COHERENT) ||
>> +			     page->pgmap->owner != migrate->pgmap_owner))
>
>
> In general LGTM

WARNING: multiple messages have this Message-ID (diff)
From: Alistair Popple <apopple@nvidia.com>
To: David Hildenbrand <david@redhat.com>
Cc: Alex Sierra <alex.sierra@amd.com>,
	rcampbell@nvidia.com, willy@infradead.org,
	Felix.Kuehling@amd.com, amd-gfx@lists.freedesktop.org,
	linux-xfs@vger.kernel.org, linux-mm@kvack.org,
	jglisse@redhat.com, dri-devel@lists.freedesktop.org,
	jgg@nvidia.com, akpm@linux-foundation.org,
	linux-ext4@vger.kernel.org, hch@lst.de
Subject: Re: [PATCH v7 04/14] mm: add device coherent vma selection for memory migration
Date: Thu, 30 Jun 2022 21:44:55 +1000	[thread overview]
Message-ID: <878rpe73t3.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <956b1c51-b8f1-0480-81ca-5d03b45110f7@redhat.com>


David Hildenbrand <david@redhat.com> writes:

> On 29.06.22 05:54, Alex Sierra wrote:
>> This case is used to migrate pages from device memory, back to system
>> memory. Device coherent type memory is cache coherent from device and CPU
>> point of view.
>>
>> Signed-off-by: Alex Sierra <alex.sierra@amd.com>
>> Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
>> Reviewed-by: Alistair Poppple <apopple@nvidia.com>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
>
> I'm not too familiar with this code, please excuse my naive questions:
>
>> @@ -148,15 +148,21 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
>>  			if (is_writable_device_private_entry(entry))
>>  				mpfn |= MIGRATE_PFN_WRITE;
>>  		} else {
>> -			if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))
>> -				goto next;
>
> Why not exclude MIGRATE_VMA_SELECT_DEVICE_PRIVATE here? IIRC that would
> have happened before this change.

I might be missing something as I don't quite follow - this path is for
normal system pages so we only want to skip selecting them if
MIGRATE_VMA_SELECT_SYSTEM or MIGRATE_VMA_SELECT_DEVICE_COHERENT aren't
set.

Note that MIGRATE_VMA_SELECT_DEVICE_PRIVATE doesn't apply here because
we already know it's not a device private page by virtue of
pte_present(pte) == True.

>>  			pfn = pte_pfn(pte);
>> -			if (is_zero_pfn(pfn)) {
>> +			if (is_zero_pfn(pfn) &&
>> +			    (migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) {
>>  				mpfn = MIGRATE_PFN_MIGRATE;
>>  				migrate->cpages++;
>>  				goto next;
>>  			}
>>  			page = vm_normal_page(migrate->vma, addr, pte);
>> +			if (page && !is_zone_device_page(page) &&
>
> I'm wondering if that check logically belongs into patch #2.

I don't think so as it would break functionality until the below
conditionals are added - we explicitly don't want to skip
is_zone_device_page(page) == False here because that is the pages we are
trying to select.

You could add in this:

>> +			    !(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))

But then in patch 2 we know this can never be true because we've already
checked for !MIGRATE_VMA_SELECT_SYSTEM there.

>> +				goto next;
>> +			else if (page && is_device_coherent_page(page) &&
>> +			    (!(migrate->flags & MIGRATE_VMA_SELECT_DEVICE_COHERENT) ||
>> +			     page->pgmap->owner != migrate->pgmap_owner))
>
>
> In general LGTM

  reply	other threads:[~2022-06-30 12:07 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29  3:54 [PATCH v7 00/14] Add MEMORY_DEVICE_COHERENT for coherent device memory mapping Alex Sierra
2022-06-29  3:54 ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 01/14] mm: rename is_pinnable_pages to is_pinnable_longterm_pages Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  7:33   ` David Hildenbrand
2022-06-29  7:33     ` David Hildenbrand
2022-06-29 22:08     ` Felix Kuehling
2022-06-29 22:08       ` Felix Kuehling
2022-06-29 22:15       ` David Hildenbrand
2022-06-29 22:15         ` David Hildenbrand
2022-07-02  4:25         ` Andrew Morton
2022-07-02  4:25           ` Andrew Morton
2022-06-29 23:24       ` Andrew Morton
2022-06-29 23:24         ` Andrew Morton
2022-06-29  3:54 ` [PATCH v7 02/14] mm: add zone device coherent type memory support Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29 18:48   ` David Hildenbrand
2022-06-29 18:48     ` David Hildenbrand
2022-06-29  3:54 ` [PATCH v7 03/14] mm: handling Non-LRU pages returned by vm_normal_pages Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  9:59   ` David Hildenbrand
2022-06-29  9:59     ` David Hildenbrand
2022-06-29 23:31     ` Andrew Morton
2022-06-29 23:31       ` Andrew Morton
2022-06-29  3:54 ` [PATCH v7 04/14] mm: add device coherent vma selection for memory migration Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-30 10:04   ` David Hildenbrand
2022-06-30 10:04     ` David Hildenbrand
2022-06-30 11:44     ` Alistair Popple [this message]
2022-06-30 11:44       ` Alistair Popple
2022-06-30 20:56       ` David Hildenbrand
2022-06-30 20:56         ` David Hildenbrand
2022-06-29  3:54 ` [PATCH v7 05/14] mm: remove the vma check in migrate_vma_setup() Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 06/14] mm/gup: migrate device coherent pages when pinning instead of failing Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 07/14] drm/amdkfd: add SPM support for SVM Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 08/14] lib: test_hmm add ioctl to get zone device type Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 09/14] lib: test_hmm add module param for " Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 10/14] lib: add support for device coherent type in test_hmm Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 11/14] tools: update hmm-test to support device coherent type Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 12/14] tools: update test_hmm script to support SP config Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 13/14] tools: add hmm gup tests for device coherent type Alex Sierra
2022-06-29  3:54   ` Alex Sierra
2022-06-29  3:54 ` [PATCH v7 14/14] tools: add selftests to hmm for COW in device memory Alex Sierra
2022-06-29  3:54   ` Alex Sierra

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=878rpe73t3.fsf@nvdebian.thelocal \
    --to=apopple@nvidia.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.sierra@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=david@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.