Skip to content

Commit 6631e63

Browse files
committed
block: don't flush plugged IO on forced preemtion scheduling
We really only want to unplug the pending IO when the process actually goes to sleep. So move the test for flushing the plug up to the place where we actually deactivate the task - where we have properly checked for preemption and for the process really sleeping. Acked-by: Jens Axboe <jaxboe@fusionio.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a626ca6 commit 6631e63

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

kernel/sched.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -4111,20 +4111,20 @@ asmlinkage void __sched schedule(void)
41114111
try_to_wake_up_local(to_wakeup);
41124112
}
41134113
deactivate_task(rq, prev, DEQUEUE_SLEEP);
4114+
4115+
/*
4116+
* If we are going to sleep and we have plugged IO queued, make
4117+
* sure to submit it to avoid deadlocks.
4118+
*/
4119+
if (blk_needs_flush_plug(prev)) {
4120+
raw_spin_unlock(&rq->lock);
4121+
blk_flush_plug(prev);
4122+
raw_spin_lock(&rq->lock);
4123+
}
41144124
}
41154125
switch_count = &prev->nvcsw;
41164126
}
41174127

4118-
/*
4119-
* If we are going to sleep and we have plugged IO queued, make
4120-
* sure to submit it to avoid deadlocks.
4121-
*/
4122-
if (prev->state != TASK_RUNNING && blk_needs_flush_plug(prev)) {
4123-
raw_spin_unlock(&rq->lock);
4124-
blk_flush_plug(prev);
4125-
raw_spin_lock(&rq->lock);
4126-
}
4127-
41284128
pre_schedule(rq, prev);
41294129

41304130
if (unlikely(!rq->nr_running))

0 commit comments

Comments
 (0)