mm/swapops: rework swap entry manipulation code
Both migration and device private pages use special swap entries that are manipluated by a range of inline functions. The arguments to these are somewhat inconsistent so rework them to remove flag type arguments and to make the arguments similar for both read and write entry creation. Link: https://lkml.kernel.org/r/20210616105937.23201-3-apopple@nvidia.com Signed-off-by: Alistair Popple <apopple@nvidia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Ralph Campbell <rcampbell@nvidia.com> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: Peter Xu <peterx@redhat.com> Cc: Shakeel Butt <shakeelb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
af5cdaf822
commit
4dd845b5a3
26
mm/migrate.c
26
mm/migrate.c
@@ -210,13 +210,18 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
|
||||
* Recheck VMA as permissions can change since migration started
|
||||
*/
|
||||
entry = pte_to_swp_entry(*pvmw.pte);
|
||||
if (is_write_migration_entry(entry))
|
||||
if (is_writable_migration_entry(entry))
|
||||
pte = maybe_mkwrite(pte, vma);
|
||||
else if (pte_swp_uffd_wp(*pvmw.pte))
|
||||
pte = pte_mkuffd_wp(pte);
|
||||
|
||||
if (unlikely(is_device_private_page(new))) {
|
||||
entry = make_device_private_entry(new, pte_write(pte));
|
||||
if (pte_write(pte))
|
||||
entry = make_writable_device_private_entry(
|
||||
page_to_pfn(new));
|
||||
else
|
||||
entry = make_readable_device_private_entry(
|
||||
page_to_pfn(new));
|
||||
pte = swp_entry_to_pte(entry);
|
||||
if (pte_swp_soft_dirty(*pvmw.pte))
|
||||
pte = pte_swp_mksoft_dirty(pte);
|
||||
@@ -2297,7 +2302,7 @@ again:
|
||||
|
||||
mpfn = migrate_pfn(page_to_pfn(page)) |
|
||||
MIGRATE_PFN_MIGRATE;
|
||||
if (is_write_device_private_entry(entry))
|
||||
if (is_writable_device_private_entry(entry))
|
||||
mpfn |= MIGRATE_PFN_WRITE;
|
||||
} else {
|
||||
if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))
|
||||
@@ -2343,8 +2348,12 @@ again:
|
||||
ptep_get_and_clear(mm, addr, ptep);
|
||||
|
||||
/* Setup special migration page table entry */
|
||||
entry = make_migration_entry(page, mpfn &
|
||||
MIGRATE_PFN_WRITE);
|
||||
if (mpfn & MIGRATE_PFN_WRITE)
|
||||
entry = make_writable_migration_entry(
|
||||
page_to_pfn(page));
|
||||
else
|
||||
entry = make_readable_migration_entry(
|
||||
page_to_pfn(page));
|
||||
swp_pte = swp_entry_to_pte(entry);
|
||||
if (pte_present(pte)) {
|
||||
if (pte_soft_dirty(pte))
|
||||
@@ -2817,7 +2826,12 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
|
||||
if (is_device_private_page(page)) {
|
||||
swp_entry_t swp_entry;
|
||||
|
||||
swp_entry = make_device_private_entry(page, vma->vm_flags & VM_WRITE);
|
||||
if (vma->vm_flags & VM_WRITE)
|
||||
swp_entry = make_writable_device_private_entry(
|
||||
page_to_pfn(page));
|
||||
else
|
||||
swp_entry = make_readable_device_private_entry(
|
||||
page_to_pfn(page));
|
||||
entry = swp_entry_to_pte(swp_entry);
|
||||
} else {
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user