Skip to content

Commit 94970cf

Browse files
igawaxboe
authored andcommitted
scsi: use block layer helpers to calculate num of queues
The calculation of the upper limit for queues does not depend solely on the number of online CPUs; for example, the isolcpus kernel command-line option must also be considered. To account for this, the block layer provides a helper function to retrieve the maximum number of queues. Use it to set an appropriate upper queue number limit. Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Daniel Wagner <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4082c98 commit 94970cf

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5971,7 +5971,8 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance)
59715971
else
59725972
instance->iopoll_q_count = 0;
59735973

5974-
num_msix_req = num_online_cpus() + instance->low_latency_index_start;
5974+
num_msix_req = blk_mq_num_online_queues(0) +
5975+
instance->low_latency_index_start;
59755976
instance->msix_vectors = min(num_msix_req,
59765977
instance->msix_vectors);
59775978

@@ -5987,7 +5988,8 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance)
59875988
/* Disable Balanced IOPS mode and try realloc vectors */
59885989
instance->perf_mode = MR_LATENCY_PERF_MODE;
59895990
instance->low_latency_index_start = 1;
5990-
num_msix_req = num_online_cpus() + instance->low_latency_index_start;
5991+
num_msix_req = blk_mq_num_online_queues(0) +
5992+
instance->low_latency_index_start;
59915993

59925994
instance->msix_vectors = min(num_msix_req,
59935995
instance->msix_vectors);
@@ -6243,7 +6245,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
62436245
intr_coalescing = (scratch_pad_1 & MR_INTR_COALESCING_SUPPORT_OFFSET) ?
62446246
true : false;
62456247
if (intr_coalescing &&
6246-
(num_online_cpus() >= MR_HIGH_IOPS_QUEUE_COUNT) &&
6248+
(blk_mq_num_online_queues(0) >= MR_HIGH_IOPS_QUEUE_COUNT) &&
62476249
(instance->msix_vectors == MEGASAS_MAX_MSIX_QUEUES))
62486250
instance->perf_mode = MR_BALANCED_PERF_MODE;
62496251
else
@@ -6287,7 +6289,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
62876289
else
62886290
instance->low_latency_index_start = 1;
62896291

6290-
num_msix_req = num_online_cpus() + instance->low_latency_index_start;
6292+
num_msix_req = blk_mq_num_online_queues(0) +
6293+
instance->low_latency_index_start;
62916294

62926295
instance->msix_vectors = min(num_msix_req,
62936296
instance->msix_vectors);
@@ -6319,8 +6322,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
63196322
megasas_setup_reply_map(instance);
63206323

63216324
dev_info(&instance->pdev->dev,
6322-
"current msix/online cpus\t: (%d/%d)\n",
6323-
instance->msix_vectors, (unsigned int)num_online_cpus());
6325+
"current msix/max num queues\t: (%d/%u)\n",
6326+
instance->msix_vectors, blk_mq_num_online_queues(0));
63246327
dev_info(&instance->pdev->dev,
63256328
"RDPQ mode\t: (%s)\n", instance->is_rdpq ? "enabled" : "disabled");
63266329

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4533,13 +4533,13 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
45334533
if (USER_CTRL_IRQ(ha) || !ha->mqiobase) {
45344534
/* user wants to control IRQ setting for target mode */
45354535
ret = pci_alloc_irq_vectors(ha->pdev, min_vecs,
4536-
min((u16)ha->msix_count, (u16)(num_online_cpus() + min_vecs)),
4537-
PCI_IRQ_MSIX);
4536+
blk_mq_num_online_queues(ha->msix_count) + min_vecs,
4537+
PCI_IRQ_MSIX);
45384538
} else
45394539
ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs,
4540-
min((u16)ha->msix_count, (u16)(num_online_cpus() + min_vecs)),
4541-
PCI_IRQ_MSIX | PCI_IRQ_AFFINITY,
4542-
&desc);
4540+
blk_mq_num_online_queues(ha->msix_count) + min_vecs,
4541+
PCI_IRQ_MSIX | PCI_IRQ_AFFINITY,
4542+
&desc);
45434543

45444544
if (ret < 0) {
45454545
ql_log(ql_log_fatal, vha, 0x00c7,

drivers/scsi/smartpqi/smartpqi_init.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5294,15 +5294,14 @@ static void pqi_calculate_queue_resources(struct pqi_ctrl_info *ctrl_info)
52945294
if (is_kdump_kernel()) {
52955295
num_queue_groups = 1;
52965296
} else {
5297-
int num_cpus;
52985297
int max_queue_groups;
52995298

53005299
max_queue_groups = min(ctrl_info->max_inbound_queues / 2,
53015300
ctrl_info->max_outbound_queues - 1);
53025301
max_queue_groups = min(max_queue_groups, PQI_MAX_QUEUE_GROUPS);
53035302

5304-
num_cpus = num_online_cpus();
5305-
num_queue_groups = min(num_cpus, ctrl_info->max_msix_vectors);
5303+
num_queue_groups =
5304+
blk_mq_num_online_queues(ctrl_info->max_msix_vectors);
53065305
num_queue_groups = min(num_queue_groups, max_queue_groups);
53075306
}
53085307

0 commit comments

Comments
 (0)