diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 57a2a3119266..141479ce13e5 100755 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1798,7 +1798,12 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags, #ifdef CONFIG_SMP if (wake_flags & WF_MIGRATED) en_flags |= ENQUEUE_MIGRATED; + else #endif + if (p->in_iowait) { + delayacct_blkio_end(p); + atomic_dec(&task_rq(p)->nr_iowait); + } ttwu_activate(rq, p, en_flags); ttwu_do_wakeup(rq, p, wake_flags, rf); @@ -2215,11 +2220,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags, if (READ_ONCE(p->on_rq) && ttwu_remote(p, wake_flags)) goto unlock; - if (p->in_iowait) { - delayacct_blkio_end(p); - atomic_dec(&task_rq(p)->nr_iowait); - } - #ifdef CONFIG_SMP /* * Ensure we load p->on_cpu _after_ p->on_rq, otherwise it would be @@ -2291,6 +2291,11 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags, cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags, sibling_count_hint); if (task_cpu(p) != cpu) { + if (p->in_iowait) { + delayacct_blkio_end(p); + atomic_dec(&task_rq(p)->nr_iowait); + } + wake_flags |= WF_MIGRATED; psi_ttwu_dequeue(p); set_task_cpu(p, cpu);