@@ -1016,6 +1016,7 @@ static struct node_attr node_state_attr[] = {
#endif
[N_MEMORY] = _NODE_ATTR(has_memory, N_MEMORY),
[N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
+ [N_TOPTIER] = _NODE_ATTR(is_toptier, N_TOPTIER),
[N_GENERIC_INITIATOR] = _NODE_ATTR(has_generic_initiator,
N_GENERIC_INITIATOR),
};
@@ -1029,6 +1030,7 @@ static struct attribute *node_state_attrs[] = {
#endif
&node_state_attr[N_MEMORY].attr.attr,
&node_state_attr[N_CPU].attr.attr,
+ &node_state_attr[N_TOPTIER].attr.attr,
&node_state_attr[N_GENERIC_INITIATOR].attr.attr,
NULL
};
@@ -399,6 +399,7 @@ enum node_states {
#endif
N_MEMORY, /* The node has memory(regular, high, movable) */
N_CPU, /* The node has one or more cpus */
+ N_TOPTIER, /* Top tier node, no demotion path into node */
N_GENERIC_INITIATOR, /* The node has one or more Generic Initiators */
NR_NODE_STATES
};
@@ -36,6 +36,7 @@
#include <linux/memblock.h>
#include <linux/compaction.h>
#include <linux/rmap.h>
+#include <linux/node.h>
#include <asm/tlbflush.h>
@@ -654,6 +655,8 @@ static void node_states_set_node(int node, struct memory_notify *arg)
if (arg->status_change_nid >= 0)
node_set_state(node, N_MEMORY);
+
+ node_set_state(node, N_TOPTIER);
}
static void __meminit resize_zone_range(struct zone *zone, unsigned long start_pfn,
@@ -3439,6 +3439,7 @@ static int establish_migrate_target(int node, nodemask_t *used)
return NUMA_NO_NODE;
node_demotion[node] = migration_target;
+ node_clear_state(migration_target, N_TOPTIER);
return migration_target;
}
@@ -157,6 +157,7 @@ nodemask_t node_states[NR_NODE_STATES] __read_mostly = {
[N_MEMORY] = { { [0] = 1UL } },
[N_CPU] = { { [0] = 1UL } },
#endif /* NUMA */
+ [N_TOPTIER] = NODE_MASK_ALL,
};
EXPORT_SYMBOL(node_states);
@@ -7590,8 +7591,10 @@ void __init free_area_init(unsigned long *max_zone_pfn)
free_area_init_node(nid);
/* Any memory on that node */
- if (pgdat->node_present_pages)
+ if (pgdat->node_present_pages) {
node_set_state(nid, N_MEMORY);
+ node_set_state(nid, N_TOPTIER);
+ }
check_for_memory(pgdat, nid);
}
}
Traditionally, all RAM is DRAM. Some DRAM might be closer/faster than others, but a byte of media has about the same cost whether it is close or far. But, with new memory tiers such as High-Bandwidth Memory or Persistent Memory, there is a choice between fast/expensive and slow/cheap. The fast/expensive memory lives in the top tier of the memory hierachy and it is a precious resource that needs to be accounted and managed on a memory cgroup basis. Define the top tier memory as the memory nodes that don't have demotion paths into it from higher tier memory. Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com> --- drivers/base/node.c | 2 ++ include/linux/nodemask.h | 1 + mm/memory_hotplug.c | 3 +++ mm/migrate.c | 1 + mm/page_alloc.c | 5 ++++- 5 files changed, 11 insertions(+), 1 deletion(-)