OSDN Git Service

block: Reduce the amount of memory used for tag sets
authorBart Van Assche <bvanassche@acm.org>
Fri, 25 Oct 2019 16:50:10 +0000 (09:50 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Oct 2019 20:12:20 +0000 (14:12 -0600)
commitf7e76dbc24df695f1b8e88ed3201be22215ec969
tree7ffba72420872347d8a556ea42f8c41edc389ebd
parentac0d6b926e741f328b23c8af0134312af7c032d9
block: Reduce the amount of memory used for tag sets

Instead of allocating an array of size nr_cpu_ids for set->tags, allocate
an array of size set->nr_hw_queues. This patch improves behavior that was
introduced by commit 868f2f0b7206 ("blk-mq: dynamic h/w context count").

Reallocating tag sets from inside __blk_mq_update_nr_hw_queues() is safe
because:
- All request queues that share the tag sets are frozen before the tag sets
  are reallocated.
- blk_mq_queue_tag_busy_iter() holds q->q_usage_counter while active and
  hence is serialized against __blk_mq_update_nr_hw_queues().

Cc: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c