From patchwork Mon Nov 18 10:31:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11249297 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 16BAB14C0 for ; Mon, 18 Nov 2019 10:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB9BF20855 for ; Mon, 18 Nov 2019 10:31:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NHh2PD3C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbfKRKbp (ORCPT ); Mon, 18 Nov 2019 05:31:45 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:23797 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726518AbfKRKbo (ORCPT ); Mon, 18 Nov 2019 05:31:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574073102; 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=QBUQpEvhUSGPyW0TNCDWONDd8thoA0ntji5C32j1HOM=; b=NHh2PD3CxryF93hocFfzs/VRO6KJRMJTq5aGqD5tbK7iRfuiheI7fJLiirZqjZgHLyfoja OBsP97Hfp/MhCZdnB5vNSKOTrbQlwQJ77ITxF41NWgJBtxLe6hu7nILCQ3EtVFaMgsihGa oO4cprw0jKegIdB/12K/5hjLIDT24Hs= 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-207-R0u2oME6PaG-zSQCmkh7eQ-1; Mon, 18 Nov 2019 05:31:39 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C7AD1802CE0; Mon, 18 Nov 2019 10:31:36 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 013D4600CD; Mon, 18 Nov 2019 10:31:32 +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 1/4] scsi: megaraid_sas: use private counter for tracking inflight per-LUN commands Date: Mon, 18 Nov 2019 18:31:14 +0800 Message-Id: <20191118103117.978-2-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.79 on 10.5.11.11 X-MC-Unique: R0u2oME6PaG-zSQCmkh7eQ-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. megaraid_sas 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/megaraid/megaraid_sas.h | 1 + drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++++++++++++-- drivers/scsi/megaraid/megaraid_sas_fusion.c | 13 +++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index a6e788c02ff4..f9562c02705b 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -2025,6 +2025,7 @@ struct MR_PRIV_DEVICE { u8 interface_type; u8 task_abort_tmo; u8 target_reset_tmo; + atomic_t active_cmds; }; struct megasas_cmd; diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 42cf38c1ea99..3afead3bc96e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1759,6 +1759,7 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) { struct megasas_instance *instance; struct MR_PRIV_DEVICE *mr_device_priv_data; + int ret; instance = (struct megasas_instance *) scmd->device->host->hostdata; @@ -1821,7 +1822,11 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) goto out_done; } - return instance->instancet->build_and_issue_cmd(instance, scmd); + atomic_inc(&mr_device_priv_data->active_cmds); + ret = instance->instancet->build_and_issue_cmd(instance, scmd); + if (ret) + atomic_dec(&mr_device_priv_data->active_cmds); + return ret; out_done: scmd->scsi_done(scmd); @@ -2100,6 +2105,7 @@ static int megasas_slave_alloc(struct scsi_device *sdev) atomic_set(&mr_device_priv_data->r1_ldio_hint, instance->r1_ldio_hint_default); + atomic_set(&mr_device_priv_data->active_cmds, 0); return 0; } @@ -3475,12 +3481,15 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, unsigned long flags; struct fusion_context *fusion = instance->ctrl_context; u32 opcode, status; + struct MR_PRIV_DEVICE *mr_device_priv_data = NULL; /* flag for the retry reset */ cmd->retry_for_fw_reset = 0; - if (cmd->scmd) + if (cmd->scmd) { cmd->scmd->SCp.ptr = NULL; + mr_device_priv_data = cmd->scmd->device->hostdata; + } switch (hdr->cmd) { case MFI_CMD_INVALID: @@ -3519,6 +3528,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, if (exception) { atomic_dec(&instance->fw_outstanding); + atomic_dec(&mr_device_priv_data->active_cmds); scsi_dma_unmap(cmd->scmd); cmd->scmd->scsi_done(cmd->scmd); @@ -3567,6 +3577,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, } atomic_dec(&instance->fw_outstanding); + atomic_dec(&mr_device_priv_data->active_cmds); scsi_dma_unmap(cmd->scmd); cmd->scmd->scsi_done(cmd->scmd); diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index e301458bcbae..10ed3bc3b643 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -2728,7 +2728,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, u8 *raidLUN; unsigned long spinlock_flags; struct MR_LD_RAID *raid = NULL; - struct MR_PRIV_DEVICE *mrdev_priv; + struct MR_PRIV_DEVICE *mrdev_priv = scp->device->hostdata; struct RAID_CONTEXT *rctx; struct RAID_CONTEXT_G35 *rctx_g35; @@ -2826,7 +2826,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, } if ((instance->perf_mode == MR_BALANCED_PERF_MODE) && - atomic_read(&scp->device->device_busy) > + atomic_read(&mrdev_priv->active_cmds) > (io_info.data_arms * MR_DEVICE_HIGH_IOPS_DEPTH)) cmd->request_desc->SCSIIO.MSIxIndex = mega_mod64((atomic64_add_return(1, &instance->high_iops_outstanding) / @@ -2849,7 +2849,6 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, * with the SLD bit asserted. */ if (io_info.r1_alt_dev_handle != MR_DEVHANDLE_INVALID) { - mrdev_priv = scp->device->hostdata; if (atomic_inc_return(&instance->fw_outstanding) > (instance->host->can_queue)) { @@ -3159,7 +3158,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance, cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle; if ((instance->perf_mode == MR_BALANCED_PERF_MODE) && - atomic_read(&scmd->device->device_busy) > MR_DEVICE_HIGH_IOPS_DEPTH) + atomic_read(&mr_device_priv_data->active_cmds) > MR_DEVICE_HIGH_IOPS_DEPTH) cmd->request_desc->SCSIIO.MSIxIndex = mega_mod64((atomic64_add_return(1, &instance->high_iops_outstanding) / MR_HIGH_IOPS_BATCH_COUNT), instance->low_latency_index_start); @@ -3550,6 +3549,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, while (d_val.u.low != cpu_to_le32(UINT_MAX) && d_val.u.high != cpu_to_le32(UINT_MAX)) { + struct MR_PRIV_DEVICE *mr_device_priv_data = NULL; smid = le16_to_cpu(reply_desc->SMID); cmd_fusion = fusion->cmd_list[smid - 1]; @@ -3585,6 +3585,8 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, } /* Fall through - and complete IO */ case MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST: /* LD-IO Path */ + mr_device_priv_data = scmd_local->device->hostdata; + atomic_dec(&mr_device_priv_data->active_cmds); atomic_dec(&instance->fw_outstanding); if (cmd_fusion->r1_alt_dev_handle == MR_DEVHANDLE_INVALID) { map_cmd_status(fusion, scmd_local, status, @@ -4865,6 +4867,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) /* Now return commands back to the OS */ for (i = 0 ; i < instance->max_scsi_cmds; i++) { + struct MR_PRIV_DEVICE *mr_device_priv_data = NULL; cmd_fusion = fusion->cmd_list[i]; /*check for extra commands issued by driver*/ if (instance->adapter_type >= VENTURA_SERIES) { @@ -4893,6 +4896,8 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) megasas_return_cmd_fusion(instance, cmd_fusion); scsi_dma_unmap(scmd_local); scmd_local->scsi_done(scmd_local); + mr_device_priv_data = scmd_local->device->hostdata; + atomic_dec(&mr_device_priv_data->active_cmds); } }