Skip to content

Commit 49db4d4

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Performance tweak
Move statistics fields from vha struct to qpair to reduce memory thrashing. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Quinn Tran <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d38cb84 commit 49db4d4

File tree

8 files changed

+91
-39
lines changed

8 files changed

+91
-39
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,6 +2726,9 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
27262726
struct link_statistics *stats;
27272727
dma_addr_t stats_dma;
27282728
struct fc_host_statistics *p = &vha->fc_host_stat;
2729+
struct qla_qpair *qpair;
2730+
int i;
2731+
u64 ib = 0, ob = 0, ir = 0, or = 0;
27292732

27302733
memset(p, -1, sizeof(*p));
27312734

@@ -2762,6 +2765,27 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
27622765
if (rval != QLA_SUCCESS)
27632766
goto done_free;
27642767

2768+
/* --- */
2769+
for (i = 0; i < vha->hw->max_qpairs; i++) {
2770+
qpair = vha->hw->queue_pair_map[i];
2771+
if (!qpair)
2772+
continue;
2773+
ir += qpair->counters.input_requests;
2774+
or += qpair->counters.output_requests;
2775+
ib += qpair->counters.input_bytes;
2776+
ob += qpair->counters.output_bytes;
2777+
}
2778+
ir += ha->base_qpair->counters.input_requests;
2779+
or += ha->base_qpair->counters.output_requests;
2780+
ib += ha->base_qpair->counters.input_bytes;
2781+
ob += ha->base_qpair->counters.output_bytes;
2782+
2783+
ir += vha->qla_stats.input_requests;
2784+
or += vha->qla_stats.output_requests;
2785+
ib += vha->qla_stats.input_bytes;
2786+
ob += vha->qla_stats.output_bytes;
2787+
/* --- */
2788+
27652789
p->link_failure_count = le32_to_cpu(stats->link_fail_cnt);
27662790
p->loss_of_sync_count = le32_to_cpu(stats->loss_sync_cnt);
27672791
p->loss_of_signal_count = le32_to_cpu(stats->loss_sig_cnt);
@@ -2781,15 +2805,16 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
27812805
p->rx_words = le64_to_cpu(stats->fpm_recv_word_cnt);
27822806
p->tx_words = le64_to_cpu(stats->fpm_xmit_word_cnt);
27832807
} else {
2784-
p->rx_words = vha->qla_stats.input_bytes;
2785-
p->tx_words = vha->qla_stats.output_bytes;
2808+
p->rx_words = ib >> 2;
2809+
p->tx_words = ob >> 2;
27862810
}
27872811
}
2812+
27882813
p->fcp_control_requests = vha->qla_stats.control_requests;
2789-
p->fcp_input_requests = vha->qla_stats.input_requests;
2790-
p->fcp_output_requests = vha->qla_stats.output_requests;
2791-
p->fcp_input_megabytes = vha->qla_stats.input_bytes >> 20;
2792-
p->fcp_output_megabytes = vha->qla_stats.output_bytes >> 20;
2814+
p->fcp_input_requests = ir;
2815+
p->fcp_output_requests = or;
2816+
p->fcp_input_megabytes = ib >> 20;
2817+
p->fcp_output_megabytes = ob >> 20;
27932818
p->seconds_since_last_reset =
27942819
get_jiffies_64() - vha->qla_stats.jiffies_at_last_reset;
27952820
do_div(p->seconds_since_last_reset, HZ);
@@ -2809,9 +2834,18 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
28092834
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
28102835
struct link_statistics *stats;
28112836
dma_addr_t stats_dma;
2837+
int i;
2838+
struct qla_qpair *qpair;
28122839

28132840
memset(&vha->qla_stats, 0, sizeof(vha->qla_stats));
28142841
memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat));
2842+
for (i = 0; i < vha->hw->max_qpairs; i++) {
2843+
qpair = vha->hw->queue_pair_map[i];
2844+
if (!qpair)
2845+
continue;
2846+
memset(&qpair->counters, 0, sizeof(qpair->counters));
2847+
}
2848+
memset(&ha->base_qpair->counters, 0, sizeof(qpair->counters));
28152849

