From 1dc841edc41a3014ece92b72013b3b57b0424e6b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 12 Apr 2004 00:16:32 -0700 Subject: [PATCH] Correct unplugs on nr_queued From: Jens Axboe There's a small discrepancy in when we decide to unplug a queue based on q->unplug_thresh. Basically it doesn't work for tagged queues, since q->rq.count[READ] + q->rq.count[WRITE] is just the number of allocated requests, not the number of requests stuck in the io scheduler. We could just change the nr_queued == to a nr_queued >=, however that is still suboptimal. This patch adds accounting for requests that have been dequeued from the io scheduler, but not freed yet. These are q->in_flight. allocated_requests - q->in_flight == requests_in_scheduler. So the condition correctly becomes if (requests_in_scheduler == q->unplug_thresh) instead. I did a quick round of testing, and for dbench on a SCSI disk the number of timer induced unplugs was reduced from 13 to 5 :-). Not a huge number, but there might be cases where it's more significant. Either way, it gets ->unplug_thresh always right, which the old logic didn't. --- include/linux/blkdev.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/linux') diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 572f96e6940a..44c722d4b67b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -348,6 +348,8 @@ struct request_queue atomic_t refcnt; + unsigned int in_flight; + /* * sg stuff */ @@ -377,6 +379,9 @@ struct request_queue #define blk_fs_request(rq) ((rq)->flags & REQ_CMD) #define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC) #define blk_noretry_request(rq) ((rq)->flags & REQ_FAILFAST) +#define blk_rq_started(rq) ((rq)->flags & REQ_STARTED) + +#define blk_account_rq(rq) (blk_rq_started(rq) && blk_fs_request(rq)) #define blk_pm_suspend_request(rq) ((rq)->flags & REQ_PM_SUSPEND) #define blk_pm_resume_request(rq) ((rq)->flags & REQ_PM_RESUME) -- cgit v1.2.3