From patchwork Wed Aug 30 17:16:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9930293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF8D060383 for ; Wed, 30 Aug 2017 17:17:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5FB228705 for ; Wed, 30 Aug 2017 17:17:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAE4228711; Wed, 30 Aug 2017 17:17:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480E028705 for ; Wed, 30 Aug 2017 17:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbdH3RRD (ORCPT ); Wed, 30 Aug 2017 13:17:03 -0400 Received: from mail-co1nam03on0054.outbound.protection.outlook.com ([104.47.40.54]:4311 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752089AbdH3RRC (ORCPT ); Wed, 30 Aug 2017 13:17:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=R+XMmgrpGLdaf5qs0bVvh6thY42RYTsZjMksT4i6nbA=; b=OI1np3hmQIKqnuIEnQh0BqSUI8IP2bmmtnZLbQDPH1dzTCbz4AB2RWhTm1Fkfgp60tD1NjSNoqsYZNxkn+LcslBSECV2gFCXjqapXyGFBXZEd2UOGtfC8auO5WTNw1AJz48z70aCkvl54WCKspRXtpwe2+42x++gAIDN/FOqlAc= Received: from SN1PR0701CA0045.namprd07.prod.outlook.com (10.163.126.13) by CO2PR07MB2517.namprd07.prod.outlook.com (10.166.200.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Wed, 30 Aug 2017 17:17:00 +0000 Received: from BY2FFO11FD004.protection.gbl (2a01:111:f400:7c0c::174) by SN1PR0701CA0045.outlook.office365.com (2a01:111:e400:52fd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10 via Frontend Transport; Wed, 30 Aug 2017 17:16:59 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2FFO11FD004.mail.protection.outlook.com (10.1.14.158) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1341.15 via Frontend Transport; Wed, 30 Aug 2017 17:16:59 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Wed, 30 Aug 2017 10:16:50 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id v7UHGpjA032384; Wed, 30 Aug 2017 10:16:51 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v7UHGoUe032383; Wed, 30 Aug 2017 10:16:50 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 2/3] qla2xxx: Fix slow mem alloc behind lock Date: Wed, 30 Aug 2017 10:16:49 -0700 Message-ID: <20170830171650.32341-3-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170830171650.32341-1-himanshu.madhani@cavium.com> References: <20170830171650.32341-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(2950100002)(42186005)(1076002)(80596001)(72206003)(356003)(5003940100001)(54906002)(50466002)(36756003)(101416001)(50226002)(50986999)(87636003)(81156014)(305945005)(81166006)(69596002)(8936002)(86362001)(33646002)(106466001)(478600001)(105586002)(2906002)(8676002)(5660300001)(48376002)(4326008)(76176999)(626005)(47776003)(189998001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB2517; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD004; 1:Ruo4mLJ4dlIYlWKGoPZEJ1wkCg9NK5jT/Jd41T7u0KvrIJ5t6ElHwUpkCgg5wkCIUJywD+xL+LqtnqYP0r/5FDY0XBFivAFaeyp7oYVnZYU5hK1Ruu1x3pthbXehX6NC X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9992a772-8088-4b9c-80f2-08d4efcaec9d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CO2PR07MB2517; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2517; 3:xtEO4igslKxF330z1m+UwXGqIP1A+4GAzeadnNdw7vQlht7TYJwAPYWObzN+b9Exvk0F3jaS/KKOKqYvKMdBxpPEZcZyO/w1Qp5Yjfh3ouHAuCFftWINa1qCg0dUkitBDf6DxLyCHMUaASShNxlIB0IWNqBHpEpI9jLEAkbxYDDK3nHl3hIzkCwKwVKqirVwny/NVnPcY39Bk2C4kUbleGU1ZmfrCXSsgbvA+O5J0Jm5BdZloRnyItMDiFJJcQki9MDnNAav9HQ7mBRcEfB+gyUHoE4jz+pHft9Cqf0C8IWnmz9W3sW3HzZ5Lo17YjxViLvjesOAAg/LWNQorYFf8g==; 25:ZNN7huQChGQZ8ZHhb7VLoG5yGWahecZ50dgs1b6gyNl9xXWpb1ARY6pD6tXiYxrfYX2AUwNdhT99S/l5uFiDFWoqSNXeexGbJtiXRlrZjcIMq4FG8SZoQRkLwn8fboSyo4OpDWZLem6jkuIlt82ls+rFS08GZEfulhetexQn5ANIaolEueUQxNVYyR7ytmf7sr8kv0nqS6Kg8km+HAOuZ5zUDEA9hGyOMWHf7fIWjlftMu9WjkNSld0qqUhWjvkrLHneYGkKK2arj8lmfukD0sIXD1R9Bn/3bLxDKWDhNL8X89/6kyawtslGf3RTweeOXMntLXyg4IIs980SbvHHeQ==; 31:Tjt7ZY2galX2tnWlb9mkfYQfX1asaJ2I2yJJ21QlPWcWiHLePJmiBrUETy8LI8KXjY0l4YCI1NvPAne6YEsvR0IbhusebYMhUbCCoJ2zK28VNlxWtTN1hPYEvKnamPDeeYKwYma30rfW2OYlyigk8dhXf8v2RsUAvb2pEQOfcgIITXCW1tCzmx9RyC1Csk5sMb4mSNay4FdNcC5Zy3nx5yTzPuq++QXAZ2EgR6Apiuc= X-MS-TrafficTypeDiagnostic: CO2PR07MB2517: X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2517; 20:zHrhXHtH2kbGjxD76PJ4UMSqjhG1V/10zfDVp/3acKpfB1pq4vyAvFGiZTJPVwzf4MydtOiSvTKKtfDP4BtarrsfnqjeJN+5Ln9mwIzeIaw2p8vqiy2TsB5eEPFQu+4goJdNaxcTFJmMvE3bYHPfsZjhAJ/udc6FaKK2rjIzdlcA4PlNNTgZYzjTYelkR1vvcE5pcQ07nmKYADueBh9D8TVSPJl45PpNXmb/RZT8weisuGT2cskcvzG6WF4swvb7KxyIQN37YdPcOq86oeVIjKc0L5uo0ulmfHElaEP/CHTxONivDGn37Ke1cwMM5GahiJnhdCJILAKiChSR3VF8JMSPDv/r1locV0prQtxyL3Uz4IO/cjJmphheRlnoPSUyh/LrFZvRur9tG77vGGsKJREC1NUZnk9YmtVWhrDOE/P861RXTsVLs9iyjyXDOHupzeuGJJu0KBgKs2qjaa1nLhcaniNVhAUA4Q/+bMV+6bNWb0ClzPCN8myc6NZpdwWK; 4:3RByAq580N4EbLlhtm1+XwfpFtzj4g5eU5Uw/vNKRQW/Y1VABCUjH7DBbPPk3r4MD4eHUPRNVlFTlFhjJlxJbIs1BdRlcspUsXzs91Yf8iVAOUFYFSEDzrDbVocu+IswElJXzq/D4RBzXIDWwtLxlF36R0Y++3EZx4t/v+MU2Dfl0NToU7dOKulhRlYE6LMzMBzXE7MoikjUuONBVq2FUBUNRXSIMpvBNW5iPTnbOte2XFZ2+HANdG2Sekt5ByDZ X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(13018025)(13016025)(8121501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CO2PR07MB2517; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CO2PR07MB2517; X-Forefront-PRVS: 041517DFAB X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2517; 23:D+scRW4g+vkmaV4PSWdQrWTMXsfLunZzIjP2XlR3ZZOQNhVlOIxFn9Va12ZSvsZ7LXLMHCbAY/EoHLuCVXyT2p4tcnZnua9K6ugKTboPWUrEt43iGxrCt/VqlpqriGAOSCXrNkHcRj35ZQto7QDH98zipSJz9ygFujiQc2Dt/ZSZ40BOhDg9GHEgk7hf3EY3WLANC+q5tHSeVFzIcA2nvK4XefbPfngnZMqBBmm9hrB2LAneWjXNU/qb67waOIrFMzoRq3DJAI5YUWDL2CBBSlAE9T8AKAO1Pwgl+cO3yGztZwKH4wh5JdCk9u6nX/3ON6k3p7TCwJA8qB6yBZsBH+Z2coFTowvOD/62CbX72oj+gDj+PcOAd+DJ2KCeqGxGQn6rbXD5EWpL3BdgZ1o+J0JV5RgDbfn17Kof3x0vgj16Q+cAk1r/AZ+cb1Zul+FSMFJCxxYbI5PVSuut0CaE0tT07BKe7Wl++JRJ6nKFbh00hBA7w/TG9CV5p/Qkdh6HxN3FnADw9L+iHePEKowWCZ7ml8zb7jryAafjiWl+gVHGym8/L+0XFG1dmtBvOl/O56Q3ZgfU4NhuN9As1pJokxYsJbyckxCBaxCpaumzaRlQHy2RrLeaE68ZSOKUMLQvtpkYcmXoECtEmLhIpD8yU9n3DeX56BQR72hdSqqXOEmxknyMiU8B465tP6RBNh778vDZKXr0AgcsWtK345fS+IxDrx1dOXiOdqBwD+g2SQreR2lG1OTUeGDboOP7AmFRposYOmWmbwgi5EZap4rKKtewO5jvmj1TCpqRRcxNLcyYha35GfovWzBWdRv4GllTzaXY968w5Bu8KYcLqH4zTWYVs+NZ4eK2gdur3YO2u8Z2+u5fsuY1/0PbkGckEaCUuogIU1D/cnbSvrGBUThiE5UFxnXnPEZHHZPdm0i9J 0j328t5zVMn6JOpx8BGrV+M X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2517; 6:Al9HYrJjA3BqEFqM9woOZF4LHYiAqydGBtX9nlI46EKbO0DtEaOytI7wRKc8Vd2X9Qk/pWYBmNxnq7R1S4uPacO77ic4g5hSJ1M5Zcj8V4nFAUUSwwbpScu6D2SJGZLVPzlNFmCDVDga/I0rJPbjhzr/VB63xsbwWSX8IlEZqGfic6X59Z58Y9dR9C4IdmjKxcspOM20CH7VGLYWZ6wxuLdH9PmpZK6wlI+jp5ttFt1GYQBofrRM1WxZMsDt24VjS9fdCopCZx4e8klx5e/SDJbmScmqMn6FJiCYYDXsoqWiPK3EjuOckjEpApFf+xQPA+NQkpycNiqeQRUjtKfWSA==; 5:gspOsJVc+ARkX3j4W57PN5DI7OUJQjeVHO05EbmeNHG/jTOloMK6f3tBLbSRboCqmJiFGuxtIYRGhb6jZ9wMcz5KhNdqSEhf3kbWr9o+DZ5Ww1WyTxU6PBHaQG2oNtdpiEAxiPCWUTD8IIckYtroOA==; 24:0M5dpd6faNTYLBuNDwyQLglewbsu/Yg8ozSHWQhfNM+1HCzqsvSLmQ15FCIUeB5j2IbxUZgpj6kokN+10FLOMOReihAAZBaACv9qqPyM8vo=; 7:U1NmVPW/6vifh6J7uK6okfV2FooI8a6lx+nlwYuzT5j7KDSsFw4tfQiOElkp9WCOjGYpeivNa8R2zyx7Zk+WM/2ZREUqhGurq9sgSvg65o4jsWURHwVwgzothSRhNY7ph6leTLSXAOP5ZmpshqL3YPPnFyAgxxUO5/lc9O3T4SVUcD2kEVsyel3zTnVjSneu2lq7EXKG9iIz2V1P+I89R8m797Hwobo4qRKdD11GKjM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2017 17:16:59.6231 (UTC) X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2517 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran Call Trace: [] dump_stack+0x6b/0xa4 [] ? print_irqtrace_events+0xd0/0xe0 [] ___might_sleep+0x183/0x240 [] __might_sleep+0x52/0x90 [] kmem_cache_alloc_trace+0x5b/0x300 [] ? __lock_acquired+0x30b/0x420 [] qla2x00_alloc_fcport+0x38/0x2a0 [qla2xxx] [] ? qla2x00_do_work+0x34/0x2b0 [qla2xxx] [] ? _raw_spin_lock_irqsave+0x7b/0x90 [] ? qla24xx_create_new_sess+0x3a/0x160 [qla2xxx] [] qla24xx_create_new_sess+0xc3/0x160 [qla2xxx] [] ? trace_hardirqs_on+0xd/0x10 [] qla2x00_do_work+0x138/0x2b0 [qla2xxx] Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_gbl.h | 1 + drivers/scsi/qla2xxx/qla_os.c | 33 ++++++++++++++++++++++++++++++++- drivers/scsi/qla2xxx/qla_target.c | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 0b219b3ca653..f852ca60c49f 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -113,6 +113,7 @@ int qla24xx_post_gpdb_work(struct scsi_qla_host *, fc_port_t *, u8); extern char qla2x00_version_str[]; extern struct kmem_cache *srb_cachep; +extern struct kmem_cache *qla_tgt_plogi_cachep; extern int ql2xlogintimeout; extern int qlport_down_retry; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 56bd086b79ea..5b2437a5ea44 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4677,9 +4677,10 @@ static void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) { unsigned long flags; - fc_port_t *fcport = NULL; + fc_port_t *fcport = NULL, *tfcp; struct qlt_plogi_ack_t *pla = (struct qlt_plogi_ack_t *)e->u.new_sess.pla; + uint8_t free_fcport = 0; spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1); @@ -4694,6 +4695,7 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) pla->ref_count--; } } else { + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); if (fcport) { fcport->d_id = e->u.new_sess.id; @@ -4703,6 +4705,29 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) memcpy(fcport->port_name, e->u.new_sess.port_name, WWN_SIZE); + } else { + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s %8phC mem alloc fail.\n", + __func__, e->u.new_sess.port_name); + + if (pla) + kmem_cache_free(qla_tgt_plogi_cachep, pla); + return; + } + + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); + /* search again to make sure one else got ahead */ + tfcp = qla2x00_find_fcport_by_wwpn(vha, + e->u.new_sess.port_name, 1); + if (tfcp) { + /* should rarily happen */ + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s %8phC found existing fcport b4 add. DS %d LS %d\n", + __func__, tfcp->port_name, tfcp->disc_state, + tfcp->fw_login_state); + + free_fcport = 1; + } else { list_add_tail(&fcport->list, &vha->vp_fcports); if (pla) { @@ -4720,6 +4745,12 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) else qla24xx_async_gnl(vha, fcport); } + + if (free_fcport) { + qla2x00_free_fcport(fcport); + if (pla) + kmem_cache_free(qla_tgt_plogi_cachep, pla); + } } void diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 43113d52893b..192554b1536f 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -145,7 +145,7 @@ static void qlt_send_busy(struct qla_qpair *, struct atio_from_isp *, * Global Variables */ static struct kmem_cache *qla_tgt_mgmt_cmd_cachep; -static struct kmem_cache *qla_tgt_plogi_cachep; +struct kmem_cache *qla_tgt_plogi_cachep; static mempool_t *qla_tgt_mgmt_cmd_mempool; static struct workqueue_struct *qla_tgt_wq; static DEFINE_MUTEX(qla_tgt_mutex);