Skip to contentSkip to conversation

smp/hotplug: Differentiate the AP completion between up and down

tip:smp/urgent Peter Zijlstra 1 participant 1 message Sep 25, 2017 1 message not in the archive CPU hotplug

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Peter Zijlstra

author maintainer
#1 lore raw
Quoted 5 lines · tip-bot for Peter Zijlstra
(quoted diff) +1 -0
@@ -90,6 +92,18 @@ static void inline cpuhp_lock_release(bool bringup) { }
 
 #endif
 
+static inline void wait_for_ap_thread(struct cpuhp_cpu_state *st, bool bringup)

Review static void inline cpuhp_lock_release(bool bringup) { } · line 105

Quoted 10 lines
(quoted diff) +10 -0
+{
+	struct completion *done = bringup ? &st->done_up : &st->done_down;
+	wait_for_completion(done);
+}
+
+static inline void complete_ap_thread(struct cpuhp_cpu_state *st, bool bringup)
+{
+	struct completion *done = bringup ? &st->done_up : &st->done_down;
+	complete(done);
+}

This wants something like this on top to build on !SMP and SMP+!HOTPLUG without issue.

kernel/cpu.c +22 -20
@@ -93,18 +93,6 @@ static void inline cpuhp_lock_release(bo
 
 #endif
 
-static inline void wait_for_ap_thread(struct cpuhp_cpu_state *st, bool bringup)
-{
-	struct completion *done = bringup ? &st->done_up : &st->done_down;
-	wait_for_completion(done);
-}
-
-static inline void complete_ap_thread(struct cpuhp_cpu_state *st, bool bringup)
-{
-	struct completion *done = bringup ? &st->done_up : &st->done_down;
-	complete(done);
-}
-
 /**
  * cpuhp_step - Hotplug state machine step
  * @name:	Name of the step
@@ -145,14 +133,6 @@ static bool cpuhp_is_ap_state(enum cpuhp
 	return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU;
 }
 
-/*
- * The former STARTING/DYING states, ran with IRQs disabled and must not fail.
- */
-static bool cpuhp_is_atomic_state(enum cpuhp_state state)
-{
-	return CPUHP_AP_IDLE_DEAD <= state && state < CPUHP_AP_ONLINE;
-}
-
 static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state)
 {
 	struct cpuhp_step *sp;
@@ -247,6 +227,26 @@ static int cpuhp_invoke_callback(unsigne
 }
 
 #ifdef CONFIG_SMP
+static inline void wait_for_ap_thread(struct cpuhp_cpu_state *st, bool bringup)
+{
+	struct completion *done = bringup ? &st->done_up : &st->done_down;
+	wait_for_completion(done);
+}
+
+static inline void complete_ap_thread(struct cpuhp_cpu_state *st, bool bringup)
+{
+	struct completion *done = bringup ? &st->done_up : &st->done_down;
+	complete(done);
+}
+
+/*
+ * The former STARTING/DYING states, ran with IRQs disabled and must not fail.
+ */
+static bool cpuhp_is_atomic_state(enum cpuhp_state state)
+{
+	return CPUHP_AP_IDLE_DEAD <= state && state < CPUHP_AP_ONLINE;
+}
+
 /* Serializes the updates to cpu_online_mask, cpu_present_mask */
 static DEFINE_MUTEX(cpu_add_remove_lock);
 bool cpuhp_tasks_frozen;
@@ -443,6 +443,7 @@ static int bringup_cpu(unsigned int cpu)
 /*
  * Hotplug state machine related functions
  */
+#ifdef CONFIG_HOTPLUG_CPU
 static void undo_cpu_down(unsigned int cpu, struct cpuhp_cpu_state *st)
 {
 	for (st->state++; st->state < st->target; st->state++) {
@@ -469,6 +470,7 @@ static int cpuhp_down_callbacks(unsigned
 	}
 	return ret;
 }
+#endif
 
 static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
 {