From: Huang Ying <ying.huang(a)intel.com>
ANBZ: #80
cherry-picked from
https://git.kernel.org/pub/scm/linux/kernel/git/vishal/tiering.git/commit/?…
Signed-off-by: "Huang, Ying" <ying.huang(a)intel.com>
Signed-off-by: Baolin Wang <baolin.wang(a)linux.alibaba.com>
---
include/linux/mmzone.h | 1 +
kernel/sched/fair.c | 6 ++++--
mm/vmstat.c | 1 +
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index fcc2c18..30b42ef 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -209,6 +209,7 @@ enum node_stat_item {
#ifdef CONFIG_NUMA_BALANCING
PGPROMOTE_SUCCESS, /* promote successfully */
PGPROMOTE_CANDIDATE, /* candidate pages to promote */
+ PROMOTE_THRESHOLD,
#endif
NR_VM_NODE_STAT_ITEMS
};
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fc954e1..f938351 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2930,7 +2930,7 @@ static void numa_migration_adjust_threshold(struct pglist_data
*pgdat,
unsigned long ref_th)
{
unsigned long now = jiffies, last_th_ts, th_period;
- unsigned long unit_th, th;
+ unsigned long unit_th, th, oth;
unsigned long nr_cand, ref_cand, diff_cand;
th_period = msecs_to_jiffies(sysctl_numa_balancing_scan_period_max);
@@ -2942,7 +2942,8 @@ static void numa_migration_adjust_threshold(struct pglist_data
*pgdat,
nr_cand = node_page_state(pgdat, PGPROMOTE_CANDIDATE);
diff_cand = nr_cand - pgdat->numa_threshold_nr_candidate;
unit_th = ref_th / NUMA_MIGRATION_ADJUST_STEPS;
- th = pgdat->numa_threshold ? : ref_th;
+ oth = pgdat->numa_threshold;
+ th = oth ? : ref_th;
if (diff_cand > ref_cand * 11 / 10)
th = max(th - unit_th, unit_th);
else if (diff_cand < ref_cand * 9 / 10)
@@ -2950,6 +2951,7 @@ static void numa_migration_adjust_threshold(struct pglist_data
*pgdat,
pgdat->numa_threshold_nr_candidate = nr_cand;
pgdat->numa_threshold = th;
trace_autonuma_threshold(pgdat->node_id, diff_cand, th);
+ mod_node_page_state(pgdat, PROMOTE_THRESHOLD, th - oth);
}
}
diff --git a/mm/vmstat.c b/mm/vmstat.c
index d921c42d..acd049b 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1189,6 +1189,7 @@ int fragmentation_index(struct zone *zone, unsigned int order)
#ifdef CONFIG_NUMA_BALANCING
"pgpromote_success",
"pgpromote_candidate",
+ "promote_threshold",
#endif
/* enum writeback_stat_item counters */
--
1.8.3.1