On Wed, Aug 21, 2019 at 08:56:36AM -0700, Bart Van Assche wrote: > On 8/21/19 2:15 AM, Ming Lei wrote: > > blk_mq_realloc_hw_ctxs() is called from blk_mq_init_allocated_queue() > > and blk_mq_update_nr_hw_queues(). For the former caller, the kobject > > isn't exposed to userspace yet. For the latter caller, sysfs/debugfs > > is un-registered before updating nr_hw_queues. > > > > On the other hand, commit 2f8f1336a48b ("blk-mq: always free hctx after > > request queue is freed") moves freeing hctx into queue's release > > handler, so there won't be race with queue release path too. > > > > So don't hold q->sysfs_lock in blk_mq_realloc_hw_ctxs(). > > How about mentioning that the locking at the start of > blk_mq_update_nr_hw_queues() serializes all blk_mq_realloc_hw_ctxs() calls > that happen after a queue has been registered in sysfs? This patch is actually wrong because elevator switch still may happen during updating nr_hw_queues, since only hctx sysfs entries are un-registered, and "queue/scheduler" is still visible to userspace. So I will drop this patch in V3. Thanks, Ming