• Andrew Morton's avatar
    [PATCH] infrastructure for monitoring queue congestion state · 4cef1b04
    Andrew Morton authored
    The patch provides a means for the VM to be able to determine whether a
    request queue is in a "congested" state.  If it is congested, then a
    write to (or read from) the queue may cause blockage in
    get_request_wait().
    
    So the VM can do:
    
    	if (!bdi_write_congested(page->mapping->backing_dev_info))
    		writepage(page);
    
    This is not exact.  The code assumes that if the request queue still
    has 1/4 of its capacity (queue_nr_requests) available then a request
    will be non-blocking.  There is a small chance that another CPU could
    zoom in and consume those requests.  But on the rare occasions where
    that may happen the result will mereley be some unexpected latency -
    it's not worth doing anything elaborate to prevent this.
    
    The patch decreases the size of `batch_requests'.  batch_requests is
    positively harmful - when a "heavy" writer and a "light" writer are
    both writing to the same queue, batch_requests provides a means for the
    heavy writer to massively stall the light writer.  Instead of waiting
    for one or two requests to come free, the light writer has to wait for
    32 requests to complete.
    
    Plus batch_requests generally makes things harder to tune, understand
    and predict.  I wanted to kill it altogether, but Jens says that it is
    important for some hardware - it allows decent size requests to be
    submitted.
    
    The VM changes which go along with this code cause batch_requests to be
    not so painful anyway - the only processes which sleep in
    get_request_wait() are the ones which we elect, by design, to wait in
    there - typically heavy writers.
    
    
    The patch changes the meaning of `queue_nr_requests'.  It used to mean
    "total number of requests per queue".  Half of these are for reads, and
    half are for writes.  This always confused the heck out of me, and the
    code needs to divide queue_nr_requests by two all over the place.
    
    So queue_nr_requests now means "the number of write requests per queue"
    and "the number of read requests per queue".  ie: I halved it.
    
    Also, queue_nr_requests was converted to static scope.  Nothing else
    uses it.
    
    
    The accuracy of bdi_read_congested() and bdi_write_congested() depends
    upon the accuracy of mapping->backing_dev_info.  With complex block
    stacking arrangements it is possible that ->backing_dev_info is
    pointing at the wrong queue.  I don't know.
    
    But the cost of getting this wrong is merely latency, and if it is a
    problem we can fix it up in the block layer, by getting stacking
    devices to communicate their congestion state upwards in some manner.
    4cef1b04
ll_rw_blk.c 52.6 KB