Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234156
b: refs/heads/master
c: 6667deb
h: refs/heads/master
v: v3
  • Loading branch information
Maksim Rayskiy authored and Ralf Baechle committed Mar 14, 2011
1 parent 4e5a3de commit fd3948d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba9786f32473410bbec256db9745a7fbcaace69f
refs/heads/master: 6667deb69ee3b8a31ea88e1303cf3ad7d4f221da
31 changes: 29 additions & 2 deletions trunk/arch/mips/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -203,8 +219,19 @@ 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);
Expand Down

0 comments on commit fd3948d

Please sign in to comment.