linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH] mm: fix migrate_vma_setup() src_owner and normal pages
@ 2020-06-22 22:20 Ralph Campbell
  2020-06-23 11:40 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Ralph Campbell @ 2020-06-22 22:20 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Jerome Glisse, John Hubbard, Christoph Hellwig, Jason Gunthorpe,
	Andrew Morton, Ralph Campbell

The caller of migrate_vma_setup() does not know what type of page is
stored in the CPU's page tables. Pages within the specified range are
free to be swapped out, migrated, or freed until after migrate_vma_setup()
returns. The caller needs to set struct migrate_vma.src_owner in case a
page is a ZONE device private page that the device owns and might want to
migrate. However, the current code skips normal anonymous pages if
src_owner is set, thus preventing those pages from being migrated.
Remove the src_owner check for normal pages since src_owner only applies
to device private pages and allow a range of normal and device private
pages to be migrated.

Fixes: 800bb1c8dc80 ("mm: handle multiple owners of device private pages in migrate_vma")
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
---

This is based on 5.8.0-rc2 for Andrew Morton's mm tree.
I believe it can be queued for 5.8-rcX after being reviewed.
This was part of a larger series but I'm resending it separately as
suggested by Jason Gunthorpe.
https://lore.kernel.org/linux-mm/20200619215649.32297-1-rcampbell@nvidia.com/

 mm/migrate.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index f37729673558..24535281cea3 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2295,8 +2295,6 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
 			if (is_write_device_private_entry(entry))
 				mpfn |= MIGRATE_PFN_WRITE;
 		} else {
-			if (migrate->src_owner)
-				goto next;
 			pfn = pte_pfn(pte);
 			if (is_zero_pfn(pfn)) {
 				mpfn = MIGRATE_PFN_MIGRATE;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] mm: fix migrate_vma_setup() src_owner and normal pages
  2020-06-22 22:20 [RESEND PATCH] mm: fix migrate_vma_setup() src_owner and normal pages Ralph Campbell
@ 2020-06-23 11:40 ` Christoph Hellwig
  2020-06-23 17:05   ` Ralph Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2020-06-23 11:40 UTC (permalink / raw)
  To: Ralph Campbell
  Cc: linux-mm, linux-kernel, Jerome Glisse, John Hubbard,
	Christoph Hellwig, Jason Gunthorpe, Andrew Morton

On Mon, Jun 22, 2020 at 03:20:08PM -0700, Ralph Campbell wrote:
> The caller of migrate_vma_setup() does not know what type of page is
> stored in the CPU's page tables. Pages within the specified range are
> free to be swapped out, migrated, or freed until after migrate_vma_setup()
> returns. The caller needs to set struct migrate_vma.src_owner in case a
> page is a ZONE device private page that the device owns and might want to
> migrate. However, the current code skips normal anonymous pages if
> src_owner is set, thus preventing those pages from being migrated.
> Remove the src_owner check for normal pages since src_owner only applies
> to device private pages and allow a range of normal and device private
> pages to be migrated.

src_owner being set means we want to migrate from device private
memory to normal host DRAM.  What kind of problem do you see of
not touching already present pages in that path?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] mm: fix migrate_vma_setup() src_owner and normal pages
  2020-06-23 11:40 ` Christoph Hellwig
@ 2020-06-23 17:05   ` Ralph Campbell
  2020-06-24  7:22     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Ralph Campbell @ 2020-06-23 17:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-mm, linux-kernel, Jerome Glisse, John Hubbard,
	Jason Gunthorpe, Andrew Morton


On 6/23/20 4:40 AM, Christoph Hellwig wrote:
> On Mon, Jun 22, 2020 at 03:20:08PM -0700, Ralph Campbell wrote:
>> The caller of migrate_vma_setup() does not know what type of page is
>> stored in the CPU's page tables. Pages within the specified range are
>> free to be swapped out, migrated, or freed until after migrate_vma_setup()
>> returns. The caller needs to set struct migrate_vma.src_owner in case a
>> page is a ZONE device private page that the device owns and might want to
>> migrate. However, the current code skips normal anonymous pages if
>> src_owner is set, thus preventing those pages from being migrated.
>> Remove the src_owner check for normal pages since src_owner only applies
>> to device private pages and allow a range of normal and device private
>> pages to be migrated.
> 
> src_owner being set means we want to migrate from device private
> memory to normal host DRAM.  What kind of problem do you see of
> not touching already present pages in that path?
> 

The problem is that migrate_vma_setup() invalidates the address range so any
previously migrated pages to device private memory have to be faulted in
again. By having the PFN of those device private pages in the src array, the
driver can reinstate the device MMU mappings and avoid the page faults.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] mm: fix migrate_vma_setup() src_owner and normal pages
  2020-06-23 17:05   ` Ralph Campbell
@ 2020-06-24  7:22     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-06-24  7:22 UTC (permalink / raw)
  To: Ralph Campbell
  Cc: Christoph Hellwig, linux-mm, linux-kernel, Jerome Glisse,
	John Hubbard, Jason Gunthorpe, Andrew Morton

On Tue, Jun 23, 2020 at 10:05:19AM -0700, Ralph Campbell wrote:
>
> On 6/23/20 4:40 AM, Christoph Hellwig wrote:
>> On Mon, Jun 22, 2020 at 03:20:08PM -0700, Ralph Campbell wrote:
>>> The caller of migrate_vma_setup() does not know what type of page is
>>> stored in the CPU's page tables. Pages within the specified range are
>>> free to be swapped out, migrated, or freed until after migrate_vma_setup()
>>> returns. The caller needs to set struct migrate_vma.src_owner in case a
>>> page is a ZONE device private page that the device owns and might want to
>>> migrate. However, the current code skips normal anonymous pages if
>>> src_owner is set, thus preventing those pages from being migrated.
>>> Remove the src_owner check for normal pages since src_owner only applies
>>> to device private pages and allow a range of normal and device private
>>> pages to be migrated.
>>
>> src_owner being set means we want to migrate from device private
>> memory to normal host DRAM.  What kind of problem do you see of
>> not touching already present pages in that path?
>>
>
> The problem is that migrate_vma_setup() invalidates the address range so any
> previously migrated pages to device private memory have to be faulted in
> again. By having the PFN of those device private pages in the src array, the
> driver can reinstate the device MMU mappings and avoid the page faults.

Maybe add that to the changelog?


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-24  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 22:20 [RESEND PATCH] mm: fix migrate_vma_setup() src_owner and normal pages Ralph Campbell
2020-06-23 11:40 ` Christoph Hellwig
2020-06-23 17:05   ` Ralph Campbell
2020-06-24  7:22     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).