mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Corrado Zoccolo <czoccolo@gmail.com>
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>,
	Jeff Moyer <jmoyer@redhat.com>
Subject: Re: [RFC PATCH 1/5] cfq-iosched: adapt slice to number of processes   doing I/O
Date: Tue, 20 Oct 2009 15:17:44 +0200	[thread overview]
Message-ID: <20091020131744.GH10727@kernel.dk> (raw)
In-Reply-To: <4e5e476b0910200301w4ae2725ch37b81c1529bdcfec@mail.gmail.com>

On Tue, Oct 20 2009, Corrado Zoccolo wrote:
> On Tue, Oct 20, 2009 at 2:54 AM, Jens Axboe <jens.axboe@oracle.com> wrote:
> > On Mon, Oct 19 2009, Corrado Zoccolo wrote:
> >> When the number of processes performing I/O concurrently increases,
> >> a fixed time slice per process will cause large latencies.
> >>
> >> This patch, if low_latency mode is enabled,  will scale the time slice
> >> assigned to each process according to a 300ms target latency.
> >>
> >> In order to keep fairness among processes:
> >> * The number of active processes is computed using a special form of
> >> running average, that quickly follows sudden increases (to keep latency low),
> >> and decrease slowly (to have fairness in spite of rapid decreases of this
> >> value).
> >>
> >> To safeguard sequential bandwidth, we impose a minimum time slice
> >> (computed using 2*cfq_slice_idle as base, adjusted according to priority
> >> and async-ness).
> >
> > Generally, this looks good. Just one minor style nit:
> >
> >> +static inline unsigned
> >> +cfq_get_avg_queues(struct cfq_data *cfqd, bool rt) {
> >> +     unsigned min_q, max_q;
> >> +     unsigned mult  = cfq_hist_divisor - 1;
> >> +     unsigned round = cfq_hist_divisor / 2;
> >> +     unsigned busy  = rt ? cfqd->busy_rt_queues :
> >> +             (cfqd->busy_queues - cfqd->busy_rt_queues);
> >> +     min_q = min(cfqd->busy_queues_avg[rt], busy);
> >> +     max_q = max(cfqd->busy_queues_avg[rt], busy);
> >> +     cfqd->busy_queues_avg[rt] = (mult * max_q + min_q + round) /
> >> +             cfq_hist_divisor;
> >> +     return cfqd->busy_queues_avg[rt];
> >> +}
> >
> > A lot of your code suffers from the specific problem of being largely
> > unreadable. To me, as the maintainer of that code, that is a maintenance
> > issue. I already asked you to get rid of the ?: constructs for earlier
> > patches, this series even takes it to the extreme of doing nested ?:
> > clauses. Don't do it! It's unreadable.
> 
> Ok. I'll resubmit a revised version of the patches that address this
> stile issue, as well as your concern with too large functions and
> lacking comments.
> I didn't realize that you hated ?: so much :).

I do, personally it doesn't read anywhere near as naturally as a simple
'if'. And when you start doing x = a ? b : c ? d : e; I almost reach for
the nearest expletive :-)

And adding a local scope with {} and having 3-4 broken lines of
multiplications, divisions (etc) inside max()/min() calls doesn't add to
the readability in any positive way...

> To me, it seems a good way to achieve a different readability goal,
> i.e. define the value of a variable in a single place, instead of
> scattering it around on multiple lines.

I prefer putting it elsewhere instead. So instead of doing:

        foo_type bar = x(y) == BAZ ? a : b;

you have

get_foo_type(y)
{
        if (x(y) == BAZ)
                return a;

        return b;
}

        foo_type bar = get_foo_type(y);

which is a lot more readable to me. Especially since you have to do the
get_foo_type() operation in a lot of places.

> >> @@ -2152,10 +2186,9 @@ static void cfq_insert_request(struct request_queue *q, struct request *rq)
> >>       cfq_log_cfqq(cfqd, cfqq, "insert_request");
> >>       cfq_init_prio_data(cfqq, RQ_CIC(rq)->ioc);
> >>
> >> -     cfq_add_rq_rb(rq);
> >> -
> >>       rq_set_fifo_time(rq, jiffies + cfqd->cfq_fifo_expire[rq_is_sync(rq)]);
> >>       list_add_tail(&rq->queuelist, &cfqq->fifo);
> >> +     cfq_add_rq_rb(rq);
> >>
> >>       cfq_rq_enqueued(cfqd, cfqq, rq);
> >
> > If the fifo vs service tree ordering is now important, you should
> > comment on why.
> It's not important for the patches per se, but I found odd (and it
> caused me some headache while debugging) that in cfq_add_rq_rb the
> fifo was still empty.
> In the new form, the rq will be complete when added, while in the
> previous, it still had some empty fields.

Then keep it like it is, or do it as a separate patch. When you include
it in a functionally changing patch like this, I'm assuming there must
be a reason for that. And when it seems like there isn't, you wonder
what is up.

-- 
Jens Axboe


  reply	other threads:[~2009-10-20 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-19 20:21 Corrado Zoccolo
2009-10-20  0:54 ` Jens Axboe
2009-10-20 10:01   ` Corrado Zoccolo
2009-10-20 13:17     ` Jens Axboe [this message]
2009-10-20 18:11       ` Corrado Zoccolo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091020131744.GH10727@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=czoccolo@gmail.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome