CFQ

From LQWiki
Jump to: navigation, search

CFQ IO Scheduler/elevator

The algorithms used to schedule disk IO requests are referred to as elevator algorithms. Since 2.6 you have had the choice of the Deadline elevator, the Anticipatory elevator (as), the No-op (noop) elevator and the Completely Fair Queuing (CFQ) elevator.

As the name suggests the CFQ elevator algorithm attempts to fairly share your available disk IO resources amongst all the processes that are requesting disk access. Without the fairness of the CFQ elevator it is possible for a process with a low priority (say something you Reniced to reduce its cpu time) to still hog all of your disk IO. The elevators fairness is accomplished by maintaining 64 internal request queues which are serviced in a round-robin fashion. Requests are removed from the non-empty queues in turn and placed in a dispatch queue where they are serviced. The requests are reordered to minimise disk head movement (thus minimising seek times) when they are placed on the dispatch queue.

For example, if there were 10 requests in each internal queue, a request would be taken from each in turn, the 64 requests would then be reordered then placed on the dispatch queue. We now have 9 requests in each queue. Next another request would be removed from each internal queue, reordered and placed on the dispatch queue etc etc.


You can tune two parameters of the CFQ elevators

  • quantum - the number of requests to be place on the dispatch queue in each cycle
  • queued - the number of requests allowed on each of the 64 internal queues