On Thu, Jul 21, 2022 at 07:16:31AM +0200, Christoph Hellwig wrote: > Looking at the hctxs and cpumap is not safe without at very last a RCU > reference. It also requires the queue to be set up before starting the > device, which leads to rather awkware life time rules. > > Instead rewrite ublk_ctrl_get_queue_affinity to call blk_mq_map_queues > on an on-stack blk_mq_queue_map and build the cpumask from that. > > Note: given that ublk has not made it into a released kernel it might > make sense to change the ABI for this command to instead copy the > qmap.mq_map array (a nr_cpu_ids sized array of unsigned integer > values where the CPU index directly points to the queue) to userspace. qmap.mq_map is too big. tag_set is embedded into ublk_device, and can be allocated once during adding device, then ublk_ctrl_get_queue_affinity() can retrieve the info from tag_set's map directly, then it is simplified a lot. Also all info for building tag_set is setup during adding device, and these info won't be changed after adding device, so it is reasonable to allocate tagset just once. Thanks, Ming