Skip to contentSkip to conversation

memory-tiering-adjust-hot-threshold-automatically.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Sep 12, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: memory tiering: adjust hot threshold automatically
has been removed from the -mm tree. Its filename was
memory-tiering-adjust-hot-threshold-automatically.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Huang Ying <[email protected]>
Subject: memory tiering: adjust hot threshold automatically
Date: Wed, 13 Jul 2022 16:39:53 +0800

The promotion hot threshold is workload and system configuration dependent. So in this patch, a method to adjust the hot threshold automatically is implemented. The basic idea is to control the number of the candidate promotion pages to match the promotion rate limit. If the hint page fault latency of a page is less than the hot threshold, we will try to promote the page, and the page is called the candidate promotion page.

If the number of the candidate promotion pages in the statistics interval is much more than the promotion rate limit, the hot threshold will be decreased to reduce the number of the candidate promotion pages. Otherwise, the hot threshold will be increased to increase the number of the candidate promotion pages.

To make the above method works, in each statistics interval, the total number of the pages to check (on which the hint page faults occur) and the hot/cold distribution need to be stable. Because the page tables are scanned linearly in NUMA balancing, but the hot/cold distribution isn't uniform along the address usually, the statistics interval should be larger than the NUMA balancing scan period. So in the patch, the max scan period is used as statistics interval and it works well in our tests.

---

 include/linux/mmzone.h |    9 +++++++
 kernel/sched/core.c    |   14 +++++++++++
 kernel/sched/fair.c    |   46 ++++++++++++++++++++++++++++++++++-----
 3 files changed, 64 insertions(+), 5 deletions(-)
include/linux/mmzone.h renamed from include/linux/mmzone.h~memory-tiering-adjust-hot-threshold-automatically +9 -0
@@ -1004,6 +1004,15 @@ typedef struct pglist_data {
 	unsigned int nbp_rl_start;
 	/* number of promote candidate pages at start time of current rate limit period */
 	unsigned long nbp_rl_nr_cand;
+	/* promote threshold in ms */
+	unsigned int nbp_threshold;
+	/* start time in ms of current promote threshold adjustment period */
+	unsigned int nbp_th_start;
+	/*
+	 * number of promote candidate pages at stat time of current promote
+	 * threshold adjustment period
+	 */
+	unsigned long nbp_th_nr_cand;
 #endif
 	/* Fields commonly accessed by the page reclaim scanner */
 
kernel/sched/core.c renamed from kernel/sched/core.c~memory-tiering-adjust-hot-threshold-automatically +14 -0
@@ -4396,6 +4396,17 @@ void set_numabalancing_state(bool enable
 }
 
 #ifdef CONFIG_PROC_SYSCTL
+static void reset_memory_tiering(void)
+{
+	struct pglist_data *pgdat;
+
+	for_each_online_pgdat(pgdat) {
+		pgdat->nbp_threshold = 0;
+		pgdat->nbp_th_nr_cand = node_page_state(pgdat, PGPROMOTE_CANDIDATE);
+		pgdat->nbp_th_start = jiffies_to_msecs(jiffies);
+	}
+}
+
 int sysctl_numa_balancing(struct ctl_table *table, int write,
 			  void *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -4412,6 +4423,9 @@ int sysctl_numa_balancing(struct ctl_tab
 	if (err < 0)
 		return err;
 	if (write) {
+		if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) &&
+		    (state & NUMA_BALANCING_MEMORY_TIERING))
+			reset_memory_tiering();
 		sysctl_numa_balancing_mode = state;
 		__set_numabalancing_state(state);
 	}
kernel/sched/fair.c renamed from kernel/sched/fair.c~memory-tiering-adjust-hot-threshold-automatically +41 -5

66 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

migrate-fix-syscall-move_pages-return-value-for-failure.patch migrate_pages-remove-unnecessary-list_safe_reset_next.patch migrate_pages-fix-thp-failure-counting-for-enomem.patch migrate_pages-fix-failure-counting-for-thp-subpages-retrying.patch migrate_pages-fix-failure-counting-for-thp-on-enosys.patch migrate_pages-fix-failure-counting-for-thp-splitting.patch migrate_pages-fix-failure-counting-for-retry.patch