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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240803094715.23900-4-gourry@gourry.net>
Date: Sat,  3 Aug 2024 05:47:15 -0400
From: Gregory Price <gourry@...rry.net>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org,
	akpm@...ux-foundation.org,
	david@...hat.com,
	ying.huang@...el.com,
	nphamcs@...il.com,
	nehagholkar@...a.com,
	abhishekd@...a.com,
	Johannes Weiner <hannes@...xchg.org>
Subject: [PATCH 3/3] swap: enable promotion for unmapped pagecache on access

Unmapped pagecache presently cannot be promoted off of lower tiers,
even if they are being accessed by read/write calls. Enable migration
in mark_folio_accessed if a given folio presently resides on a lower
tier of memory.

Suggested-by: Johannes Weiner <hannes@...xchg.org>
Signed-off-by: Gregory Price <gourry@...rry.net>
---
 mm/swap.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/mm/swap.c b/mm/swap.c
index 9caf6b017cf0..08f76d748e29 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -37,6 +37,9 @@
 #include <linux/page_idle.h>
 #include <linux/local_lock.h>
 #include <linux/buffer_head.h>
+#include <linux/sched/sysctl.h>
+#include <linux/memory-tiers.h>
+#include <linux/migrate.h>
 
 #include "internal.h"
 
@@ -463,9 +466,26 @@ static void folio_inc_refs(struct folio *folio)
  *
  * When a newly allocated folio is not yet visible, so safe for non-atomic ops,
  * __folio_set_referenced() may be substituted for folio_mark_accessed().
+ *
+ * This call may also attempt to migrate the folio memory to the local node
+ * if it presently resides on a lower memory tier.
  */
 void folio_mark_accessed(struct folio *folio)
 {
+	int nid = folio_nid(folio);
+
+	/* If folio is on lower tier, try to promote to local node */
+	if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING &&
+	    (nid == NUMA_NO_NODE || !node_is_toptier(nid))) {
+		int flags;
+
+		nid = numa_migrate_prep(folio, NULL, 0, nid, &flags);
+		if ((nid != NUMA_NO_NODE) &&
+		    !migrate_misplaced_folio_prepare(folio, NULL, nid)) {
+			migrate_misplaced_folio(folio, nid);
+		}
+	}
+
 	if (lru_gen_enabled()) {
 		folio_inc_refs(folio);
 		return;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