Skip to content

Commit 55c022b

Browse files
Shaohua LiJens Axboe
authored andcommitted
block: avoid building too big plug list
When I test fio script with big I/O depth, I found the total throughput drops compared to some relative small I/O depth. The reason is the thread accumulates big requests in its plug list and causes some delays (surely this depends on CPU speed). I thought we'd better have a threshold for requests. When a threshold reaches, this means there is no request merge and queue lock contention isn't severe when pushing per-task requests to queue, so the main advantages of blk plug don't exist. We can force a plug list flush in this case. With this, my test throughput actually increases and almost equals to small I/O depth. Another side effect is irq off time decreases in blk_flush_plug_list() for big I/O depth. The BLK_MAX_REQUEST_COUNT is choosen arbitarily, but 16 is efficiently to reduce lock contention to me. But I'm open here, 32 is ok in my test too. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 719c0c5 commit 55c022b

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎block/blk-core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,10 @@ static int __make_request(struct request_queue *q, struct bio *bio)
13021302
plug->should_sort = 1;
13031303
}
13041304
list_add_tail(&req->queuelist, &plug->list);
1305+
plug->count++;
13051306
drive_stat_acct(req, 1);
1307+
if (plug->count >= BLK_MAX_REQUEST_COUNT)
1308+
blk_flush_plug_list(plug, false);
13061309
} else {
13071310
spin_lock_irq(q->queue_lock);
13081311
add_acct_request(q, req, where);
@@ -2626,6 +2629,7 @@ void blk_start_plug(struct blk_plug *plug)
26262629
INIT_LIST_HEAD(&plug->list);
26272630
INIT_LIST_HEAD(&plug->cb_list);
26282631
plug->should_sort = 0;
2632+
plug->count = 0;
26292633

26302634
/*
26312635
* If this is a nested plug, don't actually assign it. It will be
@@ -2709,6 +2713,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
27092713
return;
27102714

27112715
list_splice_init(&plug->list, &list);
2716+
plug->count = 0;
27122717

27132718
if (plug->should_sort) {
27142719
list_sort(NULL, &list, plug_rq_cmp);

‎include/linux/blkdev.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,10 @@ struct blk_plug {
862862
struct list_head list;
863863
struct list_head cb_list;
864864
unsigned int should_sort;
865+
unsigned int count;
865866
};
867+
#define BLK_MAX_REQUEST_COUNT 16
868+
866869
struct blk_plug_cb {
867870
struct list_head list;
868871
void (*callback)(struct blk_plug_cb *);

0 commit comments

Comments
 (0)