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/?…
When THP is promoted from the slow memory node to the fast memory
node, migrate_balanced_pgdat() is called to check whether there's
enough free space on the target node. But originally, only the total
number of the free pages is considered, but the order of the free
pages isn't considered. So it's possible that there's no free page
with expected order, although the total number of the free pages is
enough. So that the page demotion for the fast memory node isn't
initiated to make the high order pages available.
To solve the above issue, the page order is considered in
migrate_balanced_pgdat().
TODO: test results?
Signed-off-by: "Huang, Ying" <ying.huang(a)intel.com>
Signed-off-by: Baolin Wang <baolin.wang(a)linux.alibaba.com>
---
mm/migrate.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 0ac0e86..e9c022e 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1949,8 +1949,7 @@ static int kernel_move_pages(pid_t pid, unsigned long nr_pages,
* Returns true if this is a safe migration target node for misplaced NUMA
* pages. Currently it only checks the watermarks which crude
*/
-static bool migrate_balanced_pgdat(struct pglist_data *pgdat,
- unsigned long nr_migrate_pages)
+static bool migrate_balanced_pgdat(struct pglist_data *pgdat, int order)
{
int z;
@@ -1960,10 +1959,9 @@ static bool migrate_balanced_pgdat(struct pglist_data *pgdat,
if (!populated_zone(zone))
continue;
- /* Avoid waking kswapd by allocating pages_to_migrate pages. */
- if (!zone_watermark_ok(zone, 0,
- high_wmark_pages(zone) +
- nr_migrate_pages,
+ /* Avoid waking kswapd by allocating pages to migrate. */
+ if (!zone_watermark_ok(zone, order,
+ high_wmark_pages(zone),
0, 0))
continue;
return true;
@@ -1994,7 +1992,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page
*page)
VM_BUG_ON_PAGE(order && !PageTransHuge(page), page);
/* Avoid migrating to a node that is nearly full */
- if (!migrate_balanced_pgdat(pgdat, 1UL << compound_order(page))) {
+ if (!migrate_balanced_pgdat(pgdat, order)) {
int z;
if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) ||
--
1.8.3.1