strcut blk_plug如何与多线程一起使用?

时间:2018-12-30 02:39:14

标签: linux linux-kernel

Linux源代码remarkblk_plug是每个任务的列表,strcut中没有任何锁定:

/*
 * blk_plug permits building a queue of related requests by holding the I/O
 * fragments for a short period. This allows merging of sequential requests
 * into single larger request. As the requests are moved from a per-task list to
 * the device's request_queue in a batch, this results in improved scalability
 * as the lock contention for request_queue lock is reduced.
 *
 * It is ok not to disable preemption when adding the request to the plug list
 * or when attempting a merge, because blk_schedule_flush_list() will only flush
 * the plug list when the task sleeps by itself. For details, please see
 * schedule() where blk_schedule_flush_plug() is called.
 */
struct blk_plug {
  struct list_head list; 
  struct list_head mq_list; 
  struct list_head cb_list; 
}

struct blk_plug如何在多线程进程中保持其安全?

0 个答案:

没有答案