Skip to content

Commit

Permalink
block: don't flush plugged IO on forced preemtion scheduling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds committed Apr 13, 2011
1 parent a626ca6 commit 6631e63
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -4111,20 +4111,20 @@ asmlinkage void __sched schedule(void)
try_to_wake_up_local(to_wakeup);
}
deactivate_task(rq, prev, DEQUEUE_SLEEP);

/*
* If we are going to sleep and we have plugged IO queued, make
* sure to submit it to avoid deadlocks.
*/
if (blk_needs_flush_plug(prev)) {
raw_spin_unlock(&rq->lock);
blk_flush_plug(prev);
raw_spin_lock(&rq->lock);
}
}
switch_count = &prev->nvcsw;
}

/*
* If we are going to sleep and we have plugged IO queued, make
* sure to submit it to avoid deadlocks.
*/
if (prev->state != TASK_RUNNING && blk_needs_flush_plug(prev)) {
raw_spin_unlock(&rq->lock);
blk_flush_plug(prev);
raw_spin_lock(&rq->lock);
}

pre_schedule(rq, prev);

if (unlikely(!rq->nr_running))
Expand Down

0 comments on commit 6631e63

Please sign in to comment.