Re: Need information on elevator_dispatch_fn

From: Jens Axboe
Date: Wed Oct 31 2007 - 07:01:33 EST


On Wed, Oct 31 2007, Philipp Gruber wrote:
> Hello everyone,
>
> I'm just working on an I/O-scheduler that implements some QoS
> functionality.
>
> Now I get some weird problems and need to know what triggers my
> elevator_dispatch_fn, and how the return value of it is handled.
> For now, I found that the dispatch function is called as long as there
> are requests in my queue, so probably as long as it returns 1. On the
> other hand, only every second dispatch call returns 1, the others 0, but
> still it's working. I couldn't find any documentation about that (but
> would like to write some, if I understood it). Could someone please
> explain me when and why exactly elevator_dispatch_fn is triggered?

elevator_dispatch_fn() is in charge of putting request on the dispatch
list. So it'll be called, if q->queue_head is empty to refill that. The
core is __elv_next_request(), which is called when a block driver wants
to queue more IO. The logic is essentially:

elv_next_request()
{
while (1) {
if (!list_empty(&q->queue_head))
return first rq of list
if (!elevator_dispatch_fn())
return NULL;
}
}

So if you queue_head is empty AND elevator_dispatch_fn returns 0, then
no request is given to the driver. IF elevator_dispatch_fn returns
non-zero, then it MUST have put request on the queue_head list.

--
Jens Axboe

-
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/