Commit 082cf69e authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] ll_rw_blk: prevent huge request allocations

Currently we cap request allocations at q->nr_requests, but we allow a
batching io context to allocate up to 32 more (default setting).  This
can flood the queue with request allocations, with only a few batching
processes.  The real fix would be to limit the number of batchers, but
as that isn't currently tracked, I suggest we just cap the maximum
number of allocated requests to eg 50% over the limit.

This was observed in real life, users typically see this as vmstat bo
numbers going off the wall with seconds of no queueing afterwards.
Behaviour this bursty is not beneficial.
Signed-off-by: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f8b58edf
...@@ -1912,6 +1912,15 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, ...@@ -1912,6 +1912,15 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio,
} }
get_rq: get_rq:
/*
* Only allow batching queuers to allocate up to 50% over the defined
* limit of requests, otherwise we could have thousands of requests
* allocated with any setting of ->nr_requests
*/
if (rl->count[rw] >= (3 * q->nr_requests / 2)) {
spin_unlock_irq(q->queue_lock);
goto out;
}
rl->count[rw]++; rl->count[rw]++;
rl->starved[rw] = 0; rl->starved[rw] = 0;
if (rl->count[rw] >= queue_congestion_on_threshold(q)) if (rl->count[rw] >= queue_congestion_on_threshold(q))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment