Merge tag 'pinctrl-fixes-v3.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[platform/adaptation/renesas_rcar/renesas_kernel.git] / kernel / cpuset.c
index 8f0f45e..64b3f79 100644 (file)
@@ -769,25 +769,26 @@ static void rebuild_sched_domains_locked(void)
        lockdep_assert_held(&cpuset_mutex);
        get_online_cpus();
 
+       /*
+        * We have raced with CPU hotplug. Don't do anything to avoid
+        * passing doms with offlined cpu to partition_sched_domains().
+        * Anyways, hotplug work item will rebuild sched domains.
+        */
+       if (!cpumask_equal(top_cpuset.cpus_allowed, cpu_active_mask))
+               goto out;
+
        /* Generate domain masks and attrs */
        ndoms = generate_sched_domains(&doms, &attr);
 
        /* Have scheduler rebuild the domains */
        partition_sched_domains(ndoms, doms, attr);
-
+out:
        put_online_cpus();
 }
 #else /* !CONFIG_SMP */
 static void rebuild_sched_domains_locked(void)
 {
 }
-
-static int generate_sched_domains(cpumask_var_t **domains,
-                       struct sched_domain_attr **attributes)
-{
-       *domains = NULL;
-       return 1;
-}
 #endif /* CONFIG_SMP */
 
 void rebuild_sched_domains(void)
@@ -1377,16 +1378,16 @@ static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
 
        cgroup_taskset_for_each(task, cgrp, tset) {
                /*
-                * Kthreads bound to specific cpus cannot be moved to a new
-                * cpuset; we cannot change their cpu affinity and
-                * isolating such threads by their set of allowed nodes is
-                * unnecessary.  Thus, cpusets are not applicable for such
-                * threads.  This prevents checking for success of
-                * set_cpus_allowed_ptr() on all attached tasks before
-                * cpus_allowed may be changed.
+                * Kthreads which disallow setaffinity shouldn't be moved
+                * to a new cpuset; we don't want to change their cpu
+                * affinity and isolating such threads by their set of
+                * allowed nodes is unnecessary.  Thus, cpusets are not
+                * applicable for such threads.  This prevents checking for
+                * success of set_cpus_allowed_ptr() on all attached tasks
+                * before cpus_allowed may be changed.
                 */
                ret = -EINVAL;
-               if (task->flags & PF_THREAD_BOUND)
+               if (task->flags & PF_NO_SETAFFINITY)
                        goto out_unlock;
                ret = security_task_setscheduler(task);
                if (ret)
@@ -2192,7 +2193,6 @@ void cpuset_update_active_cpus(bool cpu_online)
        schedule_work(&cpuset_hotplug_work);
 }
 
-#ifdef CONFIG_MEMORY_HOTPLUG
 /*
  * Keep top_cpuset.mems_allowed tracking node_states[N_MEMORY].
  * Call this routine anytime after node_states[N_MEMORY] changes.
@@ -2204,20 +2204,23 @@ static int cpuset_track_online_nodes(struct notifier_block *self,
        schedule_work(&cpuset_hotplug_work);
        return NOTIFY_OK;
 }
-#endif
+
+static struct notifier_block cpuset_track_online_nodes_nb = {
+       .notifier_call = cpuset_track_online_nodes,
+       .priority = 10,         /* ??! */
+};
 
 /**
  * cpuset_init_smp - initialize cpus_allowed
  *
  * Description: Finish top cpuset after cpu, node maps are initialized
- **/
-
+ */
 void __init cpuset_init_smp(void)
 {
        cpumask_copy(top_cpuset.cpus_allowed, cpu_active_mask);
        top_cpuset.mems_allowed = node_states[N_MEMORY];
 
-       hotplug_memory_notifier(cpuset_track_online_nodes, 10);
+       register_hotmemory_notifier(&cpuset_track_online_nodes_nb);
 
        cpuset_propagate_hotplug_wq =
                alloc_ordered_workqueue("cpuset_hotplug", 0);
@@ -2606,7 +2609,7 @@ void __cpuset_memory_pressure_bump(void)
  *    and we take cpuset_mutex, keeping cpuset_attach() from changing it
  *    anyway.
  */
-static int proc_cpuset_show(struct seq_file *m, void *unused_v)
+int proc_cpuset_show(struct seq_file *m, void *unused_v)
 {
        struct pid *pid;
        struct task_struct *tsk;
@@ -2640,19 +2643,6 @@ out_free:
 out:
        return retval;
 }
-
-static int cpuset_open(struct inode *inode, struct file *file)
-{
-       struct pid *pid = PROC_I(inode)->pid;
-       return single_open(file, proc_cpuset_show, pid);
-}
-
-const struct file_operations proc_cpuset_operations = {
-       .open           = cpuset_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
 #endif /* CONFIG_PROC_PID_CPUSET */
 
 /* Display task mems_allowed in /proc/<pid>/status file. */