From: "Gregory Price (Meta)" Restrict compaction to N_MEMORY_COMPACTION instead of common memory: - compact N_MEMORY_COMPACTION nodes for /proc/sys/vm/compact_memory. - start kcompactd and trigger proactive compaction on those nodes. Direct compaction is unchanged: an allocation compacts the zones on its zonelist, and a private node's zones are only on its private zonelist. nodeN/compact fails with -EOPNOTSUPP for private nodes without the state. Signed-off-by: Gregory Price (Meta) --- mm/compaction.c | 9 +++++---- mm/memory_hotplug.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 283d4d4e78c3..6835ddb91f29 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2973,7 +2973,7 @@ static int compact_nodes(void) /* Flush pending updates to the LRU lists */ lru_add_drain_all(); - for_each_node_state(nid, N_MEMORY_COMMON) { + for_each_node_state(nid, N_MEMORY_COMPACTION) { ret = compact_node(NODE_DATA(nid), false); if (ret) return ret; @@ -2992,7 +2992,7 @@ static int compaction_proactiveness_sysctl_handler(const struct ctl_table *table return rc; if (write && sysctl_compaction_proactiveness) { - for_each_node_state(nid, N_MEMORY_COMMON) { + for_each_node_state(nid, N_MEMORY_COMPACTION) { pg_data_t *pgdat = NODE_DATA(nid); if (pgdat->proactive_compact_trigger) @@ -3038,7 +3038,8 @@ static ssize_t compact_store(struct device *dev, int nid = dev->id; if (nid >= 0 && nid < nr_node_ids && node_online(nid)) { - if (node_state(nid, N_MEMORY_PRIVATE)) + if (node_state(nid, N_MEMORY) && + !node_state(nid, N_MEMORY_COMPACTION)) return -EOPNOTSUPP; /* Flush pending updates to the LRU lists */ @@ -3369,7 +3370,7 @@ static int __init kcompactd_init(void) { int nid; - for_each_node_state(nid, N_MEMORY_COMMON) + for_each_node_state(nid, N_MEMORY_COMPACTION) kcompactd_run(nid); register_sysctl_init("vm", vm_compaction); return 0; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index d7ce60c6815f..1cb10c88954e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1232,7 +1232,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages, if (node_state(nid, N_MEMORY_COMMON)) kswapd_run(nid); - if (node_state(nid, N_MEMORY_COMMON)) + if (node_state(nid, N_MEMORY_COMPACTION)) kcompactd_run(nid); if (node_arg.nid >= 0) -- 2.56.1