Re: [PATCH 1/1] CFQ: fix handling 'deep' cfqq

From: Shaohua Li
Date: Mon Sep 05 2011 - 21:03:39 EST


2011/8/31 Maxim Patlasov <maxim.patlasov@xxxxxxxxx>:
> Shaohua,
>
> Sorry for not getting back to you for long. See please inline comments below.
>
>> but the cfq_disk_looks_slow isn't updated if the queue doesn't have 4 requests
>> or doesn't dispatch > 4 requests, so you always have CFQD_DISK_LOOKS_FAST()
>> return true if the first slice gets it to true. And if the queue does
>> dispatch > 4 requests in one jiffy, only cfq_disk_looks_fast is updated,
>> CFQD_DISK_LOOKS_FAST returns true too. I don't understand when
>> CFQD_DISK_LOOKS_FAST can be false.
>
> The patch essentially gathers events when cfqq experiences deep queue
> early and dispatches 4 requests in one dispatch round. As soon as such
> an event detected, we're drop inside outer 'if' clause:
>
>> +     if (cfq_cfqq_deep_early(cfqq) && cfqq->n_dispatched >= CFQQ_DEEP_THR) {
>> +             if (cfqq->first_dispatch == jiffies)
>> +                     cfqd->cfq_disk_looks_fast++;
>> +             else
>> +                     cfqd->cfq_disk_looks_slow++;
>> +
>> +             cfqq->first_dispatch = 0;
>> +             cfqq->n_dispatched = 0;
>> +             cfq_clear_cfqq_deep_early(cfqq);
>> +             cfqd->cfq_disk_last_updated = jiffies;
>> +     }
>
> and either increment disk_looks_fast or disk_looks_slow.
>
> If the queue doesn't have 4 requests, cfqq is not 'deep' - no events
> to gather. Neither disk_looks_fast nor disk_looks_slow is updated.
>
> If the queue doesn't dispatch 4 requests in a raw, the event will be
> discarded, and again, neither disk_looks_fast nor disk_looks_slow is
> updated.
>
> If the queue does dispatch > 4 requests in one jiffy, only
> cfq_disk_looks_fast is updated - that's right. But if the queue
> dispatches first 4 requests in *more* than one jiffy,
> cfq_disk_looks_slow is updated.
So the case is in first round, the queue dispatch > 4 requests in one jiffy,
looks_fast gets updated. Later, if the queue always only dispatch < 4 requests
or has < 4 requests queued, no looks_fast/looks_slow gets updated till
10*HZ later.
CFQD_DISK_LOOKS_FAST() always returns true in the period. is this sane?

Thanks,
Shaohua
--
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/