cfq-iosched: fix a kbuild regression
RFC 1/1 cfq-iosched: fix a kbuild regression
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit: 3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason is cfqq_close() can't find close cooperator. If we store the seek distance to the value before the commit like below, the regression fully goes away. If this is too invasive, just changing the cfq_rq_close() for the !for_preempt is ok too.
block/cfq-iosched.c +1 -1
@@ -46,7 +46,7 @@ static const int cfq_hist_divisor = 4;#define CFQ_HW_QUEUE_MIN (5)#define CFQ_SERVICE_SHIFT 12 -#define CFQQ_SEEK_THR (sector_t)(8 * 100) +#define CFQQ_SEEK_THR (sector_t)(8 * 1024)#define CFQQ_SECT_THR_NONROT (sector_t)(2 * 32)#define CFQQ_SEEKY (cfqq) (hweight32(cfqq->seek_history) > 32/8)
Quoted 6 lines · Shaohua Li
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. If we store the seek distance to the value before the commit like below, the regression fully goes away. If this is too invasive, just changing thecfq_rq_close()for the !for_preempt is ok too.
Corrado, any objections to widening the seek threshold?
Quoted 17 lines
Reported-by Alex Shi <[email protected]>Signed-off-by Shaohua Li <[email protected]>block/cfq-iosched.c +1
-1@@ -46,7 +46,7 @@ static const int cfq_hist_divisor = 4;#define CFQ_HW_QUEUE_MIN (5)#define CFQ_SERVICE_SHIFT 12 -#define CFQQ_SEEK_THR (sector_t)(8 * 100) +#define CFQQ_SEEK_THR (sector_t)(8 * 1024)#define CFQQ_SECT_THR_NONROT (sector_t)(2 * 32)#define CFQQ_SEEKY (cfqq) (hweight32(cfqq->seek_history) > 32/8)
Signature · 1 line
Jens Axboe
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Shaohua Li
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. If we store the seek distance to the value before the commit like below, the regression fully goes away. If this is too invasive, just changing thecfq_rq_close()for the !for_preempt is ok too.Corrado, any objections to widening the seek threshold?
The previous seek threshold value was meant to be compared with the average seek distance, so it was large to account for variations. Since we handle the variations differently, we should have a smaller value now (the 100 * 8 was the result of a benchmark run on several disks).
I agreee, though, that for merging queues, it is now too small, so we should have two thresholds, the current one used to determine if a request causes a seek, and an other to be used inside cfq_close (with the older value, regardless of for_preempt).
Corrado
Quoted 23 lines
Quoted 10 lines
Reported-by Alex Shi <[email protected]>Signed-off-by Shaohua Li <[email protected]>block/cfq-iosched.c +0
-0block/cfq-iosched.c static const int cfq_hist_divisor = 4; · line 52
Quoted 8 lines
block/cfq-iosched.c +1
-1@@ -46,7 +46,7 @@ static const int cfq_hist_divisor = 4; #define CFQ_HW_QUEUE_MIN (5) #define CFQ_SERVICE_SHIFT 12 -#define CFQQ_SEEK_THR (sector_t)(8 * 100) +#define CFQQ_SEEK_THR (sector_t)(8 * 1024) #define CFQQ_SECT_THR_NONROT (sector_t)(2 * 32) #define CFQQ_SEEKY(cfqq) (hweight32(cfqq->seek_history) > 32/8)--
Jens Axboe
Signature · 10 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy -------------------------------------------------------------------------- The self-confidence of a warrior is not the self-confidence of the average man. The average man seeks certainty in the eyes of the onlooker and calls that self-confidence. The warrior seeks impeccability in his own eyes and calls that humbleness. Tales of Power - C. Castaneda
Quoted 9 lines · Corrado Zoccolo
Quoted 8 lines · Jens Axboe
Quoted 6 lines · Shaohua Li
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. If we store the seek distance to the value before the commit like below, the regression fully goes away. If this is too invasive, just changing thecfq_rq_close()for the !for_preempt is ok too.
Quoted 7 lines
Quoted 1 line
Corrado, any objections to widening the seek threshold?
The previous seek threshold value was meant to be compared with the average seek distance, so it was large to account for variations. Since we handle the variations differently, we should have a smaller value now (the 100 * 8 was the result of a benchmark run on several disks).
Our test doesn't find any issue with the seek threshold so far, so it proberly is ok.
Quoted 4 lines
I agreee, though, that for merging queues, it is now too small, so we should have two thresholds, the current one used to determine if a request causes a seek, and an other to be used inside
cfq_close(with the older value, regardless offor_preempt).
That makes sense. Updated patch.
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit: 3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason is cfqq_close() can't find close cooperator. Restoring cfq_rq_close()'s threshold to original value makes the regression go away.
Since for_preempt parameter isn't used anymore, this patch deletes it.
block/cfq-iosched.c +6 -5
@@ -47,6 +47,7 @@ static const int cfq_hist_divisor = 4;#define CFQ_SERVICE_SHIFT 12#define CFQQ_SEEK_THR (sector_t)(8 * 100) +#define CFQQ_CLOSE_THR (sector_t)(8 * 1024)#define CFQQ_SECT_THR_NONROT (sector_t)(2 * 32)#define CFQQ_SEEKY (cfqq) (hweight32(cfqq->seek_history) > 32/8)
@@ -1660,9 +1661,9 @@ static inline sector_t cfq_dist_from_last(struct cfq_data *cfqd, }static inline int cfq_rq_close (struct cfq_data *cfqd,struct cfq_queue *cfqq, -struct request *rq,bool for_preempt) +struct request *rq) { -return cfq_dist_from_last (cfqd, rq) <=CFQQ_SEEK_THR ; +return cfq_dist_from_last (cfqd, rq) <=CFQQ_CLOSE_THR ; } static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,
@@ -1689,7 +1690,7 @@ static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,* will contain the closest sector. */ __cfqq = rb_entry(parent, struct cfq_queue, p_node); -if (cfq_rq_close (cfqd, cur_cfqq, __cfqq->next_rq, false)) +if (cfq_rq_close (cfqd, cur_cfqq, __cfqq->next_rq))return __cfqq;if (blk_rq_pos (__cfqq->next_rq) < sector)
@@ -1700,7 +1701,7 @@ static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,return NULL ; __cfqq = rb_entry(node, struct cfq_queue, p_node); -if (cfq_rq_close (cfqd, cur_cfqq, __cfqq->next_rq, false)) +if (cfq_rq_close (cfqd, cur_cfqq, __cfqq->next_rq))return __cfqq;return NULL ;
@@ -3103,7 +3104,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,* if this request is as-good as one we would expect from the * current cfqq, let it preempt */ -if (cfq_rq_close (cfqd, cfqq, rq, true)) +if (cfq_rq_close (cfqd, cfqq, rq))return true;return false;
Corrado Zoccolo
Acked-byQuoted 32 lines · Shaohua Li
Quoted 9 lines · Corrado Zoccolo
Quoted 8 lines · Jens Axboe
Quoted 6 lines · Shaohua Li
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. If we store the seek distance to the value before the commit like below, the regression fully goes away. If this is too invasive, just changing thecfq_rq_close()for the !for_preempt is ok too.Quoted 7 lines
Quoted 1 line
Corrado, any objections to widening the seek threshold?
The previous seek threshold value was meant to be compared with the average seek distance, so it was large to account for variations. Since we handle the variations differently, we should have a smaller value now (the 100 * 8 was the result of a benchmark run on several disks).
Our test doesn't find any issue with the seek threshold so far, so it proberly is ok.
Quoted 4 lines
I agreee, though, that for merging queues, it is now too small, so we should have two thresholds, the current one used to determine if a request causes a seek, and an other to be used inside
cfq_close(with the older value, regardless offor_preempt).That makes sense. Updated patch.
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. Restoring cfq_rq_close()'s threshold to original value makes the regression go away.
Quoted 4 lines
Since
for_preemptparameter isn't used anymore, this patch deletes it.Reported-by Alex Shi <[email protected]>Signed-off-by Shaohua Li <[email protected]>
Quoted 53 lines
block/cfq-iosched.c +6
-5@@ -47,6 +47,7 @@ static const int cfq_hist_divisor = 4; #define CFQ_SERVICE_SHIFT 12 #define CFQQ_SEEK_THR (sector_t)(8 * 100) +#define CFQQ_CLOSE_THR (sector_t)(8 * 1024) #define CFQQ_SECT_THR_NONROT (sector_t)(2 * 32) #define CFQQ_SEEKY(cfqq) (hweight32(cfqq->seek_history) > 32/8)@@ -1660,9 +1661,9 @@ static inline sector_t cfq_dist_from_last(struct cfq_data *cfqd, } static inline int cfq_rq_close(struct cfq_data *cfqd, struct cfq_queue *cfqq, - struct request *rq, bool for_preempt) + struct request *rq) { - return cfq_dist_from_last(cfqd, rq) <= CFQQ_SEEK_THR; + return cfq_dist_from_last(cfqd, rq) <= CFQQ_CLOSE_THR; } static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,@@ -1689,7 +1690,7 @@ static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,* will contain the closest sector. */ __cfqq = rb_entry(parent, struct cfq_queue, p_node); - if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq, false)) + if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq)) return __cfqq; if (blk_rq_pos(__cfqq->next_rq) < sector)@@ -1700,7 +1701,7 @@ static struct cfq_queue *cfqq_close(struct cfq_data *cfqd, return NULL; __cfqq = rb_entry(node, struct cfq_queue, p_node); - if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq, false)) + if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq)) return __cfqq; return NULL;@@ -3103,7 +3104,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,* if this request is as-good as one we would expect from the * current cfqq, let it preempt */ - if (cfq_rq_close(cfqd, cfqq, rq, true)) + if (cfq_rq_close(cfqd, cfqq, rq)) return true; return false;
Quoted 27 lines · Shaohua Li
Quoted 9 lines · Corrado Zoccolo
Quoted 8 lines · Jens Axboe
Quoted 6 lines · Shaohua Li
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. If we store the seek distance to the value before the commit like below, the regression fully goes away. If this is too invasive, just changing thecfq_rq_close()for the !for_preempt is ok too.Quoted 7 lines
Quoted 1 line
Corrado, any objections to widening the seek threshold?
The previous seek threshold value was meant to be compared with the average seek distance, so it was large to account for variations. Since we handle the variations differently, we should have a smaller value now (the 100 * 8 was the result of a benchmark run on several disks).
Our test doesn't find any issue with the seek threshold so far, so it proberly is ok.
Quoted 4 lines
I agreee, though, that for merging queues, it is now too small, so we should have two thresholds, the current one used to determine if a request causes a seek, and an other to be used inside
cfq_close(with the older value, regardless offor_preempt).That makes sense. Updated patch.
Quoted 6 lines
Alex Shi reported a kbuild regression which is about 10% performance lost. He bisected to this commit:
3dde36ddea3e07dd025c4c1ba47edec91606fec0. The reason iscfqq_close()can't find close cooperator. Restoring cfq_rq_close()'s threshold to original value makes the regression go away.Since
for_preemptparameter isn't used anymore, this patch deletes it.
Thanks, I have applied it.
Signature · 1 line
Jens Axboe