Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp839256lqe; Sun, 7 Apr 2024 06:24:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuSE0h/+PyLExpQlXZ+mCfMRRVh/vijmLMbhlDjHJQgEZhHUk/pCuVE1BH1ooM9Yw+rYgA2rRjK3uK1JYeHzs8Effn8dLc0wFVjxtnzA== X-Google-Smtp-Source: AGHT+IHIqkRYHPmEqC7OCoxAlIDe3SBpOXgI56TVDu3Ru9jAx8us+Kv4FTNiC27PnOZIK6f9Z9d2 X-Received: by 2002:a17:906:ecb6:b0:a50:4ade:b414 with SMTP id qh22-20020a170906ecb600b00a504adeb414mr4572410ejb.3.1712496291357; Sun, 07 Apr 2024 06:24:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712496291; cv=pass; d=google.com; s=arc-20160816; b=sTpqkGKfMSNd8CnKpOfDff2Vt+RtwlGRr1xL+1BNV6ZuUvDas0z5Js0/Ye3TuYz3/i Z+8lFBC3SXbilruGp30t3X7cBG3X+dWLrySl8E83e2lbk8w6QEqIejfhlZXkSgAta/TD rki45BAxL+rRIBfvcaJUPSLkQncINOSni4Q3xc2RRil0LrGbGVsjEzru3uk79KeyMjJH nxcFrbU7oojBrKVB47uBIGrp6YmvGev4L7maafBhOOaJmiroDDnlo0f6nujWlz77AIzW O0a0eaDlblmXlmqF6lMhUc8Or9b4cxW1L6UoszLO1iyn0+ZmZAgFZjklrszDU9YapOko /BgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Z9qVBuHIAzi3KsBgjP9A2fAIgVw58MVGc2d4nkl2YyE=; fh=oPkVWPhE12BMK+pwlJxHuiMmWHHXnalyKV7QdFfBV30=; b=rLAF2xp19StaMGKwva7LktP9jViWshECI3Aj2f9yY41lUHvG5v7gFAN4QtEtOWRD78 OMp2wPfQdJ8h1XQgp5iHp0ZHaw/monk42Bc3xUvT9snqm5dryCeo1vxeMn30WkXI9xpA RgQ7b3vLpo2XRTsqv/c1QYJ8D25Qe/SbKHvxf7A6DFUaBdAreqoITKT8cpQH8XmpCyOk aCEMcWW3Qa5o35LvN/PyL1ilVzSJEJWSRLZePOcK6A4MnA1HUDQ9D9F3lQmXwEr41qFq r/YTQQb8CwfmtvrqneeGTubgHp7Cj5CXSIZiN87V6Hh3iPsVK1/d9YmyzJ2YuvyVKHoe 23CA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Gw6d/Be7"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f8-20020a170906084800b00a518cad5f66si2663124ejd.597.2024.04.07.06.24.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 06:24:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Gw6d/Be7"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1C62F1F211C1 for ; Sun, 7 Apr 2024 13:24:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0B787D07F; Sun, 7 Apr 2024 13:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gw6d/Be7" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D9F67CF0F; Sun, 7 Apr 2024 13:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712495558; cv=none; b=D0v2M6aQdQET897pfCAsmuXLgFH2+9hKelTWQGb2sRbrR+DW9Dawy3gqL/94Hr5zv9F3PIfTkBe6VPGDu5ZxTsa2UDcIuAuthbDoV2KTLXTxdr7+YVj5AkaLKUo/vx4zU8Ni8cm9QYHx2SMIIiYIXvzFPLe/7j00ejVbmGO4jEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712495558; c=relaxed/simple; bh=Z3qs+jVDzbjy4F6F96Y6axrHvOpYUWjFxpb0JRDg0ro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qwG5e1q4RJBDw2VuyMFF0+pvJi/YZWfpve1JiiA+ZcWoVsoDDVZh2aHR1fqM8dD/FW70NMP1y9GIlN2ywJ8cymXUnZ4V+Cjd1PxZP3kPCFvx8HokAQhEOaWnEZA5vlwSVZP/ZuFt2Wl7LsiCXmy0QTS7NF9xipcX4fbN0DOzlVs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gw6d/Be7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B223EC433C7; Sun, 7 Apr 2024 13:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712495557; bh=Z3qs+jVDzbjy4F6F96Y6axrHvOpYUWjFxpb0JRDg0ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gw6d/Be74ICTobznPPdSWCa01iQT2EJC+pwHJ2ejahXA2TH9avRluFfhEr4+gRIN0 saVFJc2nmwtI1kcguU5v85KeMMoPAraH/8UA8f2lt3Sf5QKaZOJMD4bgEk9GfBnbQ5 5kxt2JPjzO4oDZpnaMgg0pM0fawiiszgJDahYeaXopbvKNT43eAuG89A9qfpM2sXji qwvJmhsEx1s1hZ9kvXTDgWJq+DsbDhlZrozCcWZHJjxAbZhEId0bmxzT77Uf7D7wVa cNRTmJGYu7T7rPzRLe5/MWywWqGHI8msyofGiiYEwRpP3ITgav4CJDT6bdNCMuHWc9 NdUPikGzl5ONQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Justin Tee , "Martin K . Petersen" , Sasha Levin , james.smart@broadcom.com, dick.kennedy@broadcom.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 04/22] scsi: lpfc: Update lpfc_ramp_down_queue_handler() logic Date: Sun, 7 Apr 2024 09:12:03 -0400 Message-ID: <20240407131231.1051652-4-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240407131231.1051652-1-sashal@kernel.org> References: <20240407131231.1051652-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.25 Content-Transfer-Encoding: 8bit From: Justin Tee [ Upstream commit bb011631435c705cdeddca68d5c85fd40a4320f9 ] Typically when an out of resource CQE status is detected, the lpfc_ramp_down_queue_handler() logic is called to help reduce I/O load by reducing an sdev's queue_depth. However, the current lpfc_rampdown_queue_depth() logic does not help reduce queue_depth. num_cmd_success is never updated and is always zero, which means new_queue_depth will always be set to sdev->queue_depth. So, new_queue_depth = sdev->queue_depth - new_queue_depth always sets new_queue_depth to zero. And, scsi_change_queue_depth(sdev, 0) is essentially a no-op. Change the lpfc_ramp_down_queue_handler() logic to set new_queue_depth equal to sdev->queue_depth subtracted from number of times num_rsrc_err was incremented. If num_rsrc_err is >= sdev->queue_depth, then set new_queue_depth equal to 1. Eventually, the frequency of Good_Status frames will signal SCSI upper layer to auto increase the queue_depth back to the driver default of 64 via scsi_handle_queue_ramp_up(). Signed-off-by: Justin Tee Link: https://lore.kernel.org/r/20240305200503.57317-5-justintee8345@gmail.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc.h | 1 - drivers/scsi/lpfc/lpfc_scsi.c | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 04d608ea91060..be016732ab2ea 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -1325,7 +1325,6 @@ struct lpfc_hba { struct timer_list fabric_block_timer; unsigned long bit_flags; atomic_t num_rsrc_err; - atomic_t num_cmd_success; unsigned long last_rsrc_error_time; unsigned long last_ramp_down_time; #ifdef CONFIG_SCSI_LPFC_DEBUG_FS diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index bf879d81846b6..cf506556f3b0b 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -167,11 +167,10 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) struct Scsi_Host *shost; struct scsi_device *sdev; unsigned long new_queue_depth; - unsigned long num_rsrc_err, num_cmd_success; + unsigned long num_rsrc_err; int i; num_rsrc_err = atomic_read(&phba->num_rsrc_err); - num_cmd_success = atomic_read(&phba->num_cmd_success); /* * The error and success command counters are global per @@ -186,20 +185,16 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { shost = lpfc_shost_from_vport(vports[i]); shost_for_each_device(sdev, shost) { - new_queue_depth = - sdev->queue_depth * num_rsrc_err / - (num_rsrc_err + num_cmd_success); - if (!new_queue_depth) - new_queue_depth = sdev->queue_depth - 1; + if (num_rsrc_err >= sdev->queue_depth) + new_queue_depth = 1; else new_queue_depth = sdev->queue_depth - - new_queue_depth; + num_rsrc_err; scsi_change_queue_depth(sdev, new_queue_depth); } } lpfc_destroy_vport_work_array(phba, vports); atomic_set(&phba->num_rsrc_err, 0); - atomic_set(&phba->num_cmd_success, 0); } /** -- 2.43.0