Skip to contentSkip to conversation

sched/fair: Fix kernel build warning in test_idle_cores() for !SMT NUMA

PATCH In review Mel Gorman 3 participants 3 messages Feb 27, 2020 – Mar 3, 2020 Scheduler

lore
Share & tools
lore

Mel Gorman

author
#0 lore raw

PATCH 1/1 sched/fair: Fix kernel build warning in test_idle_cores() for !SMT NUMA

Building against tip/sched/core as of as ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a migration target instead of comparing tasks") with the arm64 defconfig (which doesn't have CONFIG_SCHED_SMT set) leads to:

kernel/sched/fair.c:1525:20: warning: ‘test_idle_cores’ declared ‘static’ but never defined [-Wunused-function]
static inline bool test_idle_cores(int cpu, bool def);

		      ^~~~~~~~~~~~~~~

Rather than define it in its own CONFIG_SCHED_SMT #define island, bunch it up with test_idle_cores().

Fixes ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a migration target instead of comparing tasks")
[[email protected]: Edit changelog, minor style change]
---
 kernel/sched/fair.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
kernel/sched/fair.c +9 -5
index fcc968669aea..10f9e6729fcf 100644
@@ -1520,9 +1520,6 @@ static inline bool is_core_idle(int cpu)
 	return true;
 }
 
-/* Forward declarations of select_idle_sibling helpers */
-static inline bool test_idle_cores(int cpu, bool def);
-
 struct task_numa_env {
 	struct task_struct *p;
 
@@ -1558,9 +1555,11 @@ numa_type numa_classify(unsigned int imbalance_pct,
 	return node_fully_busy;
 }
 
+#ifdef CONFIG_SCHED_SMT
+/* Forward declarations of select_idle_sibling helpers */
+static inline bool test_idle_cores(int cpu, bool def);
 static inline int numa_idle_core(int idle_core, int cpu)
 {
-#ifdef CONFIG_SCHED_SMT
 	if (!static_branch_likely(&sched_smt_present) ||
 	    idle_core >= 0 || !test_idle_cores(cpu, false))
 		return idle_core;
@@ -1571,10 +1570,15 @@ static inline int numa_idle_core(int idle_core, int cpu)
 	 */
 	if (is_core_idle(cpu))
 		idle_core = cpu;
-#endif
 
 	return idle_core;
 }
+#else
+static inline int numa_idle_core(int idle_core, int cpu)
+{
+	return idle_core;
+}
+#endif
 
 /*
  * Gather all necessary information to make NUMA balancing placement
Reviewed-by on v1 1/1
#1 lore raw
Quoted 54 lines · Mel Gorman

Building against tip/sched/core as of as ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a migration target instead of comparing tasks") with the arm64 defconfig (which doesn't have CONFIG_SCHED_SMT set) leads to:

   kernel/sched/fair.c:1525:20: warning: ‘test_idle_cores’ declared ‘static’ but never defined [-Wunused-function]
    static inline bool test_idle_cores(int cpu, bool def);
		      ^~~~~~~~~~~~~~~

Rather than define it in its own CONFIG_SCHED_SMT #define island, bunch it up with test_idle_cores().

Fixes ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a migration target instead of comparing tasks")
[[email protected]: Edit changelog, minor style change]
---
  kernel/sched/fair.c | 14 +++++++++-----
  1 file changed, 9 insertions(+), 5 deletions(-)
kernel/sched/fair.c +3 -5
index fcc968669aea..10f9e6729fcf 100644
@@ -1520,9 +1520,6 @@ static inline bool is_core_idle(int cpu)
  	return true;
  }
 
-/* Forward declarations of select_idle_sibling helpers */
-static inline bool test_idle_cores(int cpu, bool def);
-
  struct task_numa_env {
  	struct task_struct *p;
 
@@ -1558,9 +1555,11 @@ numa_type numa_classify(unsigned int imbalance_pct,
  	return node_fully_busy;
  }
 
+#ifdef CONFIG_SCHED_SMT
+/* Forward declarations of select_idle_sibling helpers */
+static inline bool test_idle_cores(int cpu, bool def);
  static inline int numa_idle_core(int idle_core, int cpu)
  {
-#ifdef CONFIG_SCHED_SMT
  	if (!static_branch_likely(&sched_smt_present) ||
  	    idle_core >= 0 || !test_idle_cores(cpu, false))
  		return idle_core;
@@ -1571,10 +1570,15 @@ static inline int numa_idle_core(int idle_core, int cpu)
  	 */
  	if (is_core_idle(cpu))
  		idle_core = cpu;
-#endif
 
  	return idle_core;

kernel/sched/fair.c static inline int numa_idle_core(int idle_core, int cpu) · line 1584

Quoted 10 lines
kernel/sched/fair.c +6 -0
  }
+#else
+static inline int numa_idle_core(int idle_core, int cpu)
+{
+	return idle_core;
+}
+#endif
 
  /*
   * Gather all necessary information to make NUMA balancing placement

Looks good (apart from odd formatting got in '’') and calms down yesterday's build of next (next-20200227 were I spotted it) and today's also.

Regards,
Lukasz

#2 lore raw
In reply to Mel Gorman
Quoted 5 lines · Mel Gorman

Building against tip/sched/core as of as ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a migration target instead of comparing tasks") with the arm64 defconfig (which doesn't have CONFIG_SCHED_SMT set) leads to:

kernel/sched/fair.c:1525:20: warning: ‘test_idle_cores’ declared ‘static’ but never defined [-Wunused-function]

^ ^ ^ ^
For some reason the quotes got turned into â in your edit. Doesn't really matter TBH.

Quoted 10 lines
   static inline bool test_idle_cores(int cpu, bool def);
		      ^~~~~~~~~~~~~~~

Rather than define it in its own CONFIG_SCHED_SMT #define island, bunch it up with test_idle_cores().

Fixes ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a migration target instead of comparing tasks")
[[email protected]: Edit changelog, minor style change]

Could we get this in tip (and hopefully -next will follow shortly)? We're at like the third duplicate fix on the list already.