On 12/1/23 23:21, Yu Kuai wrote:
在 2023/12/01 3:31, Bart Van Assche 写道:
+/*
+ * Enable or disable fair tag sharing for all request queues
associated with
+ * a tag set.
+ */
+void blk_mq_update_fair_sharing(struct blk_mq_tag_set *set, bool enable)
+{
+ const unsigned int DFTS_BIT =
ilog2(BLK_MQ_F_DISABLE_FAIR_TAG_SHARING);
+ struct blk_mq_hw_ctx *hctx;
+ struct request_queue *q;
+ unsigned long i;
+
+ /*
+ * Serialize against blk_mq_update_nr_hw_queues() and
+ * blk_mq_realloc_hw_ctxs().
+ */
+ mutex_lock(&set->tag_list_lock);
I'm a litter confused about this comment, because
blk_mq_realloc_hw_ctxs() can be called from
blk_mq_update_nr_hw_queues().
If you are talking about blk_mq_init_allocated_queue(), it looks like
just holding this lock is not enough?
I added that comment because blk_mq_init_allocated_queue() calls
blk_mq_realloc_hw_ctxs() before the request queue is added to
set->tag_list. I will take a closer look at how
blk_mq_init_allocated_queue() reads set->flags and will make sure
that these reads are properly serialized against the changes made
by blk_mq_update_fair_sharing().
Thanks,
Bart.