#include <linux/types.h>
struct task_struct;
+
+#ifdef CONFIG_GENERIC_SMP_IDLE_THREAD
+struct task_struct *idle_thread_get(unsigned int cpu, bool unpoison);
+#else
+static inline struct task_struct *idle_thread_get(unsigned int cpu, bool unpoison)
+{
+ return NULL;
+}
+#endif
+
/* Cookie handed to the thread_fn*/
struct smpboot_thread_data;
#include <linux/smpboot.h>
#include <linux/relay.h>
#include <linux/slab.h>
-#include <linux/scs.h>
#include <linux/percpu-rwsem.h>
#include <linux/cpuset.h>
#include <linux/random.h>
static int bringup_cpu(unsigned int cpu)
{
- struct task_struct *idle = idle_thread_get(cpu);
+ struct task_struct *idle = idle_thread_get(cpu, true);
int ret;
- /*
- * Reset stale stack state from the last time this CPU was online.
- */
- scs_task_reset(idle);
- kasan_unpoison_task_stack(idle);
-
/*
* Some architectures have to walk the irq descriptors to
* setup the vector space for the cpu which comes online.
static int finish_cpu(unsigned int cpu)
{
- struct task_struct *idle = idle_thread_get(cpu);
+ struct task_struct *idle = idle_thread_get(cpu, false);
struct mm_struct *mm = idle->active_mm;
/*
if (st->state == CPUHP_OFFLINE) {
/* Let it fail before we try to bring the cpu up */
- idle = idle_thread_get(cpu);
+ idle = idle_thread_get(cpu, false);
if (IS_ERR(idle)) {
ret = PTR_ERR(idle);
goto out;
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/sched/task.h>
+#include <linux/scs.h>
#include <linux/export.h>
#include <linux/percpu.h>
#include <linux/kthread.h>
*/
static DEFINE_PER_CPU(struct task_struct *, idle_threads);
-struct task_struct *idle_thread_get(unsigned int cpu)
+struct task_struct *idle_thread_get(unsigned int cpu, bool unpoison)
{
struct task_struct *tsk = per_cpu(idle_threads, cpu);
if (!tsk)
return ERR_PTR(-ENOMEM);
+
+ if (unpoison) {
+ /*
+ * Reset stale stack state from last time this CPU was online.
+ */
+ scs_task_reset(tsk);
+ kasan_unpoison_task_stack(tsk);
+ }
return tsk;
}
struct task_struct;
#ifdef CONFIG_GENERIC_SMP_IDLE_THREAD
-struct task_struct *idle_thread_get(unsigned int cpu);
void idle_thread_set_boot_cpu(void);
void idle_threads_init(void);
#else
-static inline struct task_struct *idle_thread_get(unsigned int cpu) { return NULL; }
static inline void idle_thread_set_boot_cpu(void) { }
static inline void idle_threads_init(void) { }
#endif