sched/core: Add __sched tag for io_schedule()
[linux-2.6-block.git] / kernel / sched / core.c
index 102dfcf0a29a8539106c15c0150878c457953fbd..cd047927f7073da4f6c2d2e2297d26c4050ce99c 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  kernel/sched/core.c
  *
@@ -929,7 +930,7 @@ static inline bool is_per_cpu_kthread(struct task_struct *p)
  */
 static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
 {
-       if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
+       if (!cpumask_test_cpu(cpu, p->cpus_ptr))
                return false;
 
        if (is_per_cpu_kthread(p))
@@ -1024,7 +1025,7 @@ static int migration_cpu_stop(void *data)
        local_irq_disable();
        /*
         * We need to explicitly wake pending tasks before running
-        * __migrate_task() such that we will not miss enforcing cpus_allowed
+        * __migrate_task() such that we will not miss enforcing cpus_ptr
         * during wakeups, see set_cpus_allowed_ptr()'s TASK_WAKING test.
         */
        sched_ttwu_pending();
@@ -1055,7 +1056,7 @@ static int migration_cpu_stop(void *data)
  */
 void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask)
 {
-       cpumask_copy(&p->cpus_allowed, new_mask);
+       cpumask_copy(&p->cpus_mask, new_mask);
        p->nr_cpus_allowed = cpumask_weight(new_mask);
 }
 
@@ -1125,7 +1126,7 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
                goto out;
        }
 
