From patchwork Mon Nov 18 10:31:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11249299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD1E6930 for ; Mon, 18 Nov 2019 10:31:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1BBA20730 for ; Mon, 18 Nov 2019 10:31:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XhdwF3Mv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbfKRKbw (ORCPT ); Mon, 18 Nov 2019 05:31:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50122 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726518AbfKRKbw (ORCPT ); Mon, 18 Nov 2019 05:31:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574073110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kQGaSPSMYZf0wTy4mSjYgqZcEjcQZsd+fMlyCkP8oTA=; b=XhdwF3MvMaOJZcLcwwnWUCulR72OjbamI5440PD0DBqrCk09d1CB3gIFwlgBxpwYg6t6Y6 lBUeo3q/IVJQ8SYBAWI8huCWhQhpv9ltsApY4yD2wKRlWp2BifVMhKCyg3lW6hBdd1SNL9 ylsWmUV3Bueh90BtALcxsyFatCdLFCE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-YV0MO35nMzaGbPBoC5Cesw-1; Mon, 18 Nov 2019 05:31:46 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CF5F801FD2; Mon, 18 Nov 2019 10:31:42 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id F37A519C6A; Mon, 18 Nov 2019 10:31:38 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Christoph Hellwig , Hannes Reinecke , Bart Van Assche Subject: [PATCH 2/4] scsi: mpt3sas: use private counter for tracking inflight per-LUN commands Date: Mon, 18 Nov 2019 18:31:15 +0800 Message-Id: <20191118103117.978-3-ming.lei@redhat.com> In-Reply-To: <20191118103117.978-1-ming.lei@redhat.com> References: <20191118103117.978-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: YV0MO35nMzaGbPBoC5Cesw-1 X-Mimecast-Spam-Score: 0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Prepare for bypassing sdev->device_busy for improving performance on fast SCSI storage device, so sdev->device_busy can't be relied any more. mpt3sas may need one such counter for balancing load among LUNs in some specific setting, so add one private counter for this purpose. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Christoph Hellwig , Cc: Hannes Reinecke Cc: Bart Van Assche Signed-off-by: Ming Lei Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.c | 3 ++- drivers/scsi/mpt3sas/mpt3sas_base.h | 1 + drivers/scsi/mpt3sas/mpt3sas_scsih.c | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index fea3cb6a090b..9c2d374b3157 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3480,12 +3480,13 @@ static inline u8 _base_get_high_iops_msix_index(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd) { + struct MPT3SAS_DEVICE *sas_device_priv_data = scmd->device->hostdata; /** * Round robin the IO interrupts among the high iops * reply queues in terms of batch count 16 when outstanding * IOs on the target device is >=8. */ - if (atomic_read(&scmd->device->device_busy) > + if (atomic_read(&sas_device_priv_data->active_cmds) > MPT3SAS_DEVICE_HIGH_IOPS_DEPTH) return base_mod64(( atomic64_add_return(1, &ioc->high_iops_outstanding) / diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index faca0a5e71f8..9e9f319bb636 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -467,6 +467,7 @@ struct MPT3SAS_DEVICE { * thing while a SATL command is pending. */ unsigned long ata_command_pending; + atomic_t active_cmds; }; diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index c8e512ba6d39..194960dae1d6 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1770,6 +1770,7 @@ scsih_slave_alloc(struct scsi_device *sdev) sas_device_priv_data->lun = sdev->lun; sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; + atomic_set(&sas_device_priv_data->active_cmds, 0); starget = scsi_target(sdev); sas_target_priv_data = starget->hostdata; @@ -2884,6 +2885,7 @@ scsih_abort(struct scsi_cmnd *scmd) ioc->remove_host) { sdev_printk(KERN_INFO, scmd->device, "device been deleted! scmd(%p)\n", scmd); + atomic_dec(&sas_device_priv_data->active_cmds); scmd->result = DID_NO_CONNECT << 16; scmd->scsi_done(scmd); r = SUCCESS; @@ -2993,7 +2995,7 @@ scsih_dev_reset(struct scsi_cmnd *scmd) MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0, tr_timeout, tr_method); /* Check for busy commands after reset */ - if (r == SUCCESS && atomic_read(&scmd->device->device_busy)) + if (r == SUCCESS && atomic_read(&sas_device_priv_data->active_cmds)) r = FAILED; out: sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(%p)\n", @@ -4517,9 +4519,12 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc) int count = 0; for (smid = 1; smid <= ioc->scsiio_depth; smid++) { + struct MPT3SAS_DEVICE *sas_device_priv_data; + scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid); if (!scmd) continue; + sas_device_priv_data = scmd->device->hostdata; count++; _scsih_set_satl_pending(scmd, false); st = scsi_cmd_priv(scmd); @@ -4529,6 +4534,7 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc) scmd->result = DID_NO_CONNECT << 16; else scmd->result = DID_RESET << 16; + atomic_dec(&sas_device_priv_data->active_cmds); scmd->scsi_done(scmd); } dtmprintk(ioc, ioc_info(ioc, "completing %d cmds\n", count)); @@ -4756,11 +4762,14 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) mpi_request->LUN); memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); + atomic_inc(&sas_device_priv_data->active_cmds); + if (mpi_request->DataLength) { pcie_device = sas_target_priv_data->pcie_dev; if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { mpt3sas_base_free_smid(ioc, smid); _scsih_set_satl_pending(scmd, false); + atomic_dec(&sas_device_priv_data->active_cmds); goto out; } } else @@ -5207,6 +5216,7 @@ _scsih_smart_predicted_fault(struct MPT3SAS_ADAPTER *ioc, u16 handle) static u8 _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) { + struct MPT3SAS_DEVICE *sas_device_priv_data; Mpi25SCSIIORequest_t *mpi_request; Mpi2SCSIIOReply_t *mpi_reply; struct scsi_cmnd *scmd; @@ -5216,7 +5226,6 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) u8 scsi_state; u8 scsi_status; u32 log_info; - struct MPT3SAS_DEVICE *sas_device_priv_data; u32 response_code = 0; mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply); @@ -5225,6 +5234,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) if (scmd == NULL) return 1; + sas_device_priv_data = scmd->device->hostdata; _scsih_set_satl_pending(scmd, false); mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); @@ -5431,6 +5441,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) scsi_dma_unmap(scmd); mpt3sas_base_free_smid(ioc, smid); + atomic_dec(&sas_device_priv_data->active_cmds); scmd->scsi_done(scmd); return 0; }