All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] MIPS: move idle task creation to work queue
@ 2011-02-12 18:21 maksim.rayskiy
  2011-02-16 16:58 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: maksim.rayskiy @ 2011-02-12 18:21 UTC (permalink / raw)
  To: ralf, linux-mips; +Cc: Maksim Rayskiy

From: Maksim Rayskiy <mrayskiy@broadcom.com>

To avoid forking usermode thread when creating an idle task, move fork_idle
to a work queue.
This is a small improvement to 467f0b8e708390052ada48b28d1a56d20fe8b3de
[ MIPS: Clear idle task mm pointer when hotplugging cpu ]

Signed-off-by: Maksim Rayskiy <mrayskiy@broadcom.com>
---

Style improvements per Sergei's suggestions.

 arch/mips/kernel/smp.c |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 4593916..635484d 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -193,6 +193,22 @@ void __devinit smp_prepare_boot_cpu(void)
  */
 static struct task_struct *cpu_idle_thread[NR_CPUS];
 
+struct create_idle {
+	struct work_struct work;
+	struct task_struct *idle;
+	struct completion done;
+	int cpu;
+};
+
+static void __cpuinit do_fork_idle(struct work_struct *work)
+{
+	struct create_idle *c_idle =
+		container_of(work, struct create_idle, work);
+
+	c_idle->idle = fork_idle(c_idle->cpu);
+	complete(&c_idle->done);
+}
+
 int __cpuinit __cpu_up(unsigned int cpu)
 {
 	struct task_struct *idle;
@@ -203,16 +219,23 @@ int __cpuinit __cpu_up(unsigned int cpu)
 	 * Linux can schedule processes on this slave.
 	 */
 	if (!cpu_idle_thread[cpu]) {
-		idle = fork_idle(cpu);
-		cpu_idle_thread[cpu] = idle;
+		/*
+		 * Schedule work item to avoid forking user task
+		 * Ported from arch/x86/kernel/smpboot.c
+		 */
+		struct create_idle c_idle = {
+			.cpu	= cpu,
+			.done	= COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
+		};
+
+		INIT_WORK_ONSTACK(&c_idle.work, do_fork_idle);
+		schedule_work(&c_idle.work);
+		wait_for_completion(&c_idle.done);
+		idle = cpu_idle_thread[cpu] = c_idle.idle;
 
 		if (IS_ERR(idle))
 			panic(KERN_ERR "Fork failed for CPU %d", cpu);
 
-		if (idle->mm) {
-			mmput(idle->mm);
-			idle->mm = NULL;
-		}
 	} else {
 		idle = cpu_idle_thread[cpu];
 		init_idle(idle, cpu);
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] MIPS: move idle task creation to work queue
  2011-02-12 18:21 [PATCH v2] MIPS: move idle task creation to work queue maksim.rayskiy
@ 2011-02-16 16:58 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2011-02-16 16:58 UTC (permalink / raw)
  To: maksim.rayskiy; +Cc: linux-mips, Maksim Rayskiy

On Sat, Feb 12, 2011 at 10:21:32AM -0800, maksim.rayskiy@gmail.com wrote:

Thanks Maksim, applied.  This solves all the problems at once and is
barely more complex!

  Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-16 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-12 18:21 [PATCH v2] MIPS: move idle task creation to work queue maksim.rayskiy
2011-02-16 16:58 ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.