cfq-iosched: speedup cic rb lookup
We often lookup the same queue many times in succession, so cache the last looked up queue to avoid browsing the rbtree. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
4e521c27ee
commit
597bc485d6
1 changed files with 18 additions and 2 deletions
|
@ -1165,6 +1165,8 @@ static void cfq_free_io_context(struct io_context *ioc)
|
||||||
struct rb_node *n;
|
struct rb_node *n;
|
||||||
int freed = 0;
|
int freed = 0;
|
||||||
|
|
||||||
|
ioc->ioc_data = NULL;
|
||||||
|
|
||||||
while ((n = rb_first(&ioc->cic_root)) != NULL) {
|
while ((n = rb_first(&ioc->cic_root)) != NULL) {
|
||||||
__cic = rb_entry(n, struct cfq_io_context, rb_node);
|
__cic = rb_entry(n, struct cfq_io_context, rb_node);
|
||||||
rb_erase(&__cic->rb_node, &ioc->cic_root);
|
rb_erase(&__cic->rb_node, &ioc->cic_root);
|
||||||
|
@ -1228,10 +1230,11 @@ static void cfq_exit_io_context(struct io_context *ioc)
|
||||||
struct cfq_io_context *__cic;
|
struct cfq_io_context *__cic;
|
||||||
struct rb_node *n;
|
struct rb_node *n;
|
||||||
|
|
||||||
|
ioc->ioc_data = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* put the reference this task is holding to the various queues
|
* put the reference this task is holding to the various queues
|
||||||
*/
|
*/
|
||||||
|
|
||||||
n = rb_first(&ioc->cic_root);
|
n = rb_first(&ioc->cic_root);
|
||||||
while (n != NULL) {
|
while (n != NULL) {
|
||||||
__cic = rb_entry(n, struct cfq_io_context, rb_node);
|
__cic = rb_entry(n, struct cfq_io_context, rb_node);
|
||||||
|
@ -1415,6 +1418,10 @@ static void
|
||||||
cfq_drop_dead_cic(struct io_context *ioc, struct cfq_io_context *cic)
|
cfq_drop_dead_cic(struct io_context *ioc, struct cfq_io_context *cic)
|
||||||
{
|
{
|
||||||
WARN_ON(!list_empty(&cic->queue_list));
|
WARN_ON(!list_empty(&cic->queue_list));
|
||||||
|
|
||||||
|
if (ioc->ioc_data == cic)
|
||||||
|
ioc->ioc_data = NULL;
|
||||||
|
|
||||||
rb_erase(&cic->rb_node, &ioc->cic_root);
|
rb_erase(&cic->rb_node, &ioc->cic_root);
|
||||||
kmem_cache_free(cfq_ioc_pool, cic);
|
kmem_cache_free(cfq_ioc_pool, cic);
|
||||||
elv_ioc_count_dec(ioc_count);
|
elv_ioc_count_dec(ioc_count);
|
||||||
|
@ -1430,6 +1437,13 @@ cfq_cic_rb_lookup(struct cfq_data *cfqd, struct io_context *ioc)
|
||||||
if (unlikely(!ioc))
|
if (unlikely(!ioc))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we maintain a last-hit cache, to avoid browsing over the tree
|
||||||
|
*/
|
||||||
|
cic = ioc->ioc_data;
|
||||||
|
if (cic && cic->key == cfqd)
|
||||||
|
return cic;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
n = ioc->cic_root.rb_node;
|
n = ioc->cic_root.rb_node;
|
||||||
while (n) {
|
while (n) {
|
||||||
|
@ -1445,8 +1459,10 @@ cfq_cic_rb_lookup(struct cfq_data *cfqd, struct io_context *ioc)
|
||||||
n = n->rb_left;
|
n = n->rb_left;
|
||||||
else if (key > k)
|
else if (key > k)
|
||||||
n = n->rb_right;
|
n = n->rb_right;
|
||||||
else
|
else {
|
||||||
|
ioc->ioc_data = cic;
|
||||||
return cic;
|
return cic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue