hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9812 ---------------------------------------- NUMA.remote's memory tier sits at the same level as DRAM, which breaks both NUMA demote and NUMA balancing promote: cold pages can no longer be demoted to the remote node, and hot pages cannot be promoted back to local DRAM. Because there is currently no bandwidth/latency data for NUMA.remote, the adist cannot be derived through the normal path. Hardcode the NUMA.remote adist to MEMTIER_ADISTANCE_DRAM * 5, so that it lands below DRAM in the memory tier hierarchy, making demote/promote work. Fixes: 5d0bd1321546 ("mm/numa_remote: support to hotplug/hotremove remote memory") Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com> --- drivers/base/numa_remote.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/base/numa_remote.c b/drivers/base/numa_remote.c index f924d7867394..b1ed72020482 100644 --- a/drivers/base/numa_remote.c +++ b/drivers/base/numa_remote.c @@ -12,6 +12,7 @@ #include <linux/memory.h> #include <linux/numa_remote.h> #include <linux/oom.h> +#include <linux/memory-tiers.h> #include "../../mm/hugetlb_vmemmap.h" #include "../../mm/internal.h" @@ -20,6 +21,8 @@ /* The default distance between two remote node */ #define REMOTE_TO_REMOTE_DISTANCE 255 +#define MEMTIER_DEFAULT_UB_ADISTANCE (MEMTIER_ADISTANCE_DRAM * 5) + bool numa_remote_enabled __ro_after_init; static bool numa_remote_nofallback_mode __ro_after_init; static bool numa_remote_preonline_mode __ro_after_init; @@ -680,6 +683,24 @@ int numa_remote_report_node_meminfo(char *buf, int len, int nid) nid, K(atomic_long_read(&pre_online_pages_node[nid]))); } +static int ub_calculate_adistance(struct notifier_block *self, + unsigned long nid, void *data) +{ + int *adist = data; + + if (!numa_is_remote_node(nid)) + return NOTIFY_OK; + + *adist = MEMTIER_DEFAULT_UB_ADISTANCE; + + return NOTIFY_STOP; +} + +static struct notifier_block ub_adist_nb __meminitdata = { + .notifier_call = ub_calculate_adistance, + .priority = 100, +}; + static int __init numa_remote_init(void) { int ret; @@ -700,6 +721,8 @@ static int __init numa_remote_init(void) if (ret) goto err_register_notifier; + register_mt_adistance_algorithm(&ub_adist_nb); + return 0; err_register_notifier: -- 2.43.0