[RFC][PATCH 18/18] sched: Sort hotplug vs ttwu queueing

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Peter Zijlstra
Date: Tuesday, January 4, 2011 - 7:59 am

On hot-unplug flush the pending wakeup queue by selecting a new rq for
each of them and requeueing them appropriately.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/sched.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -2526,6 +2526,29 @@ static void ttwu_queue(struct task_struc
 	raw_spin_unlock(&rq->lock);
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+static void ttwu_queue_unplug(struct rq *rq)
+{
+	struct task_struct *p, *list = xchg(&rq->wake_list, NULL);
+	unsigned long flags;
+	int cpu;
+
+	if (!list)
+		return;
+
+	while (list) {
+		p = list;
+		list = list->wake_entry;
+
+		raw_spin_lock_irqsave(&p->pi_lock, flags);
+		cpu = select_task_rq(p, SD_BALANCE_WAKE, 0);
+		set_task_cpu(p, cpu);
+		ttwu_queue(p, cpu);
+		raw_spin_unlock_irqrestore(&p->pi_lock, flags);
+	}
+}
+#endif
+
 /**
  * try_to_wake_up - wake up a thread
  * @p: the thread to be awakened
@@ -6151,6 +6174,11 @@ migration_call(struct notifier_block *nf
 		migrate_nr_uninterruptible(rq);
 		calc_global_load_remove(rq);
 		break;
+
+	case CPU_DEAD:
+		ttwu_queue_unplug(cpu_rq(cpu));
+		break;
+
 #endif
 	}
 	return NOTIFY_OK;


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH 01/18] sched: Always provide p-&gt;on_cpu, Peter Zijlstra, (Tue Jan 4, 7:59 am)
[RFC][PATCH 03/18] sched: Change the ttwu success details, Peter Zijlstra, (Tue Jan 4, 7:59 am)
[RFC][PATCH 04/18] sched: Clean up ttwu stats, Peter Zijlstra, (Tue Jan 4, 7:59 am)
[RFC][PATCH 05/18] sched: Provide p-&gt;on_rq, Peter Zijlstra, (Tue Jan 4, 7:59 am)
[RFC][PATCH 16/18] sched: Rename ttwu_post_activation, Peter Zijlstra, (Tue Jan 4, 7:59 am)
[RFC][PATCH 18/18] sched: Sort hotplug vs ttwu queueing, Peter Zijlstra, (Tue Jan 4, 7:59 am)