Blob Blame History Raw
From: Mel Gorman <mgorman@suse.de>
Date: Wed, 23 Sep 2020 16:59:29 +0100
Subject: [PATCH] sched/numa: Check numa balancing information only when
 enabled

References: bnc#1176588
Patch-mainline: Not yet, needs to be posted with the follow-on patch

When selecting the first CPU for a task to run, the NUMA balancing
information will be used if it is available. Avoid making the
checks if NUMA balancing is disabled. This is of marginal interest,
just popped out while preparing the second patch.

Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 kernel/sched/fair.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 327e3325c396..db02212b2fba 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8773,17 +8773,19 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu)
 	case group_has_spare:
 		if (sd->flags & SD_NUMA) {
 #ifdef CONFIG_NUMA_BALANCING
-			int idlest_cpu;
-			/*
-			 * If there is spare capacity at NUMA, try to select
-			 * the preferred node
-			 */
-			if (cpu_to_node(this_cpu) == p->numa_preferred_nid)
-				return NULL;
+			if (static_branch_likely(&sched_numa_balancing)) {
+				int idlest_cpu;
+				/*
+				 * If there is spare capacity at NUMA, try to select
+				 * the preferred node
+				 */
+				if (cpu_to_node(this_cpu) == p->numa_preferred_nid)
+					return NULL;
 
-			idlest_cpu = cpumask_first(sched_group_span(idlest));
-			if (cpu_to_node(idlest_cpu) == p->numa_preferred_nid)
-				return idlest;
+				idlest_cpu = cpumask_first(sched_group_span(idlest));
+				if (cpu_to_node(idlest_cpu) == p->numa_preferred_nid)
+					return idlest;
+			}
 #endif
 			/*
 			 * Otherwise, keep the task on this node to stay close