18c2ecf20Sopenharmony_ci============================== 28c2ecf20Sopenharmony_ciDeadline IO scheduler tunables 38c2ecf20Sopenharmony_ci============================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThis little file attempts to document how the deadline io scheduler works. 68c2ecf20Sopenharmony_ciIn particular, it will clarify the meaning of the exposed tunables that may be 78c2ecf20Sopenharmony_ciof interest to power users. 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciSelecting IO schedulers 108c2ecf20Sopenharmony_ci----------------------- 118c2ecf20Sopenharmony_ciRefer to Documentation/block/switching-sched.rst for information on 128c2ecf20Sopenharmony_ciselecting an io scheduler on a per-device basis. 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci------------------------------------------------------------------------------ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciread_expire (in ms) 178c2ecf20Sopenharmony_ci----------------------- 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ciThe goal of the deadline io scheduler is to attempt to guarantee a start 208c2ecf20Sopenharmony_ciservice time for a request. As we focus mainly on read latencies, this is 218c2ecf20Sopenharmony_citunable. When a read request first enters the io scheduler, it is assigned 228c2ecf20Sopenharmony_cia deadline that is the current time + the read_expire value in units of 238c2ecf20Sopenharmony_cimilliseconds. 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciwrite_expire (in ms) 278c2ecf20Sopenharmony_ci----------------------- 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciSimilar to read_expire mentioned above, but for writes. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cififo_batch (number of requests) 338c2ecf20Sopenharmony_ci------------------------------------ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciRequests are grouped into ``batches`` of a particular data direction (read or 368c2ecf20Sopenharmony_ciwrite) which are serviced in increasing sector order. To limit extra seeking, 378c2ecf20Sopenharmony_cideadline expiries are only checked between batches. fifo_batch controls the 388c2ecf20Sopenharmony_cimaximum number of requests per batch. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciThis parameter tunes the balance between per-request latency and aggregate 418c2ecf20Sopenharmony_cithroughput. When low latency is the primary concern, smaller is better (where 428c2ecf20Sopenharmony_cia value of 1 yields first-come first-served behaviour). Increasing fifo_batch 438c2ecf20Sopenharmony_cigenerally improves throughput, at the cost of latency variation. 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciwrites_starved (number of dispatches) 478c2ecf20Sopenharmony_ci-------------------------------------- 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciWhen we have to move requests from the io scheduler queue to the block 508c2ecf20Sopenharmony_cidevice dispatch queue, we always give a preference to reads. However, we 518c2ecf20Sopenharmony_cidon't want to starve writes indefinitely either. So writes_starved controls 528c2ecf20Sopenharmony_cihow many times we give preference to reads over writes. When that has been 538c2ecf20Sopenharmony_cidone writes_starved number of times, we dispatch some writes based on the 548c2ecf20Sopenharmony_cisame criteria as reads. 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cifront_merges (bool) 588c2ecf20Sopenharmony_ci---------------------- 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ciSometimes it happens that a request enters the io scheduler that is contiguous 618c2ecf20Sopenharmony_ciwith a request that is already on the queue. Either it fits in the back of that 628c2ecf20Sopenharmony_cirequest, or it fits at the front. That is called either a back merge candidate 638c2ecf20Sopenharmony_cior a front merge candidate. Due to the way files are typically laid out, 648c2ecf20Sopenharmony_ciback merges are much more common than front merges. For some work loads, you 658c2ecf20Sopenharmony_cimay even know that it is a waste of time to spend any time attempting to 668c2ecf20Sopenharmony_cifront merge requests. Setting front_merges to 0 disables this functionality. 678c2ecf20Sopenharmony_ciFront merges may still occur due to the cached last_merge hint, but since 688c2ecf20Sopenharmony_cithat comes at basically 0 cost we leave that on. We simply disable the 698c2ecf20Sopenharmony_cirbtree front sector lookup when the io scheduler merge function is called. 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciNov 11 2002, Jens Axboe <jens.axboe@oracle.com> 73