Skip to content

Commit

Permalink
block: only force kblockd unplugging from the schedule() path
Browse files Browse the repository at this point in the history
For the explicit unplugging, we'd prefer to kick things off
immediately and not pay the penalty of the latency to switch
to kblockd. So let blk_finish_plug() do the run inline, while
the implicit-on-schedule-out unplug will punt to kblockd.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
  • Loading branch information
Jens Axboe committed Apr 15, 2011
1 parent 88b996c commit f660378
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2662,16 +2662,17 @@ static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
return !(rqa->q <= rqb->q);
}

static void queue_unplugged(struct request_queue *q, unsigned int depth)
static void queue_unplugged(struct request_queue *q, unsigned int depth,
bool force_kblockd)
{
trace_block_unplug_io(q, depth);
__blk_run_queue(q, true);
__blk_run_queue(q, force_kblockd);

if (q->unplugged_fn)
q->unplugged_fn(q);
}

void blk_flush_plug_list(struct blk_plug *plug)
void blk_flush_plug_list(struct blk_plug *plug, bool force_kblockd)
{
struct request_queue *q;
unsigned long flags;
Expand Down Expand Up @@ -2706,7 +2707,7 @@ void blk_flush_plug_list(struct blk_plug *plug)
BUG_ON(!rq->q);
if (rq->q != q) {
if (q) {
queue_unplugged(q, depth);
queue_unplugged(q, depth, force_kblockd);
spin_unlock(q->queue_lock);
}
q = rq->q;
Expand All @@ -2727,7 +2728,7 @@ void blk_flush_plug_list(struct blk_plug *plug)
}

if (q) {
queue_unplugged(q, depth);
queue_unplugged(q, depth, force_kblockd);
spin_unlock(q->queue_lock);
}

Expand All @@ -2737,7 +2738,7 @@ EXPORT_SYMBOL(blk_flush_plug_list);

void blk_finish_plug(struct blk_plug *plug)
{
blk_flush_plug_list(plug);
blk_flush_plug_list(plug, false);

if (plug == current->plug)
current->plug = NULL;
Expand Down
4 changes: 2 additions & 2 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,14 @@ struct blk_plug {

extern void blk_start_plug(struct blk_plug *);
extern void blk_finish_plug(struct blk_plug *);
extern void blk_flush_plug_list(struct blk_plug *);
extern void blk_flush_plug_list(struct blk_plug *, bool);

static inline void blk_flush_plug(struct task_struct *tsk)
{
struct blk_plug *plug = tsk->plug;

if (plug)
blk_flush_plug_list(plug);
blk_flush_plug_list(plug, true);
}

static inline bool blk_needs_flush_plug(struct task_struct *tsk)
Expand Down

0 comments on commit f660378

Please sign in to comment.