Re: [PATCH 03/16] blkio: Keep queue on service tree until we expire it

From: Corrado Zoccolo
Date: Fri Nov 13 2009 - 05:40:11 EST


Hi Vivek,
the following is probably not on a critical path, but maybe it can be
written more efficiently.
Now, it will cicle through all service trees multiple times, to
retrieve the queues for the last one.
What about having a cfq_for_each_queue that takes a function pointer
and will apply it to all of them?

On Fri, Nov 13, 2009 at 12:32 AM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote:
> +static struct cfq_queue *cfq_get_next_queue(struct cfq_data *cfqd)
> +{
> + Â Â Â struct cfq_group *cfqg = &cfqd->root_group;
> + Â Â Â struct cfq_queue *cfqq;
> + Â Â Â int i, j;
> +
> + Â Â Â if (!cfqd->rq_queued)
> + Â Â Â Â Â Â Â return NULL;
> +
> + Â Â Â for (i = 0; i < 2; ++i) {
> + Â Â Â Â Â Â Â for (j = 0; j < 3; ++j) {
> + Â Â Â Â Â Â Â Â Â Â Â cfqq = cfq_rb_first(&cfqg->service_trees[i][j]);
> + Â Â Â Â Â Â Â Â Â Â Â if (cfqq)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return cfqq;
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> +
> + Â Â Â cfqq = cfq_rb_first(&cfqg->service_tree_idle);
> + Â Â Â if (cfqq)
> + Â Â Â Â Â Â Â return cfqq;
> + Â Â Â return NULL;
> +}
> +
> Â/*
> Â* Get and set a new active queue for service.
> Â*/
> @@ -1590,16 +1633,8 @@ static int cfq_forced_dispatch(struct cfq_data *cfqd)
> Â{
> Â Â Â Âstruct cfq_queue *cfqq;
> Â Â Â Âint dispatched = 0;
> - Â Â Â int i, j;
> - Â Â Â struct cfq_group *cfqg = &cfqd->root_group;
> -
> - Â Â Â for (i = 0; i < 2; ++i)
> - Â Â Â Â Â Â Â for (j = 0; j < 3; ++j)
> - Â Â Â Â Â Â Â Â Â Â Â while ((cfqq = cfq_rb_first(&cfqg->service_trees[i][j]))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â != NULL)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dispatched += __cfq_forced_dispatch_cfqq(cfqq);
>
> - Â Â Â while ((cfqq = cfq_rb_first(&cfqg->service_tree_idle)) != NULL)
> + Â Â Â while ((cfqq = cfq_get_next_queue(cfqd)) != NULL)
> Â Â Â Â Â Â Â Âdispatched += __cfq_forced_dispatch_cfqq(cfqq);
>
> Â Â Â Âcfq_slice_expired(cfqd, 0);
> @@ -1770,13 +1805,14 @@ static void cfq_put_queue(struct cfq_queue *cfqq)
> Â Â Â Âcfq_log_cfqq(cfqd, cfqq, "put_queue");
> Â Â Â ÂBUG_ON(rb_first(&cfqq->sort_list));
> Â Â Â ÂBUG_ON(cfqq->allocated[READ] + cfqq->allocated[WRITE]);
> - Â Â Â BUG_ON(cfq_cfqq_on_rr(cfqq));
>
> Â Â Â Âif (unlikely(cfqd->active_queue == cfqq)) {
> Â Â Â Â Â Â Â Â__cfq_slice_expired(cfqd, cfqq, 0);
> Â Â Â Â Â Â Â Âcfq_schedule_dispatch(cfqd);
> Â Â Â Â}
>
> + Â Â Â BUG_ON(cfq_cfqq_on_rr(cfqq));
> +
> Â Â Â Âkmem_cache_free(cfq_pool, cfqq);
> Â}
>
> --
> 1.6.2.5
>



Thanks
Corrado
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/