[RFC -V2 7/8] autonuma, memory tiering: Double hot threshold for write hint page fault

From: Huang, Ying
Date: Tue Feb 18 2020 - 03:27:41 EST


From: Huang Ying <ying.huang@xxxxxxxxx>

The write performance of PMEM is much worse than its read
performance. So even if a write-mostly pages is colder than a
read-mostly pages, it is usually better to put the write-mostly pages
in DRAM and read-mostly pages in PMEM.

To give write-mostly pages more opportunity to be promoted to DRAM, in
this patch, the hot threshold for write hint page fault is
doubled (easier to be promoted).

Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxx>
Cc: Mel Gorman <mgorman@xxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
---
include/linux/sched/numa_balancing.h | 1 +
kernel/sched/fair.c | 2 ++
mm/memory.c | 3 +++
3 files changed, 6 insertions(+)

diff --git a/include/linux/sched/numa_balancing.h b/include/linux/sched/numa_balancing.h
index 4899ec000245..518b3d6143ba 100644
--- a/include/linux/sched/numa_balancing.h
+++ b/include/linux/sched/numa_balancing.h
@@ -15,6 +15,7 @@
#define TNF_FAULT_LOCAL 0x08
#define TNF_MIGRATE_FAIL 0x10
#define TNF_YOUNG 0x20
+#define TNF_WRITE 0x40

#ifdef CONFIG_NUMA_BALANCING
extern void task_numa_fault(int last_node, int node, int pages, int flags);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 773f3220efc4..e5f7f4139c82 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1513,6 +1513,8 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page,
return false;

th = msecs_to_jiffies(sysctl_numa_balancing_hot_threshold);
+ if (flags & TNF_WRITE)
+ th *= 2;
latency = numa_hint_fault_latency(p, addr);
if (latency > th)
return false;
diff --git a/mm/memory.c b/mm/memory.c
index 207caa9e61da..595d3cd62f61 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3829,6 +3829,9 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
if (pte_young(old_pte))
flags |= TNF_YOUNG;

+ if (vmf->flags & FAULT_FLAG_WRITE)
+ flags |= TNF_WRITE;
+
page = vm_normal_page(vma, vmf->address, pte);
if (!page)
goto unmap_out;
--
2.24.1