From d378ad9c0efff84831ee2b2ef6c1a9424543568d Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Sat, 11 Feb 2012 23:07:34 +0100 Subject: [PATCH 69/84] lsbd: reduce throttling by random non-throttle Reducing throttling improves performance by using effectively more sectors per block. The randomness in throttling avoids generation of some problematic patterns. Signed-off-by: Krzysztof Mazur --- drivers/block/lsbd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/block/lsbd.c b/drivers/block/lsbd.c index 0b823fd..82a5002 100644 --- a/drivers/block/lsbd.c +++ b/drivers/block/lsbd.c @@ -2094,6 +2094,17 @@ static int lsbd_write_lcache(struct lsbd *p, void *bp) return 0; } +static unsigned int rand_seed = 152L; + +/* + * simple random number generator from glibc 2.5 (TYPE_0) + */ +static unsigned int rand(void) +{ + rand_seed = (rand_seed * 1103515245 + 12345) & 0x7fffffff; + return rand_seed; +} + /** * lsbd_request_dequeue - dequeue request * @p: LSBD device @@ -2143,6 +2154,10 @@ static struct lsbd_request *lsbd_request_dequeue(struct lsbd *p, int throttle) if (p->wqueue_qlen[LSBD_QUEUE_HIGH]) can_throttle = 0; + /* add some randomness, use throtting only in 50% cases */ + if (!(rand() & 0x40000000)) + can_throttle = 0; + /* * High priority requests should be never throttled * to minimize write latency. Currently it is also -- 1.8.4.652.g0d6e0ce