Cache queue_congestion_on/off_threshold
It's kind of redundant that queue_congestion_on/off_threshold gets calculated on every I/O and they produce the same number over and over again unless q->nr_requests gets changed (which is probably a very rare event). Can we cache those values in the request_queue structure?
- Ken
drivers/block/ll_rw_blk.c +16 -13
@@ -70,14 +70,7 @@ EXPORT_SYMBOL(blk_max_pfn);*/ static inline int queue_congestion_on_threshold (struct request_queue *q) { -int ret; - - ret = q->nr_requests - (q->nr_requests /8 ) +1 ; - -if (ret > q->nr_requests) - ret = q->nr_requests; - -return ret; +return q->nr_congestion_on; }/*
@@ -85,14 +78,22 @@ static inline int queue_congestion_on_th*/ static inline int queue_congestion_off_threshold (struct request_queue *q) { -int ret; +return q->nr_congestion_off; +} - ret = q->nr_requests - (q->nr_requests /8 ) -1 ; +static inline void blk_queue_congestion_threshold (struct request_queue *q) +{ +int nr; -if (ret <1 ) - ret =1 ; + nr = q->nr_requests - (q->nr_requests /8 ) +1 ; +if (nr > q->nr_requests) + nr = q->nr_requests; + q->nr_congestion_on = nr; -return ret; + nr = q->nr_requests - (q->nr_requests /8 ) -1 ; +if (nr <1 ) + nr =1 ; + q->nr_congestion_off = nr; }void clear_backing_dev_congested (struct backing_dev_info *bdi,int rw)
@@ -235,6 +236,7 @@ void blk_queue_make_request(request_queublk_queue_max_sectors (q,MAX_SECTORS );blk_queue_hardsect_size (q,512 );blk_queue_dma_alignment (q,511 ); +blk_queue_congestion_threshold (q); q->unplug_thresh =4 ;/* hmm */ q->unplug_delay = (3 *HZ ) /1000 ;/* 3 milliseconds */
@@ -2953,6 +2955,7 @@ queue_requests_store(struct request_queuint ret =queue_var_store (&q->nr_requests, page, count);if (q->nr_requests <BLKDEV_MIN_RQ ) q->nr_requests =BLKDEV_MIN_RQ ; +blk_queue_congestion_threshold (q);if (rl->count[READ ] >=queue_congestion_on_threshold (q))set_queue_congested (q,READ );
include/linux/blkdev.h +2 -0
@@ -334,6 +334,8 @@ struct request_queue* queue settings */ unsigned long nr_requests;/* Max # of requests */ +unsigned int nr_congestion_on; +unsigned int nr_congestion_off;unsigned short max_sectors;unsigned short max_phys_segments;
Quoted 76 lines · Kenneth W
It's kind of redundant that queue_congestion_on/off_threshold gets calculated on every I/O and they produce the same number over and over again unless
q->nr_requestsgets changed (which is probably a very rare event). Can we cache those values in therequest_queuestructure?- Ken
diff -Nurp
linux-2.6.6-rc3/drivers/block/ll_rw_blk.clinux-2.6.6-rc3.blk/drivers/block/ll_rw_blk.cdrivers/block/ll_rw_blk.c +16
-13@@ -70,14 +70,7 @@ EXPORT_SYMBOL(blk_max_pfn);*/ static inline int queue_congestion_on_threshold (struct request_queue *q) { -int ret; - - ret = q->nr_requests - (q->nr_requests /8 ) +1 ; - -if (ret > q->nr_requests) - ret = q->nr_requests; - -return ret; +return q->nr_congestion_on; }/* @@ -85,14 +78,22 @@ static inline int queue_congestion_on_th*/ static inline int queue_congestion_off_threshold (struct request_queue *q) { -int ret; +return q->nr_congestion_off; +} - ret = q->nr_requests - (q->nr_requests /8 ) -1 ; +static inline void blk_queue_congestion_threshold (struct request_queue *q) +{ +int nr; -if (ret <1 ) - ret =1 ; + nr = q->nr_requests - (q->nr_requests /8 ) +1 ; +if (nr > q->nr_requests) + nr = q->nr_requests; + q->nr_congestion_on = nr; -return ret; + nr = q->nr_requests - (q->nr_requests /8 ) -1 ; +if (nr <1 ) + nr =1 ; + q->nr_congestion_off = nr; }void clear_backing_dev_congested (struct backing_dev_info *bdi,int rw)@@ -235,6 +236,7 @@ void blk_queue_make_request(request_queublk_queue_max_sectors (q,MAX_SECTORS );blk_queue_hardsect_size (q,512 );blk_queue_dma_alignment (q,511 ); +blk_queue_congestion_threshold (q); q->unplug_thresh =4 ;/* hmm */ q->unplug_delay = (3 *HZ ) /1000 ;/* 3 milliseconds */ @@ -2953,6 +2955,7 @@ queue_requests_store(struct request_queuint ret =queue_var_store (&q->nr_requests, page, count);if (q->nr_requests <BLKDEV_MIN_RQ ) q->nr_requests =BLKDEV_MIN_RQ ; +blk_queue_congestion_threshold (q);if (rl->count[READ ] >=queue_congestion_on_threshold (q))set_queue_congested (q,READ );diff -Nurp
linux-2.6.6-rc3/include/linux/blkdev.hlinux-2.6.6-rc3.blk/include/linux/blkdev.h
include/linux/blkdev.h struct request_queue · line 341
Quoted 8 lines
include/linux/blkdev.h +2
-0@@ -334,6 +334,8 @@ struct request_queue* queue settings */ unsigned long nr_requests;/* Max # of requests */ +unsigned int nr_congestion_on; +unsigned int nr_congestion_off;unsigned short max_sectors;unsigned short max_phys_segments;
Do you have any numbers at all for this? I'd say these calculations are severly into the noise area when submitting io.
Signature · 1 line
Jens Axboe
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.
The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
I uninlined the new function though. Two callsites, both slowpath...
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
Humm dunno, I'd rather save the sizeof(int) * 2.
Quoted 1 line
I uninlined the new function though. Two callsites, both slowpath...
The more reason not to make it static :). I don't feel too strongly about it though.
Signature · 1 line
Jens Axboe
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Jens Axboe wrote on Wed, May 05, 2004 11:43 PM
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
Humm dunno, I'd rather save the sizeof(int) * 2.
Strictly speaking from memory consumption point of view, it probably comes for free since sizeof(struct request_queue) currently is 456 bytes on x86 and 816 on 64bit arch. The structure is being rounded to 512 or 1024 with kmalloc. If it is on the borderline to next kmalloc size, it probably should be revisited. But so far it has been noise on the positive side.
- Ken
Quoted 11 lines · Kenneth W
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Jens Axboe wrote on Wed, May 05, 2004 11:43 PM
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
Quoted 6 lines
Quoted 1 line
Humm dunno, I'd rather save the sizeof(int) * 2.
Strictly speaking from memory consumption point of view, it probably comes for free since
sizeof(struct request_queue)currently is 456 bytes on x86 and 816 on 64bit arch. The structure is being rounded to 512 or 1024 with kmalloc.
That's a good argument for creating a standalone slab cache for request queue structures ;)
Quoted 14 lines · Andrew Morton
Quoted 13 lines · Kenneth W
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Jens Axboe wrote on Wed, May 05, 2004 11:43 PM
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
Humm dunno, I'd rather save the sizeof(int) * 2.
Quoted 7 lines
Quoted 4 lines
Strictly speaking from memory consumption point of view, it probably comes for free since
sizeof(struct request_queue)currently is 456 bytes on x86 and 816 on 64bit arch. The structure is being rounded to 512 or 1024 with kmalloc.That's a good argument for creating a standalone slab cache for request queue structures ;)
Precisely, it's definitely not a good argument to keep loading it. I'll do that.
Signature · 1 line
Jens Axboe
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Andrew Morton wrote on Wednesday, May 05, 2004 11:34 PM
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
Even though it is in the noise range that can't be easily measured, they are indeed in the positive territory. If I stack 5 of these little things, we actually measured positive gain on a large db workload.
There isn't anything absurd in 2.6 kernel, however, I hate to say that we consistently see performance regression with latest 2.6 kernel compare to best 2.4 based kernel under heavy db workload on 4-way SMP platform. (2.6 rocks on numa platform that 2.4 doesn't even have a chance to compete).
Some of the examples are:
(1) it's cheaper to find out whether a queue is empty or not by calling elv_queue_empty() instead of using heavier elv_next_request().
(2) it's better to check queue empty before calling into q->request_fn()
drivers/block/ll_rw_blk.c +3 -2
@@ -1128,7 +1128,7 @@ static inline void __generic_unplug_devi/* * was plugged, fire request_fn if queue has stuff to do */ -if (elv_next_request (q)) +if (!elv_queue_empty (q)) q->request_fn (q); }
@@ -1237,7 +1237,8 @@ void blk_run_queue(struct request_queuespin_lock_irqsave (q->queue_lock, flags);blk_remove_plug (q); - q->request_fn (q); +if (!elv_queue_empty (q)) + q->request_fn (q);spin_unlock_irqrestore (q->queue_lock, flags); }
(3) can we allocate request structure up front in __make_request? For I/O that cannot be merged, the elevator code executes twice in __make_request.
drivers/block/ll_rw_blk.c +4 -5
@@ -2154,15 +2154,14 @@ static int __make_request(request_queue_ ra = bio->bi_rw & (1 <<BIO_RW_AHEAD ); +/* Grab a free request from the freelist */ + freereq =get_request (q, rw,GFP_ATOMIC ); + again:spin_lock_irq (q->queue_lock); -if (elv_queue_empty (q)) { +if (elv_queue_empty (q))blk_plug_device (q); - goto get_rq; - } -if (barrier) - goto get_rq; el_ret =elv_merge (q, &req, bio);switch (el_ret) {
Some more, I will post in another thread.
- Ken
Quoted 6 lines · Kenneth W
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Andrew Morton wrote on Wednesday, May 05, 2004 11:34 PM
Quoted 3 lines · Jens Axboe
Do you have any numbers at all for this? I'd say these calculations are
severly into the noise area when submitting io.
Quoted 6 lines
Quoted 2 lines
The difference will not be measurable, but I think the patch makes sense regardless of what the numbers say.
Even though it is in the noise range that can't be easily measured, they are indeed in the positive territory. If I stack 5 of these little things, we actually measured positive gain on a large db workload.
I somehow still find that very hard to believe, it's a branch and a couple of cycles.
Quoted 25 lines
There isn't anything absurd in 2.6 kernel, however, I hate to say that we consistently see performance regression with latest 2.6 kernel compare to best 2.4 based kernel under heavy db workload on 4-way SMP platform. (2.6 rocks on numa platform that 2.4 doesn't even have a chance to compete).
Some of the examples are:
(1) it's cheaper to find out whether a queue is empty or not by calling
elv_queue_empty()instead of using heavierelv_next_request().
(2) it's better to check queue empty before calling intoq->request_fn()diff -Nurp
linux-2.6.6-rc3/drivers/block/ll_rw_blk.clinux-2.6.6-rc3.ken/drivers/block/ll_rw_blk.cdrivers/block/ll_rw_blk.c +1
-1@@ -1128,7 +1128,7 @@ static inline void __generic_unplug_devi/* * was plugged, fire request_fn if queue has stuff to do */ -if (elv_next_request (q)) +if (!elv_queue_empty (q)) q->request_fn (q); }
drivers/block/ll_rw_blk.c void blk_run_queue(struct request_queue · line 1243
Quoted 8 lines
drivers/block/ll_rw_blk.c +2
-1@@ -1237,7 +1237,8 @@ void blk_run_queue(struct request_queuespin_lock_irqsave (q->queue_lock, flags);blk_remove_plug (q); - q->request_fn (q); +if (!elv_queue_empty (q)) + q->request_fn (q);spin_unlock_irqrestore (q->queue_lock, flags); }
This looks great, should be merged right away.
Quoted 18 lines
(3) can we allocate request structure up front in
__make_request? For I/O that cannot be merged, the elevator code executes twice in__make_request.diff -Nurp
linux-2.6.6-rc3/drivers/block/ll_rw_blk.clinux-2.6.6-rc3.ken/drivers/block/ll_rw_blk.cdrivers/block/ll_rw_blk.c +3
-0@@ -2154,15 +2154,14 @@ static int __make_request(request_queue_ ra = bio->bi_rw & (1 <<BIO_RW_AHEAD ); +/* Grab a free request from the freelist */ + freereq =get_request (q, rw,GFP_ATOMIC ); + again:spin_lock_irq (q->queue_lock);
drivers/block/ll_rw_blk.c static int __make_request(request_queue_ · line 2167
Quoted 10 lines
drivers/block/ll_rw_blk.c +1
-5-if (elv_queue_empty (q)) { +if (elv_queue_empty (q))blk_plug_device (q); - goto get_rq; - } -if (barrier) - goto get_rq; el_ret =elv_merge (q, &req, bio);switch (el_ret) {
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Quoted 1 line
Some more, I will post in another thread.
Can you please remember to cc in initial posts as well, I don't want to always hunt for your findings. Thanks.
Signature · 1 line
Jens Axboe
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Jens Axboe wrote on Friday, May 07, 2004 2:39 AM
Quoted 4 lines · Kenneth W
(3) can we allocate request structure up front in
__make_request? For I/O that cannot be merged, the elevator code executes twice in__make_request.Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
- Ken
Quoted 7 lines · Kenneth W
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Jens Axboe wrote on Friday, May 07, 2004 2:39 AM
Quoted 4 lines · Kenneth W
(3) can we allocate request structure up front in
__make_request? For I/O that cannot be merged, the elevator code executes twice in__make_request.
Quoted 5 lines
Quoted 2 lines
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Something like this.
drivers/block/ll_rw_blk.c renamed from drivers/block/ll_rw_blk.c~ +15 -20
@@ -2138,8 +2138,8 @@static int __make_request (request_queue_t *q,struct bio *bio) { -struct request *req, *freereq =NULL ;int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, ra; +struct request *req;sector_t sector; sector = bio->bi_sector;
@@ -2161,15 +2161,15 @@ ra = bio->bi_rw & (1 <<BIO_RW_AHEAD ); -again: +if (barrier) + goto get_rq_nolock; +spin_lock_irq (q->queue_lock);if (elv_queue_empty (q)) {blk_plug_device (q); goto get_rq; } -if (barrier) - goto get_rq; el_ret =elv_merge (q, &req, bio);switch (el_ret) {
@@ -2230,21 +2230,17 @@* a free slot. */ get_rq: -if (freereq) { - req = freereq; - freereq =NULL ; - }else { -spin_unlock_irq (q->queue_lock); -if ((freereq =get_request (q, rw,GFP_ATOMIC )) ==NULL ) { -/* -* READA bit set -*/ -if (ra) - goto end_io; +spin_unlock_irq (q->queue_lock); +get_rq_nolock: + req =get_request (q, rw,GFP_ATOMIC ); +if (!req) { +/* +* READA bit set +*/ +if (ra) + goto end_io; - freereq =get_request_wait (q, rw); - } - goto again; + req =get_request_wait (q, rw); } req->flags |=REQ_CMD ;
@@ -2276,10 +2272,9 @@ req->rq_disk = bio->bi_bdev->bd_disk; req->start_time = jiffies; +spin_lock_irq (q->queue_lock);add_request (q, req); out: -if (freereq) -__blk_put_request (q, freereq);if (blk_queue_plugged (q)) {int nrq = q->rq.count[READ ] + q->rq.count[WRITE ] - q->in_flight;
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 9 lines · Kenneth W
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Jens Axboe wrote on Friday, May 07, 2004 2:39 AM
Quoted 4 lines · Kenneth W
(3) can we allocate request structure up front in
__make_request? For I/O that cannot be merged, the elevator code executes twice in__make_request.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Something like this.
While we're doing that can we drop the GFP_ATOMIC allocation completely?
Quoted 19 lines · Nick Piggin
Quoted 18 lines · Jens Axboe
Quoted 14 lines · Kenneth W
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Jens Axboe wrote on Friday, May 07, 2004 2:39 AM
Quoted 4 lines · Kenneth W
(3) can we allocate request structure up front in
__make_request? For I/O that cannot be merged, the elevator code executes twice in__make_request.Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Quoted 5 lines
Quoted 2 lines
Something like this.
While we're doing that can we drop the
GFP_ATOMICallocation completely?
Thought the same thing. But lets stick to single item tests first, then we can kill that double allocation after.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 3 lines · Nick Piggin
While we're doing that can we drop the
GFP_ATOMICallocation completely?Thought the same thing. But lets stick to single item tests first, then we can kill that double allocation after.
That sounds like the best idea :)
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Jens Axboe wrote on Monday, May 10, 2004 7:30 AM
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Something like this.
drivers/block/ll_rw_blk.c renamed from drivers/block/ll_rw_blk.c~ +1
-1@@ -2138,8 +2138,8 @@static int __make_request (request_queue_t *q,struct bio *bio) { -struct request *req, *freereq =NULL ;int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, ra; +struct request *req;sector_t sector;
Quoted 1 line
[snip] ...
I'm still working on this. With this patch, several processes stuck in "D" state and never finish. Suspect it's the barrier thing, it jumps through blk_plug_device() and might goof up the queue afterwards.
- Ken
Quoted 22 lines · Kenneth W
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Jens Axboe wrote on Monday, May 10, 2004 7:30 AM
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Something like this.
drivers/block/ll_rw_blk.c renamed from drivers/block/ll_rw_blk.c~ +1
-1@@ -2138,8 +2138,8 @@static int __make_request (request_queue_t *q,struct bio *bio) { -struct request *req, *freereq =NULL ;int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, ra; +struct request *req;sector_t sector;
Quoted 5 lines
Quoted 1 line
[snip] ...
I'm still working on this. With this patch, several processes stuck in "D" state and never finish. Suspect it's the barrier thing, it jumps through
blk_plug_device()and might goof up the queue afterwards.
I'll do a quick test run (and review) of the patch, it wasn't even compiled here. So the chance of a slip-up is non-zero.
Signature · 1 line
Jens Axboe
Quoted 23 lines · Jens Axboe
Quoted 22 lines · Kenneth W
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Jens Axboe wrote on Monday, May 10, 2004 7:30 AM
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Something like this.
drivers/block/ll_rw_blk.c renamed from drivers/block/ll_rw_blk.c~ +1
-1@@ -2138,8 +2138,8 @@static int __make_request (request_queue_t *q,struct bio *bio) { -struct request *req, *freereq =NULL ;int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, ra; +struct request *req;sector_t sector;
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
[snip] ...
I'm still working on this. With this patch, several processes stuck in "D" state and never finish. Suspect it's the barrier thing, it jumps through
blk_plug_device()and might goof up the queue afterwards.I'll do a quick test run (and review) of the patch, it wasn't even compiled here. So the chance of a slip-up is non-zero.
This at least boots here, does it work correctly for you?
linux/bio.h renamed from linux/bio.h~ +1 -0
@@ -126,6 +126,7 @@#define BIO_RW_BARRIER 2#define BIO_RW_FAILFAST 3#define BIO_RW_SYNC 4 +#define bio_rw_flagged (bio, flag) ((bio)->bi_rw & (1 << (flag)))/* * various member access, note that bio_data should of course not be used
block/ll_rw_blk.c renamed from block/ll_rw_blk.c~ +17 -23
@@ -1614,7 +1615,6 @@DEFINE_WAIT (wait);struct request *rq; -generic_unplug_device (q); do { struct request_list *rl = &q->rq;
@@ -1626,6 +1626,7 @@if (!rq) {struct io_context *ioc; +generic_unplug_device (q);io_schedule ();/*
@@ -2133,8 +2134,8 @@static int __make_request (request_queue_t *q,struct bio *bio) { -struct request *req, *freereq =NULL ;int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, ra; +struct request *req =NULL ;sector_t sector; sector = bio->bi_sector;
@@ -2152,17 +2153,17 @@spin_lock_prefetch (q->queue_lock); - barrier =test_bit (BIO_RW_BARRIER , &bio->bi_rw); - - ra = bio->bi_rw & (1 <<BIO_RW_AHEAD ); +mb (); + barrier =bio_rw_flagged (bio,BIO_RW_BARRIER ); + ra =bio_rw_flagged (bio,BIO_RW_AHEAD ); -again:spin_lock_irq (q->queue_lock);if (elv_queue_empty (q)) {blk_plug_device (q); goto get_rq; } +if (barrier) goto get_rq;
@@ -2225,21 +2226,16 @@* a free slot. */ get_rq: -if (freereq) { - req = freereq; - freereq =NULL ; - }else { -spin_unlock_irq (q->queue_lock); -if ((freereq =get_request (q, rw,GFP_ATOMIC )) ==NULL ) { -/* -* READA bit set -*/ -if (ra) - goto end_io; +spin_unlock_irq (q->queue_lock); + req =get_request (q, rw,GFP_ATOMIC ); +if (!req) { +/* +* READA bit set +*/ +if (ra) + goto end_io; - freereq =get_request_wait (q, rw); - } - goto again; + req =get_request_wait (q, rw); } req->flags |=REQ_CMD ;
@@ -2248,7 +2244,7 @@* inherit FAILFAST from bio and don't stack up * retries for read ahead */ -if (ra ||test_bit (BIO_RW_FAILFAST , &bio->bi_rw)) +if (ra ||bio_rw_flagged (bio,BIO_RW_FAILFAST )) req->flags |=REQ_FAILFAST ;/*
@@ -2271,10 +2267,9 @@ req->rq_disk = bio->bi_bdev->bd_disk; req->start_time = jiffies; +spin_lock_irq (q->queue_lock);add_request (q, req); out: -if (freereq) -__blk_put_request (q, freereq);if (blk_queue_plugged (q)) {int nrq = q->rq.count[READ ] + q->rq.count[WRITE ] - q->in_flight;
Signature · 1 line
Jens Axboe
Quoted 22 lines · Kenneth W
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Jens Axboe wrote on Monday, May 10, 2004 7:30 AM
Actually, with the good working batching we might get away with killing freereq completely. Have you tested that (if not, could you?)
Sorry, I'm clueless on "good working batching". If you could please give me some pointers, I will definitely test it.
Something like this.
drivers/block/ll_rw_blk.c renamed from drivers/block/ll_rw_blk.c~ +1
-1@@ -2138,8 +2138,8 @@static int __make_request (request_queue_t *q,struct bio *bio) { -struct request *req, *freereq =NULL ;int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, ra; +struct request *req;sector_t sector;
Quoted 5 lines
Quoted 1 line
[snip] ...
I'm still working on this. With this patch, several processes stuck in "D" state and never finish. Suspect it's the barrier thing, it jumps through
blk_plug_device()and might goof up the queue afterwards.
BTW, the barrier bit was buggy, but it could not make a difference since the stock kernels + -mm doesn't use barriers. So you are right it's wrong, but no impact on this test.
Signature · 1 line
Jens Axboe