lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230507061726.13422-1-mpenttil@redhat.com>
Date:   Sun,  7 May 2023 09:17:26 +0300
From:   mpenttil@...hat.com
To:     linux-kernel@...r.kernel.org, linux-mm@...ck.org
Cc:     apopple@...dia.com, jhubbard@...dia.com, rcampbell@...dia.com,
        Mika Penttilä <mpenttil@...hat.com>
Subject: [PATCH] mm/migrate_device: Try to handle swapcache pages.

From: Mika Penttilä <mpenttil@...hat.com>

Migrating file pages and swapcache pages into device memory is not supported.
The decision is done based on page_mapping(). For now, swapcache pages are not migrated.

Things can however be improved, for swapcache pages. Try to get rid of the swap cache,
and if successful, go ahead as with other anonymous pages.

As a detail, do not mess with shmem pages, as they handle swap internally.

Cc: Alistair Popple <apopple@...dia.com>
Cc: John Hubbard <jhubbard@...dia.com>
Cc: Ralph Campbell <rcampbell@...dia.com>
Signed-off-by: Mika Penttilä <mpenttil@...hat.com>
---
 mm/migrate_device.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index d30c9de60b0d..e8169c58c341 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -12,6 +12,7 @@
 #include <linux/mmu_notifier.h>
 #include <linux/oom.h>
 #include <linux/pagewalk.h>
+#include <linux/shmem_fs.h>
 #include <linux/rmap.h>
 #include <linux/swapops.h>
 #include <asm/tlbflush.h>
@@ -750,10 +751,17 @@ static void __migrate_device_pages(unsigned long *src_pfns,
 			/*
 			 * For now only support anonymous memory migrating to
 			 * device private or coherent memory.
+			 *
+			 * Try to get rid of swap cache if possible.
+			 * Leave shmem pages alone, they handle swap internally
+			 *
 			 */
 			if (mapping) {
-				src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
-				continue;
+				if (shmem_mapping(mapping) ||
+				    !folio_free_swap(page_folio(page))) {
+					src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
+					continue;
+				}
 			}
 		} else if (is_zone_device_page(newpage)) {
 			/*
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