linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	James Smart <james.smart@broadcom.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
	Hannes Reinecke <hare@suse.com>
Subject: [PATCH 03/14] lpfc: Add config option 'lpfc_enable_stats'
Date: Thu,  2 Jun 2016 16:39:05 +0200	[thread overview]
Message-ID: <1464878356-42407-4-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1464878356-42407-1-git-send-email-hare@suse.de>

Add a module option lpfc_enable_stats to enable or disable
HBA statistics. Gathering statistics is done in the hot path
during lpfc_scsi_cmd_iocb_cmpl() and require the host_lock,
so disabling them increases the overall performance.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/lpfc/lpfc.h      |  1 +
 drivers/scsi/lpfc/lpfc_attr.c | 10 ++++++++++
 drivers/scsi/lpfc/lpfc_scsi.c | 21 +++++++++------------
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index d5bd420..bb53b81 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -759,6 +759,7 @@ struct lpfc_hba {
 #define LPFC_FDMI_NO_SUPPORT	0	/* FDMI not supported */
 #define LPFC_FDMI_SUPPORT	1	/* FDMI supported? */
 	uint32_t cfg_enable_SmartSAN;
+	uint32_t cfg_enable_stats;
 	lpfc_vpd_t vpd;		/* vital product data */
 
 	struct pci_dev *pcidev;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index cfec2ec..241bbd6 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -4697,6 +4697,14 @@ LPFC_ATTR_RW(XLanePriority, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature.");
 LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
 
 /*
+# lpfc_enable_stats:  Enable HBA statistics
+#       0  = HBA statistics disabled
+#       1  = HBA statistics enabled (default)
+# Value range is [0,1]. Default value is 1
+*/
+LPFC_ATTR_RW(enable_stats, 1, 0, 1, "Enable HBA statistics.");
+
+/*
 # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine
 #       0  = disabled (default)
 #       1  = enabled
@@ -4876,6 +4884,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
 	&dev_attr_lpfc_sriov_hw_max_virtfn,
 	&dev_attr_protocol,
 	&dev_attr_lpfc_xlane_supported,
+	&dev_attr_lpfc_enable_stats,
 	NULL,
 };
 
@@ -5866,6 +5875,7 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
 	lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade);
 	lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up);
 	lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt);
+	lpfc_enable_stats_init(phba, lpfc_enable_stats);
 	phba->cfg_enable_dss = 1;
 	return;
 }
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 3bd0be6..fde5b00 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -195,31 +195,24 @@ lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
  *
  * This function is called when there is a command completion and this
  * function updates the statistical data for the command completion.
+ * Needs to be called under shost->host_lock.
  **/
 static void
-lpfc_update_stats(struct lpfc_hba *phba, struct  lpfc_scsi_buf *lpfc_cmd)
+lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_vport *vport,
+		  struct lpfc_scsi_buf *lpfc_cmd)
 {
 	struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
 	struct lpfc_nodelist *pnode = rdata->pnode;
-	struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
-	unsigned long flags;
-	struct Scsi_Host  *shost = cmd->device->host;
-	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
 	unsigned long latency;
 	int i;
 
-	if (cmd->result)
-		return;
-
 	latency = jiffies_to_msecs((long)jiffies - (long)lpfc_cmd->start_time);
 
-	spin_lock_irqsave(shost->host_lock, flags);
 	if (!vport->stat_data_enabled ||
 		vport->stat_data_blocked ||
 		!pnode ||
 		!pnode->lat_data ||
 		(phba->bucket_type == LPFC_NO_BUCKET)) {
-		spin_unlock_irqrestore(shost->host_lock, flags);
 		return;
 	}
 
@@ -239,7 +232,6 @@ lpfc_update_stats(struct lpfc_hba *phba, struct  lpfc_scsi_buf *lpfc_cmd)
 	}
 
 	pnode->lat_data[i].cmd_count++;
-	spin_unlock_irqrestore(shost->host_lock, flags);
 }
 
 /**
@@ -4100,7 +4092,12 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
 				 scsi_get_resid(cmd));
 	}
 
-	lpfc_update_stats(phba, lpfc_cmd);
+	if (!cmd->result && phba->cfg_enable_stats) {
+		spin_lock_irqsave(shost->host_lock, flags);
+		lpfc_update_stats(phba, vport, lpfc_cmd);
+		spin_unlock_irqrestore(shost->host_lock, flags);
+	}
+
 	if (vport->cfg_max_scsicmpl_time &&
 	   time_after(jiffies, lpfc_cmd->start_time +
 		msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) {
-- 
1.8.5.6


  parent reply	other threads:[~2016-06-02 14:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 14:39 [PATCH 00/14] lpfc multiqueue performance fixes Hannes Reinecke
2016-06-02 14:39 ` [PATCH 01/14] block: don't check request size in blk_cloned_rq_check_limits() Hannes Reinecke
2016-06-02 14:39 ` [PATCH 02/14] lpfc: remove unused 'pring' argument Hannes Reinecke
2016-06-02 14:39 ` Hannes Reinecke [this message]
2016-06-02 14:39 ` [PATCH 04/14] scsi: add 'abort_completions' host template flag Hannes Reinecke
2016-06-02 14:39 ` [PATCH 05/14] lpfc: do not wait for completion when aborting commands Hannes Reinecke
2016-06-02 14:39 ` [PATCH 06/14] lpfc: display manual queue assignment Hannes Reinecke
2016-06-02 14:39 ` [PATCH 07/14] scsi: modify can_queue after calling mq_allocate() Hannes Reinecke
2016-06-02 14:39 ` [PATCH 08/14] blk-mq: add blk_mq_resize_tag_set() Hannes Reinecke
2016-06-02 15:55   ` Bart Van Assche
2016-06-02 14:39 ` [PATCH 09/14] scsi: Implement scsi_mq_resize_tags() Hannes Reinecke
2016-06-02 15:58   ` Bart Van Assche
2016-06-02 14:39 ` [PATCH 10/14] lpfc: use bitflag for exch_busy Hannes Reinecke
2016-06-02 14:39 ` [PATCH 11/14] lpfc: set LPFC_CMD_ABORTED when a command is put on the aborted list Hannes Reinecke
2016-06-02 14:39 ` [PATCH 12/14] lpfc: move to array based command allocation for SLI-4 Hannes Reinecke
2016-06-02 14:39 ` [PATCH 13/14] lpfc: LPFC_CMD_RRQ_ACTIVE flag to mark commands Hannes Reinecke
2016-06-02 14:39 ` [PATCH 14/14] lpfc: Complete scsi commands after RRQ has completed Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464878356-42407-4-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=dick.kennedy@broadcom.com \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=james.smart@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).