x86/head/64: Move early exception dispatch to C code
[linux-2.6-microblaze.git] / kernel / kthread.c
index 132f84a..3edaa38 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/ptrace.h>
 #include <linux/uaccess.h>
 #include <linux/numa.h>
+#include <linux/sched/isolation.h>
 #include <trace/events/sched.h>
 
 
@@ -383,7 +384,8 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
                 * The kernel thread should not inherit these properties.
                 */
                sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
-               set_cpus_allowed_ptr(task, cpu_all_mask);
+               set_cpus_allowed_ptr(task,
+                                    housekeeping_cpumask(HK_FLAG_KTHREAD));
        }
        kfree(create);
        return task;
@@ -478,7 +480,6 @@ EXPORT_SYMBOL(kthread_bind);
  *          to "name.*%u". Code fills in cpu number.
  *
  * Description: This helper function creates and names a kernel thread
- * The thread will be woken and put into park mode.
  */
 struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
                                          void *data, unsigned int cpu,
@@ -608,7 +609,7 @@ int kthreadd(void *unused)
        /* Setup a clean context for our children to inherit. */
        set_task_comm(tsk, "kthreadd");
        ignore_signals(tsk);
-       set_cpus_allowed_ptr(tsk, cpu_all_mask);
+       set_cpus_allowed_ptr(tsk, housekeeping_cpumask(HK_FLAG_KTHREAD));
        set_mems_allowed(node_states[N_MEMORY]);
 
        current->flags |= PF_NOFREEZE;
@@ -1239,13 +1240,16 @@ void kthread_use_mm(struct mm_struct *mm)
        WARN_ON_ONCE(tsk->mm);
 
        task_lock(tsk);
+       /* Hold off tlb flush IPIs while switching mm's */
+       local_irq_disable();
        active_mm = tsk->active_mm;
        if (active_mm != mm) {
                mmgrab(mm);
                tsk->active_mm = mm;
        }
        tsk->mm = mm;
-       switch_mm(active_mm, mm, tsk);
+       switch_mm_irqs_off(active_mm, mm, tsk);
+       local_irq_enable();
        task_unlock(tsk);
 #ifdef finish_arch_post_lock_switch
        finish_arch_post_lock_switch();
@@ -1254,8 +1258,7 @@ void kthread_use_mm(struct mm_struct *mm)
        if (active_mm != mm)
                mmdrop(active_mm);
 
-       to_kthread(tsk)->oldfs = get_fs();
-       set_fs(USER_DS);
+       to_kthread(tsk)->oldfs = force_uaccess_begin();
 }
 EXPORT_SYMBOL_GPL(kthread_use_mm);
 
@@ -1270,13 +1273,15 @@ void kthread_unuse_mm(struct mm_struct *mm)
        WARN_ON_ONCE(!(tsk->flags & PF_KTHREAD));
        WARN_ON_ONCE(!tsk->mm);
 
-       set_fs(to_kthread(tsk)->oldfs);
+       force_uaccess_end(to_kthread(tsk)->oldfs);
 
        task_lock(tsk);
        sync_mm_rss(mm);
+       local_irq_disable();
        tsk->mm = NULL;
        /* active_mm is still 'mm' */
        enter_lazy_tlb(mm, tsk);
+       local_irq_enable();
        task_unlock(tsk);
 }
 EXPORT_SYMBOL_GPL(kthread_unuse_mm);