[PATCH v1 01/15] mm: add zone device coherent type memory support
Sierra Guiza, Alejandro (Alex)
alex.sierra at amd.com
Thu May 12 18:45:16 UTC 2022
On 5/11/2022 9:58 PM, Alistair Popple wrote:
> Alex Sierra <alex.sierra at amd.com> writes:
>
> [...]
>
>> diff --git a/mm/rmap.c b/mm/rmap.c
>> index fedb82371efe..d57102cd4b43 100644
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -1995,7 +1995,8 @@ void try_to_migrate(struct folio *folio, enum ttu_flags flags)
>> TTU_SYNC)))
>> return;
>>
>> - if (folio_is_zone_device(folio) && !folio_is_device_private(folio))
>> + if (folio_is_zone_device(folio) &&
>> + (!folio_is_device_private(folio) && !folio_is_device_coherent(folio)))
>> return;
>>
>> /*
> I vaguely recall commenting on this previously, or at least intending
> to. In try_to_migrate_one() we have this:
>
> if (folio_is_zone_device(folio)) {
> unsigned long pfn = folio_pfn(folio);
> swp_entry_t entry;
> pte_t swp_pte;
>
> /*
> * Store the pfn of the page in a special migration
> * pte. do_swap_page() will wait until the migration
> * pte is removed and then restart fault handling.
> */
> entry = pte_to_swp_entry(pteval);
> if (is_writable_device_private_entry(entry))
> entry = make_writable_migration_entry(pfn);
> else
> entry = make_readable_migration_entry(pfn);
> swp_pte = swp_entry_to_pte(entry);
>
> The check in try_to_migrate() guarantees that if folio_is_zone_device()
> is true this must be a DEVICE_PRIVATE page and it treats it as such by
> assuming there is a special device private swap entry there.
>
> Relying on that assumption seems bad, and I have no idea why I didn't
> just use is_device_private_page() originally but I think the fix is just
> to change this to:
>
> if (folio_is_device_private(folio))
Thanks Alistair. This worked fine. I'll drop patch 4 and update this
patch in the next series version.
Regards,
Alex Sierra
>
> And let DEVICE_COHERENT pages fall through to normal page processing.
>
> - Alistair
More information about the amd-gfx
mailing list