28162850
vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
28172851

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,12 +2443,6 @@ typedef struct fc_port {
24432443
struct list_head list;
24442444
struct scsi_qla_host *vha;
24452445

2446-
uint8_t node_name[WWN_SIZE];
2447-
uint8_t port_name[WWN_SIZE];
2448-
port_id_t d_id;
2449-
uint16_t loop_id;
2450-
uint16_t old_loop_id;
2451-
24522446
unsigned int conf_compl_supported:1;
24532447
unsigned int deleted:2;
24542448
unsigned int free_pending:1;
@@ -2465,6 +2459,13 @@ typedef struct fc_port {
24652459
unsigned int n2n_flag:1;
24662460
unsigned int explicit_logout:1;
24672461
unsigned int prli_pend_timer:1;
2462+
uint8_t nvme_flag;
2463+
2464+
uint8_t node_name[WWN_SIZE];
2465+
uint8_t port_name[WWN_SIZE];
2466+
port_id_t d_id;
2467+
uint16_t loop_id;
2468+
uint16_t old_loop_id;
24682469

24692470
struct completion nvme_del_done;
24702471
uint32_t nvme_prli_service_param;
@@ -2473,7 +2474,7 @@ typedef struct fc_port {
24732474
#define NVME_PRLI_SP_TARGET BIT_4
24742475
#define NVME_PRLI_SP_DISCOVERY BIT_3
24752476
#define NVME_PRLI_SP_FIRST_BURST BIT_0
2476-
uint8_t nvme_flag;
2477+
24772478
uint32_t nvme_first_burst_size;
24782479
#define NVME_FLAG_REGISTERED 4
24792480
#define NVME_FLAG_DELETING 2
@@ -3510,6 +3511,14 @@ struct qla_tgt_counters {
35103511
uint64_t num_term_xchg_sent;
35113512
};
35123513

3514+
struct qla_counters {
3515+
uint64_t input_bytes;
3516+
uint64_t input_requests;
3517+
uint64_t output_bytes;
3518+
uint64_t output_requests;
3519+
3520+
};
3521+
35133522
struct qla_qpair;
35143523

35153524
/* Response queue data structure */
@@ -3594,6 +3603,7 @@ struct qla_qpair {
35943603
uint32_t enable_class_2:1;
35953604
uint32_t enable_explicit_conf:1;
35963605
uint32_t use_shadow_reg:1;
3606+
uint32_t rcv_intr:1;
35973607

35983608
uint16_t id; /* qp number used with FW */
35993609
uint16_t vp_idx; /* vport ID */
@@ -3609,13 +3619,16 @@ struct qla_qpair {
36093619
struct qla_msix_entry *msix; /* point to &ha->msix_entries[x] */
36103620
struct qla_hw_data *hw;
36113621
struct work_struct q_work;
3622+
struct qla_counters counters;
3623+
36123624
struct list_head qp_list_elem; /* vha->qp_list */
36133625
struct list_head hints_list;
3614-
uint16_t cpuid;
3626+
36153627
uint16_t retry_term_cnt;
36163628
__le32 retry_term_exchg_addr;
36173629
uint64_t retry_term_jiff;
36183630
struct qla_tgt_counters tgt_counters;
3631+
uint16_t cpuid;
36193632
};
36203633

36213634
/* Place holder for FW buffer parameters */
@@ -4129,6 +4142,10 @@ struct qla_hw_data {
41294142
#define USE_ASYNC_SCAN(ha) (IS_QLA25XX(ha) || IS_QLA81XX(ha) ||\
41304143
IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
41314144

4145+
#define IS_ZIO_THRESHOLD_CAPABLE(ha) \
4146+
((IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&\
4147+
(ha->zio_mode == QLA_ZIO_MODE_6))
4148+
41324149
/* HBA serial number */
41334150
uint8_t serial0;
41344151
uint8_t serial1;

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,9 +3700,7 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
37003700
goto execute_fw_with_lr;
37013701
}
37023702

3703-
if ((IS_QLA83XX(ha) || IS_QLA27XX(ha) ||
3704-
IS_QLA28XX(ha)) &&
3705-
(ha->zio_mode == QLA_ZIO_MODE_6))
3703+
if (IS_ZIO_THRESHOLD_CAPABLE(ha))
37063704
qla27xx_set_zio_threshold(vha,
37073705
ha->last_zio_threshold);
37083706

drivers/scsi/qla2xxx/qla_iocb.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
594594
uint32_t dsd_list_len;
595595
struct dsd_dma *dsd_ptr;
596596
struct ct6_dsd *ctx;
597+
struct qla_qpair *qpair = sp->qpair;
597598

598599
cmd = GET_CMD_SP(sp);
599600

@@ -612,12 +613,12 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
612613
/* Set transfer direction */
613614
if (cmd->sc_data_direction == DMA_TO_DEVICE) {
614615
cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA);
615-
vha->qla_stats.output_bytes += scsi_bufflen(cmd);
616-
vha->qla_stats.output_requests++;
616+
qpair->counters.output_bytes += scsi_bufflen(cmd);
617+
qpair->counters.output_requests++;
617618
} else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
618619
cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA);
619-
vha->qla_stats.input_bytes += scsi_bufflen(cmd);
620-
vha->qla_stats.input_requests++;
620+
qpair->counters.input_bytes += scsi_bufflen(cmd);
621+
qpair->counters.input_requests++;
621622
}
622623

623624
cur_seg = scsi_sglist(cmd);
@@ -704,6 +705,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
704705
struct scsi_cmnd *cmd;
705706
struct scatterlist *sg;
706707
int i;
708+
struct qla_qpair *qpair = sp->qpair;
707709

708710
cmd = GET_CMD_SP(sp);
709711

@@ -721,12 +723,12 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
721723
/* Set transfer direction */
722724
if (cmd->sc_data_direction == DMA_TO_DEVICE) {
723725
cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_WRITE_DATA);
724-
vha->qla_stats.output_bytes += scsi_bufflen(cmd);
725-
vha->qla_stats.output_requests++;
726+
qpair->counters.output_bytes += scsi_bufflen(cmd);
727+
qpair->counters.output_requests++;
726728
} else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
727729
cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_READ_DATA);
728-
vha->qla_stats.input_bytes += scsi_bufflen(cmd);
729-
vha->qla_stats.input_requests++;
730+
qpair->counters.input_bytes += scsi_bufflen(cmd);
731+
qpair->counters.input_requests++;
730732
}
731733

