[PATCH 1/2] cpu, idle: move init_idle() out of idle_thread_get()

From: Andrey Ryabinin
Date: Wed Mar 02 2016 - 08:52:47 EST


Currently idle_thread_get() not only gets the idle task but also
initializes it. This is fine for _cpu_up() which is the only caller
of idle_thread_get().

idle_thread_get() is going to be used in the next patch, but it
would be nice to avoid double initialization of idle task.
Hence this patch removes init_idle() call from idle_thread_get()
and invokes it directly from _cpu_up().

No functional changes here.

Signed-off-by: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
---
kernel/cpu.c | 2 ++
kernel/smpboot.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 5b9d396..63d8e7b 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -503,6 +503,8 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen)
goto out;
}

+ init_idle(idle, cpu);
+
ret = smpboot_create_threads(cpu);
if (ret)
goto out;
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index d264f59..74687e8 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -31,7 +31,6 @@ struct task_struct *idle_thread_get(unsigned int cpu)

if (!tsk)
return ERR_PTR(-ENOMEM);
- init_idle(tsk, cpu);
return tsk;
}

--
2.4.10