Re: [PATCH 3/4] cfq-iosched: Remove prio_change logic for workload selection

From: Corrado Zoccolo
Date: Thu Dec 17 2009 - 06:49:25 EST


On Wed, Dec 16, 2009 at 11:52 PM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote:
> o CFQ now internally divides cfq queues in therr workload categories. sync-idle,
> Âsync-noidle and async. Which workload to run depends primarily on rb_key
> Âoffset across three service trees. Which is a combination of mulitiple things
> Âincluding what time queue got queued on the service tree.
>
> ÂThere is one exception though. That is if we switched the prio class, say
> Âwe served some RT tasks and again started serving BE class, then with-in
> ÂBE class we always started with sync-noidle workload irrespective of rb_key
> Âoffset in service trees.
>
> ÂThis can provide better latencies for sync-noidle workload in the presence
> Âof RT tasks.
>
> o This patch gets rid of that exception and which workload to run with-in
> Âclass always depends on lowest rb_key across service trees. The reason
> Âbeing that now we have multiple BE class groups and if we always switch
> Âto sync-noidle workload with-in group, we can potentially starve a sync-idle
> Âworkload with-in group. Same is true for async workload which will be in
> Âroot group. Also the workload-switching with-in group will become very
> Âunpredictable as it now depends whether some RT workload was running in
> Âthe system or not.
>
> Signed-off-by: Vivek Goyal <vgoyal@xxxxxxxxxx>
> ---
> Âblock/cfq-iosched.c | Â 48 ++++++++++++------------------------------------
> Â1 files changed, 12 insertions(+), 36 deletions(-)
>
> diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
> index d9bfa09..8df4fe5 100644
> --- a/block/cfq-iosched.c
> +++ b/block/cfq-iosched.c
> @@ -292,8 +292,7 @@ static struct cfq_group *cfq_get_next_cfqg(struct cfq_data *cfqd);
>
> Âstatic struct cfq_rb_root *service_tree_for(struct cfq_group *cfqg,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âenum wl_prio_t prio,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â enum wl_type_t type,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct cfq_data *cfqd)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â enum wl_type_t type)
> Â{
> Â Â Â Âif (!cfqg)
> Â Â Â Â Â Â Â Âreturn NULL;
> @@ -1146,7 +1145,7 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
> Â#endif
>
> Â Â Â Âservice_tree = service_tree_for(cfqq->cfqg, cfqq_prio(cfqq),
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cfqq_type(cfqq), cfqd);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cfqq_type(cfqq));
> Â Â Â Âif (cfq_class_idle(cfqq)) {
> Â Â Â Â Â Â Â Ârb_key = CFQ_IDLE_DELAY;
> Â Â Â Â Â Â Â Âparent = rb_last(&service_tree->rb);
> @@ -1609,7 +1608,7 @@ static struct cfq_queue *cfq_get_next_queue(struct cfq_data *cfqd)
> Â{
> Â Â Â Âstruct cfq_rb_root *service_tree =
> Â Â Â Â Â Â Â Âservice_tree_for(cfqd->serving_group, cfqd->serving_prio,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cfqd->serving_type, cfqd);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cfqd->serving_type);
>
> Â Â Â Âif (!cfqd->rq_queued)
> Â Â Â Â Â Â Â Âreturn NULL;
> @@ -1956,8 +1955,7 @@ static void cfq_setup_merge(struct cfq_queue *cfqq, struct cfq_queue *new_cfqq)
> Â}
>
> Âstatic enum wl_type_t cfq_choose_wl(struct cfq_data *cfqd,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct cfq_group *cfqg, enum wl_prio_t prio,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bool prio_changed)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct cfq_group *cfqg, enum wl_prio_t prio)
> Â{
> Â Â Â Âstruct cfq_queue *queue;
> Â Â Â Âint i;
> @@ -1965,24 +1963,9 @@ static enum wl_type_t cfq_choose_wl(struct cfq_data *cfqd,
> Â Â Â Âunsigned long lowest_key = 0;
> Â Â Â Âenum wl_type_t cur_best = SYNC_NOIDLE_WORKLOAD;
>
> - Â Â Â if (prio_changed) {
> - Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â* When priorities switched, we prefer starting
> - Â Â Â Â Â Â Â Â* from SYNC_NOIDLE (first choice), or just SYNC
> - Â Â Â Â Â Â Â Â* over ASYNC
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â if (service_tree_for(cfqg, prio, cur_best, cfqd)->count)
> - Â Â Â Â Â Â Â Â Â Â Â return cur_best;
> - Â Â Â Â Â Â Â cur_best = SYNC_WORKLOAD;
> - Â Â Â Â Â Â Â if (service_tree_for(cfqg, prio, cur_best, cfqd)->count)
> - Â Â Â Â Â Â Â Â Â Â Â return cur_best;
> -
> - Â Â Â Â Â Â Â return ASYNC_WORKLOAD;
> - Â Â Â }
> -
> - Â Â Â for (i = 0; i < 3; ++i) {
> - Â Â Â Â Â Â Â /* otherwise, select the one with lowest rb_key */
> - Â Â Â Â Â Â Â queue = cfq_rb_first(service_tree_for(cfqg, prio, i, cfqd));
> + Â Â Â for (i = 0; i <= SYNC_WORKLOAD; ++i) {
> + Â Â Â Â Â Â Â /* select the one with lowest rb_key */
> + Â Â Â Â Â Â Â queue = cfq_rb_first(service_tree_for(cfqg, prio, i));
> Â Â Â Â Â Â Â Âif (queue &&
> Â Â Â Â Â Â Â Â Â Â(!key_valid || time_before(queue->rb_key, lowest_key))) {
> Â Â Â Â Â Â Â Â Â Â Â Âlowest_key = queue->rb_key;
> @@ -1996,8 +1979,6 @@ static enum wl_type_t cfq_choose_wl(struct cfq_data *cfqd,
>
> Âstatic void choose_service_tree(struct cfq_data *cfqd, struct cfq_group *cfqg)
> Â{
> - Â Â Â enum wl_prio_t previous_prio = cfqd->serving_prio;
> - Â Â Â bool prio_changed;
> Â Â Â Âunsigned slice;
> Â Â Â Âunsigned count;
> Â Â Â Âstruct cfq_rb_root *st;
> @@ -2025,24 +2006,19 @@ static void choose_service_tree(struct cfq_data *cfqd, struct cfq_group *cfqg)
> Â Â Â Â * (SYNC, SYNC_NOIDLE, ASYNC), and to compute a workload
> Â Â Â Â * expiration time
> Â Â Â Â */
> - Â Â Â prio_changed = (cfqd->serving_prio != previous_prio);
> - Â Â Â st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cfqd);
> + Â Â Â st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type);
> Â Â Â Âcount = st->count;
>
> Â Â Â Â/*
> - Â Â Â Â* If priority didn't change, check workload expiration,
> - Â Â Â Â* and that we still have other queues ready
> + Â Â Â Â* check workload expiration, and that we still have other queues ready
> Â Â Â Â */
> - Â Â Â if (!prio_changed && count &&
> - Â Â Â Â Â !time_after(jiffies, cfqd->workload_expires))
> + Â Â Â if (count && !time_after(jiffies, cfqd->workload_expires))
> Â Â Â Â Â Â Â Âreturn;
>
> Â Â Â Â/* otherwise select new workload type */
> Â Â Â Âcfqd->serving_type =
> - Â Â Â Â Â Â Â cfq_choose_wl(cfqd, cfqg, cfqd->serving_prio, prio_changed);
> - Â Â Â st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cfqd);
> + Â Â Â Â Â Â Â cfq_choose_wl(cfqd, cfqg, cfqd->serving_prio);
> + Â Â Â st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type);
> Â Â Â Âcount = st->count;
>
> Â Â Â Â/*
> --
> 1.6.2.5
>
>

Acked-by: Corrado Zoccolo <czoccolo@xxxxxxxxx>
--
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/