732734
/* One DSD is available in the Command Type 3 IOCB */

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,8 +3440,10 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
34403440
if (!ha->flags.fw_started)
34413441
return;
34423442

3443-
if (rsp->qpair->cpuid != smp_processor_id())
3443+
if (rsp->qpair->cpuid != smp_processor_id() || !rsp->qpair->rcv_intr) {
3444+
rsp->qpair->rcv_intr = 1;
34443445
qla_cpu_update(rsp->qpair, smp_processor_id());
3446+
}
34453447

34463448
while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) {
34473449
pkt = (struct sts_entry_24xx *)rsp->ring_ptr;
@@ -3890,7 +3892,7 @@ qla2xxx_msix_rsp_q(int irq, void *dev_id)
38903892
}
38913893
ha = qpair->hw;
38923894

3893-
queue_work(ha->wq, &qpair->q_work);
3895+
queue_work_on(smp_processor_id(), ha->wq, &qpair->q_work);
38943896

38953897
return IRQ_HANDLED;
38963898
}
@@ -3916,7 +3918,7 @@ qla2xxx_msix_rsp_q_hs(int irq, void *dev_id)
39163918
wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_INT);
39173919
spin_unlock_irqrestore(&ha->hardware_lock, flags);
39183920

3919-
queue_work(ha->wq, &qpair->q_work);
3921+
queue_work_on(smp_processor_id(), ha->wq, &qpair->q_work);
39203922

39213923
return IRQ_HANDLED;
39223924
}

drivers/scsi/qla2xxx/qla_mid.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,9 @@ static void qla_do_work(struct work_struct *work)
808808
{
809809
unsigned long flags;
810810
struct qla_qpair *qpair = container_of(work, struct qla_qpair, q_work);
811-
struct scsi_qla_host *vha;
812-
struct qla_hw_data *ha = qpair->hw;
811+
struct scsi_qla_host *vha = qpair->vha;
813812

814813
spin_lock_irqsave(&qpair->qp_lock, flags);
815-
vha = pci_get_drvdata(ha->pdev);
816814
qla24xx_process_response_queue(vha, qpair->rsp);
817815
spin_unlock_irqrestore(&qpair->qp_lock, flags);
818816

drivers/scsi/qla2xxx/qla_nvme.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp)
428428
/* No data transfer how do we check buffer len == 0?? */
429429
if (fd->io_dir == NVMEFC_FCP_READ) {
430430
cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA);
431-
vha->qla_stats.input_bytes += fd->payload_length;
432-
vha->qla_stats.input_requests++;
431+
qpair->counters.input_bytes += fd->payload_length;
432+
qpair->counters.input_requests++;
433433
} else if (fd->io_dir == NVMEFC_FCP_WRITE) {
434434
cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA);
435435
if ((vha->flags.nvme_first_burst) &&
@@ -441,8 +441,8 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp)
441441
cmd_pkt->control_flags |=
442442
cpu_to_le16(CF_NVME_FIRST_BURST_ENABLE);
443443
}
444-
vha->qla_stats.output_bytes += fd->payload_length;
445-
vha->qla_stats.output_requests++;
444+
qpair->counters.output_bytes += fd->payload_length;
445+
qpair->counters.output_requests++;
446446
} else if (fd->io_dir == 0) {
447447
cmd_pkt->control_flags = 0;
448448
}

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7198,8 +7198,10 @@ qla2x00_timer(struct timer_list *t)
71987198
* FC-NVME
71997199
* see if the active AEN count has changed from what was last reported.
72007200
*/
7201+
index = atomic_read(&ha->nvme_active_aen_cnt);
72017202
if (!vha->vp_idx &&
7202-
(atomic_read(&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen) &&
7203+
(index != ha->nvme_last_rptd_aen) &&
7204+
(index >= DEFAULT_ZIO_THRESHOLD) &&
72037205
ha->zio_mode == QLA_ZIO_MODE_6 &&
72047206
!ha->flags.host_shutting_down) {
72057207
ql_log(ql_log_info, vha, 0x3002,
@@ -7211,9 +7213,8 @@ qla2x00_timer(struct timer_list *t)
72117213
}
72127214

72137215
if (!vha->vp_idx &&
7214-
(atomic_read(&ha->zio_threshold) != ha->last_zio_threshold) &&
7215-
(ha->zio_mode == QLA_ZIO_MODE_6) &&
7216-
(IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))) {
7216+
atomic_read(&ha->zio_threshold) != ha->last_zio_threshold &&
7217+
IS_ZIO_THRESHOLD_CAPABLE(ha)) {
72177218
ql_log(ql_log_info, vha, 0x3002,
72187219
"Sched: Set ZIO exchange threshold to %d.\n",
72197220
ha->last_zio_threshold);

0 commit comments

Comments
 (0)