>From e18aa6158a60c2134b4eef93c856f3b5b250b122 Mon Sep 17 00:00:00 2001 From: Nathan Zimmer Date: Thu, 11 Jun 2015 10:47:39 -0500 Subject: [RFC] Avoid the contention in set_cpus_allowed Noticing some scaling issues at larger box sizes (64 nodes+) I found that in some cases we are spending significant amounts of time in set_cpus_allowed_ptr. My assumption is that it is getting stuck on migration. So if we create the thread on the target node and restrict cpus before we start the thread then we don't have to suffer migration. Cc: Mel Gorman Cc: Waiman Long Cc: Scott Norton Cc: Daniel J Blueman Signed-off-by: Nathan Zimmer --- mm/page_alloc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f88e8c4..531f7bc 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1090,16 +1090,12 @@ static int __init deferred_init_memmap(void *data) int i, zid; struct zone *zone; unsigned long first_init_pfn = pgdat->first_deferred_pfn; - const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); if (first_init_pfn == ULONG_MAX) { up_read(&pgdat_init_rwsem); return 0; } - /* Bind memory initialisation thread to a local node if possible */ - if (!cpumask_empty(cpumask)) - set_cpus_allowed_ptr(current, cpumask); /* Sanity check boundaries */ BUG_ON(pgdat->first_deferred_pfn < pgdat->node_start_pfn); @@ -1204,8 +1200,16 @@ void __init page_alloc_init_late(void) unsigned long start = jiffies; for_each_node_state(nid, N_MEMORY) { + struct task_struct *defer_task; + const struct cpumask *cpumask = cpumask_of_node(nid); down_read(&pgdat_init_rwsem); - kthread_run(deferred_init_memmap, NODE_DATA(nid), "pgdatinit%d", nid); + defer_task = kthread_create_on_node(deferred_init_memmap, + NODE_DATA(nid), nid, "pgdatinit%d", nid); + /* Bind memory initialisation thread to a local node if possible */ + if (!cpumask_empty(cpumask)) + set_cpus_allowed_ptr(defer_task, cpumask); + if (!IS_ERR(defer_task)) + wake_up_process(defer_task); } /* Block until all are initialised */ -- 1.8.2.1