Scheduling constraints for sync requests in the BFQ scheduler
by adithyabhaskar from LinuxQuestions.org on (#5JBRN)
In the BFQ scheduler of the linux kernel (bfq-iosched.c), I noticed that there are separate queues for SYNC and non-SYNC requests. Also, the insert function(s) seem to opportunistically try to run the respective queues when receiving requests. My question is, how the ordering enforced between a SYNC request and preceding requests? For example, if I have requests in the order:
SYNC1 A B C SYNC2
then the individual FIFO ordering of both dispatch queues ensures the order SYNC1 < SYNC2 and A < B < C, but where (in which function) is SYNC1 < A < SYNC2 (for e.g.) enforced?
What I tried doing: I tried following the dispatch functions, hoping that they would enforce the ordering somewhere. The requests flow via blk_mq_sched_dispatch_requests in blk-mq-sched.c and finally converge via various paths at blk_mq_dispatch_rq_list in blk-mq.c However, this function simply keeps dispatching requests until either the queue runs out or a tag cannot be obtained for the request (and the tag allocation function, blk_mq_get_driver_tag, calls __blk_mq_get_tag. Here one argument is struct blk_mq_alloc_data which has the cmd_flags as a struct member, but after following through to __sbitmap_queue_get I don't think I got anywhere.)
I am somewhat of a linux kernel newbie so sorry if the question isn't very focused. If you need more information do ask.


SYNC1 A B C SYNC2
then the individual FIFO ordering of both dispatch queues ensures the order SYNC1 < SYNC2 and A < B < C, but where (in which function) is SYNC1 < A < SYNC2 (for e.g.) enforced?
What I tried doing: I tried following the dispatch functions, hoping that they would enforce the ordering somewhere. The requests flow via blk_mq_sched_dispatch_requests in blk-mq-sched.c and finally converge via various paths at blk_mq_dispatch_rq_list in blk-mq.c However, this function simply keeps dispatching requests until either the queue runs out or a tag cannot be obtained for the request (and the tag allocation function, blk_mq_get_driver_tag, calls __blk_mq_get_tag. Here one argument is struct blk_mq_alloc_data which has the cmd_flags as a struct member, but after following through to __sbitmap_queue_get I don't think I got anywhere.)
I am somewhat of a linux kernel newbie so sorry if the question isn't very focused. If you need more information do ask.