-       if (cpumask_equal(&p->cpus_allowed, new_mask))
+       if (cpumask_equal(p->cpus_ptr, new_mask))
                goto out;
 
        if (!cpumask_intersects(new_mask, cpu_valid_mask)) {
@@ -1285,10 +1286,10 @@ static int migrate_swap_stop(void *data)
        if (task_cpu(arg->src_task) != arg->src_cpu)
                goto unlock;
 
-       if (!cpumask_test_cpu(arg->dst_cpu, &arg->src_task->cpus_allowed))
+       if (!cpumask_test_cpu(arg->dst_cpu, arg->src_task->cpus_ptr))
                goto unlock;
 
-       if (!cpumask_test_cpu(arg->src_cpu, &arg->dst_task->cpus_allowed))
+       if (!cpumask_test_cpu(arg->src_cpu, arg->dst_task->cpus_ptr))
                goto unlock;
 
        __migrate_swap_task(arg->src_task, arg->dst_cpu);
@@ -1330,10 +1331,10 @@ int migrate_swap(struct task_struct *cur, struct task_struct *p,
        if (!cpu_active(arg.src_cpu) || !cpu_active(arg.dst_cpu))
                goto out;
 
-       if (!cpumask_test_cpu(arg.dst_cpu, &arg.src_task->cpus_allowed))
+       if (!cpumask_test_cpu(arg.dst_cpu, arg.src_task->cpus_ptr))
                goto out;
 
-       if (!cpumask_test_cpu(arg.src_cpu, &arg.dst_task->cpus_allowed))
+       if (!cpumask_test_cpu(arg.src_cpu, arg.dst_task->cpus_ptr))
                goto out;
 
        trace_sched_swap_numa(cur, arg.src_cpu, p, arg.dst_cpu);
@@ -1478,7 +1479,7 @@ void kick_process(struct task_struct *p)
 EXPORT_SYMBOL_GPL(kick_process);
 
 /*
- * ->cpus_allowed is protected by both rq->lock and p->pi_lock
+ * ->cpus_ptr is protected by both rq->lock and p->pi_lock
  *
  * A few notes on cpu_active vs cpu_online:
  *
@@ -1518,14 +1519,14 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
                for_each_cpu(dest_cpu, nodemask) {
                        if (!cpu_active(dest_cpu))
                                continue;
-                       if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed))
+                       if (cpumask_test_cpu(dest_cpu, p->cpus_ptr))
                                return dest_cpu;
                }
        }
 
        for (;;) {
                /* Any allowed, online CPU? */
-               for_each_cpu(dest_cpu, &p->cpus_allowed) {
+               for_each_cpu(dest_cpu, p->cpus_ptr) {
                        if (!is_cpu_allowed(p, dest_cpu))
                                continue;
 
@@ -1569,7 +1570,7 @@ out:
 }
 
 /*
- * The caller (fork, wakeup) owns p->pi_lock, ->cpus_allowed is stable.
+ * The caller (fork, wakeup) owns p->pi_lock, ->cpus_ptr is stable.
  */
 static inline
 int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
@@ -1579,11 +1580,11 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
        if (p->nr_cpus_allowed > 1)
                cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags);
        else
-               cpu = cpumask_any(&p->cpus_allowed);
+               cpu = cpumask_any(p->cpus_ptr);
 
        /*
         * In order not to call set_task_cpu() on a blocking task we need
-        * to rely on ttwu() to place the task on a valid ->cpus_allowed
+        * to rely on ttwu() to place the task on a valid ->cpus_ptr
         * CPU.
         *
         * Since this is common to all placement strategies, this lives here.
@@ -2394,7 +2395,7 @@ void wake_up_new_task(struct task_struct *p)
 #ifdef CONFIG_SMP
        /*
         * Fork balancing, do it here and not earlier because:
-        *  - cpus_allowed can change in the fork path
+        *  - cpus_ptr can change in the fork path
         *  - any previously selected CPU might disappear through hotplug
         *
         * Use __set_task_cpu() to avoid calling sched_class::migrate_task_rq,
@@ -3032,7 +3033,6 @@ void scheduler_tick(void)
 
        update_rq_clock(rq);
        curr->sched_class->task_tick(rq, curr, 0);
-       cpu_load_update_active(rq);
        calc_global_load_tick(rq);
        psi_task_tick(rq);
 
@@ -4266,7 +4266,7 @@ change:
                         * the entire root_domain to become SCHED_DEADLINE. We
                         * will also fail if there's no bandwidth available.
                         */
-                       if (!cpumask_subset(span, &p->cpus_allowed) ||
+                       if (!cpumask_subset(span, p->cpus_ptr) ||
                            rq->rd->dl_bw.bw == 0) {
                                task_rq_unlock(rq, p, &rf);
                                return -EPERM;
@@ -4865,7 +4865,7 @@ long sched_getaffinity(pid_t pid, struct cpumask *mask)
                goto out_unlock;
 
        raw_spin_lock_irqsave(&p->pi_lock, flags);
-       cpumask_and(mask, &p->cpus_allowed, cpu_active_mask);
+       cpumask_and(mask, &p->cpus_mask, cpu_active_mask);
        raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
 out_unlock:
@@ -5122,7 +5122,7 @@ long __sched io_schedule_timeout(long timeout)
 }
 EXPORT_SYMBOL(io_schedule_timeout);
 
-void io_schedule(void)
+void __sched io_schedule(void)
 {
        int token;
 
@@ -5442,7 +5442,7 @@ int task_can_attach(struct task_struct *p,
         * 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.
+        * before cpus_mask may be changed.
         */
        if (p->flags & PF_NO_SETAFFINITY) {
                ret = -EINVAL;
@@ -5469,7 +5469,7 @@ int migrate_task_to(struct task_struct *p, int target_cpu)
        if (curr_cpu == target_cpu)
                return 0;
 
-       if (!cpumask_test_cpu(target_cpu, &p->cpus_allowed))
+       if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))
                return -EINVAL;
 
        /* TODO: This is not properly updating schedstats */
@@ -5607,7 +5607,7 @@ static void migrate_tasks(struct rq *dead_rq, struct rq_flags *rf)
                put_prev_task(rq, next);
 
                /*
-                * Rules for changing task_struct::cpus_allowed are holding
+                * Rules for changing task_struct::cpus_mask are holding
                 * both pi_lock and rq->lock, such that holding either
                 * stabilizes the mask.
                 *
@@ -5901,8 +5901,8 @@ DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
 
 void __init sched_init(void)
 {
-       int i, j;
        unsigned long alloc_size = 0, ptr;
+       int i;
 
        wait_bit_init();
 
@@ -6004,10 +6004,6 @@ void __init sched_init(void)
 #ifdef CONFIG_RT_GROUP_SCHED
                init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, NULL);
 #endif
-
-               for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
-                       rq->cpu_load[j] = 0;
-
 #ifdef CONFIG_SMP
                rq->sd = NULL;
                rq->rd = NULL;