From patchwork Thu Feb 11 19:08:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 8284641 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A483E9F38B for ; Thu, 11 Feb 2016 19:08:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91AE2202FE for ; Thu, 11 Feb 2016 19:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 374F820121 for ; Thu, 11 Feb 2016 19:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751025AbcBKTIl (ORCPT ); Thu, 11 Feb 2016 14:08:41 -0500 Received: from mail-by2on0073.outbound.protection.outlook.com ([207.46.100.73]:28000 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750796AbcBKTIi (ORCPT ); Thu, 11 Feb 2016 14:08:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bPCIW3izpzIp9X4/PtzBwSXKXOHKUquHrm1AHw1FprY=; b=vre1M5Wdh7iY4Ro/zWltdzACyzFj+bYiZHpCKl7Fm8ehLnv7PMAO5v4J9j29VdzV3S5fYsavypqv5B+69nRP5bFvnpdJA47qlIq5q22wbn0qmEoieQa4ouvgCb1F492nIQK2AnnxRrfbzVHzLg8vDUWv0RCH55e73MHjh7Kx2iU= Received: from BY2PR02CA0078.namprd02.prod.outlook.com (10.242.32.36) by BL2PR02MB289.namprd02.prod.outlook.com (10.141.90.143) with Microsoft SMTP Server (TLS) id 15.1.403.16; Thu, 11 Feb 2016 19:08:36 +0000 Received: from BL2FFO11OLC005.protection.gbl (2a01:111:f400:7c09::129) by BY2PR02CA0078.outlook.office365.com (2a01:111:e400:2c2a::36) with Microsoft SMTP Server (TLS) id 15.1.403.16 via Frontend Transport; Thu, 11 Feb 2016 19:08:36 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.174) smtp.mailfrom=sandisk.com; mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.174 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.174; helo=milsmgep12.sandisk.com; Received: from milsmgep12.sandisk.com (63.163.107.174) by BL2FFO11OLC005.mail.protection.outlook.com (10.173.160.91) with Microsoft SMTP Server id 15.1.415.6 via Frontend Transport; Thu, 11 Feb 2016 19:08:35 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by (Symantec Messaging Gateway) with SMTP id 92.4E.03682.23CDCB65; Thu, 11 Feb 2016 11:08:34 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.248.2; Thu, 11 Feb 2016 11:08:34 -0800 X-AuditID: ac160a69-d23ff70000000e62-26-56bcdc32879c Received: from [10.60.52.49] ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id B4.93.03361.23CDCB65; Thu, 11 Feb 2016 11:08:34 -0800 (PST) Subject: [PATCH v4 16/21] IB/srpt: Use a mutex to protect the channel list To: Doug Ledford References: <56BCDAAD.7030906@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , "Alex Estrin" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <56BCDC32.6000209@sandisk.com> Date: Thu, 11 Feb 2016 11:08:34 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56BCDAAD.7030906@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRmVeSWpSXmKPExsWyRoxnka7RnT1hBs9um1lcePqdyeLl+Q+s FitXH2WyeHaol8XiRtsDNgdWj8V7XjJ57L7ZwObxbPphJo/3+66yeXzeJBfAGsVlk5Kak1mW WqRvl8CVcfLIJfaCW5oVK7Z+Zm5gvKzUxcjJISFgIrHlykaWLkYuDiGBTYwSDT2tzBDODkaJ 4/c7GWGqWl+3s0Mk5jBKfH9yDywhLOAlMevBEjYQW0RATWLTq0XsILaQgJbE8/5+VpAGZoFV jBKbrl4HS7AJGEl8ez+TBcTmBSqa9/cTK4jNIqAqceH8KSYQW1QgQuJwZxc7RI2gxMmZT4Dq OTg4BbQlZl6JADGZBTQl1u/SB6lgFpCX2P52DtjREgJ7WSX2rjzLBHGDusTJJfOZJjAKz0Iy aRZC+ywk7QsYmVcxiuVm5hTnpqcWGBrpFSfmpWQWZ+sl5+duYgRHB1fmDsYVk8wPMQpwMCrx 8Brc2hMmxJpYVlyZe4hRgoNZSYT3/iagEG9KYmVValF+fFFpTmrxIUZpDhYlcV7rFrUwIYH0 xJLU7NTUgtQimCwTB6dUA2NN+KGanRsXmlbcNLQTM7CYuS/v3427gRql3xddWDLjxNMH2jH3 ZH62XdZ/lZv77tqdSkbt2/PZq038DvEsO2S9n70gZ8ZnDnWPx5+ecMcvmlmnzHhTIfaVTljr 5K9vmb9PE6z8qttmVtrRGbKpTr2i4r/zwv21oW8OhSrZ58vyzLK6crviqY4SS3FGoqEWc1Fx IgCJ2JXqigIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHJMWRmVeSWpSXmKPExsXCtZEjRdfozp4wg7YWEYsLT78zWbw8/4HV YuXqo0wWzw71sljcaHvA5sDqsXjPSyaP3Tcb2DyeTT/M5PF+31U2j8+b5AJYo7hsUlJzMstS i/TtErgyTh65xF5wS7NixdbPzA2Ml5W6GDk5JARMJFpft7N3MXJxCAnMYpR4fu4OO0hCWMBL YtaDJWwgtoiAmsSmV4vA4kICWhLP+/tZQRqYBVYxSvxe+QGsiE3ASOLb+5ksIDYvUNG8v59Y QWwWAVWJC+dPMYHYogIREoc7u9ghagQlTs58AlTPwcEpoC0x80oESJhZQF3iz7xLzBC2vMT2 t3OYJzDyzULSMQtJ2SwkZQsYmVcxiuVm5hTnpmcWGBrpFSfmpWQWZ+sl5+duYgSHKGfUDsbr E80PMTJxcEo1MG69k24TsVk+Z9+07fNapuQqOv6sqZVR4lIS33rkw8dj4pN6eyTsXrzoN4ry M3zk7bd3RV6bCXfJE36JA9MuX2ANX1bnmqoh2JF6ueDU5tRK+9hDq04d48s39GI1fb9TqVSN NfQI31Ytjt2PTmg3b+pXClloyvN+/lrW/wqVSsf+ciTNf/rqhBJLcUaioRZzUXEiALrqUVcB AgAA X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC005; 1:7GKVze4FkYwai37SPYgF4MW0NQxv2gEQTaqfl53AdBh2Nz0wVuzxP8ndlsbztvw2pF/QiyUia969WQPFpxCASXhr8kCCyCt9Y5TlIW4Sc/b97EyOfmff7bKqWT2L6wKJS2GxCJLvdB6nxlzdx0YcXV9U8kEd9rK8ShDu/h9o0DXF/NiKnjBdL2sDfp2k0ImLS7jnD/C2GyJx33Vb2FIC81EYeCqhNkNhlBtqTFjl7bfKYiVp40irV7WLc1qaIw1GBaWULMYX737yBbFc4kEFznp77jinTmTuAM+e5J/Tp8fFRYY9r1fc5stjMr6sPF7XGh2YrQh29IB6MP5cr1DddDafQl27UAxy1AmYytB3JRFZ5Vu8WXgA297QMUex5JoNdpJKaX1APDCt/8188BIgPSZcJBZvYS9BEDV4bGUkirErF02QSjx4wUMxKfnXmgkEnCxknp/nJuYQukltQILBnQ== X-Forefront-Antispam-Report: CIP:63.163.107.174; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(65956001)(189998001)(83506001)(54356999)(87266999)(65816999)(76176999)(86362001)(4001350100001)(5001960100002)(229853001)(2950100001)(1220700001)(87936001)(1096002)(106466001)(586003)(50986999)(92566002)(23676002)(59896002)(5008740100001)(65806001)(230700001)(36756003)(19580395003)(80316001)(19580405001)(50466002)(11100500001)(2906002)(77096005)(4326007)(33656002)(47776003)(64126003); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR02MB289; H:milsmgep12.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2PR02MB289; 2:8MQ3/c+/yeZax+bbVAcDOARbia5TV9E9lewk+3lfO3R2B99g6qgz0l4A02AWmZvloiGya7TyG7kvgEoXYZ2B8aXWtAzJpGDN3wvH/Z8TSp6JWQJvfIZZbznwsQ8O0noy9IztDSvaj4KWB1O+swxfbw==; 3:4pkUyPNPDfcIT60J182Eei+CLNe4DdV/ZcLjtJV8S8LkFOKs0JtnNJc84fcmdeMCEyABP0jzrOZrxR5d8oLVyMabcmDDM3/LXnw4lLtTGUR7CmA2ngs+7arJQG6J02/ROtdCftSEuWb2WGxatXVarvBafNB6x/WmdJ//QfI1gT//+1SaInCPJoo+nesxV1iQP7uRHwzy7LDwKFLDnFiFlv+Vr21ByIcPg7ifVDBg4+eZ8EC2Hi0q6KLqZSnfwp/hknf+QDdq3cDwni6gqH9JKA==; 25:Ff5fNXv0CgYQkPM3tWn/tr4YZJKmFX8gX2WEyhJSFGJNgxgVfqHkrMwglOsCkGqJ83ybSq/GEOKbHqfxMYlku1XwW1RYGWWGeoAykzB0waC6b89iSt+n9BM7d2FD+C3TAmPneWmItPIlpOMuSXEOg0ETxdh2WbH0EbFm65nyq1W9CKaR7UcDiqpfDqzNPFdA6GiCDEpJxoEcqlWSId6tRjCLeSqbuj1w+V2M5CQgeY9E/r/RdIsIAwtJBQYe+kSY2s+ofOeioH3Q2EUU3BiRoM379zSjJV3Y7sP4XAzi0udlK9jKj9tz67g7p2RHsZT1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BL2PR02MB289; X-MS-Office365-Filtering-Correlation-Id: b3596170-eb57-43a0-6f2e-08d33316bdc6 X-Microsoft-Exchange-Diagnostics: 1; BL2PR02MB289; 20:hgkuDkqUIhg1cmxNbkmq0PHiiRrTpq+bm4zx08umezf6hD8HXh9NBweEqX9c4iOSHo+Jgt9pa33Zh+BMkEny6iGP4OO3bVSm9d61orbqx9tnE/dhwFElsmFBgvId3MIWOsCTR8igbMTxvCFnklc25WXGDTKi9H5RA4fZ/GNdHX070P+YjigdcRn7KQsel/NNP8N5KtcmlU6N1mJ+Qxps6+Q9+vitkzI9mWOxi0D4Qhe4QU0zkC/QfUdrAftJ+JP96JBAD4SY16r6VD0CRHsKNhHHA+lPr7QPQl2GPxZrFJutdB0607mr0mhDTa46b6Nqq2Uo5c0a9VutGB/52wqxKLnkySZFpO/jXtiK5wdq6jUy64U5zC6Gjoojo6X6fL14mdo7qmQ73frFYZ4dYh0eFQW6BA6o8Ac0fTfE92gQX4ZNJRjF+o2eDqVWNYxBEpN0eYo6UE6PgQPBHVVHS7M1m/9JLMvl2eNod1AYEnjoXKUhTa4iHzZw+EeoSaBQ7vJQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(5005006)(13017025)(8121501046)(13023025)(13018025)(13024025)(3002001)(10201501046); SRVR:BL2PR02MB289; BCL:0; PCL:0; RULEID:; SRVR:BL2PR02MB289; X-Microsoft-Exchange-Diagnostics: 1; BL2PR02MB289; 4:X4qAvWgsXc3ZOEGJyVg1AGOckCtwnpue0gwfi0hPENlRfFO+g5ljp8BmyX9V8zpZ2pSXb8MgVM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FWnpV?= =?utf-8?B?MkJYK0hrOXY1Q1dvMnVvYUF1ODdPbXRhdm5QVmNhYWRpL3BNN1pOMzBhV3Zt?= =?utf-8?Q?kiyJp+Mw3Q6VnVR8DVum52jhub?= X-Microsoft-Exchange-Diagnostics: 1; BL2PR02MB289; 5:+GdTILjEhfnDf0mB/XbkP1yd7+n2jBa9N//yTlaFqmkYRlAu8JZOvOHyNOh0VGS0ErlL8D9VP3vDDEJ53cYdPebttY/CPPNcJm65uMF58CGI68StHx0UFkzoSWUoYJ9o1on/bRA0IKvIFWrtrPxZDg==; 24:7OioY/30pGyyLTdwVCXEKlhcdnGHsO7B38Q77Hxlv8jy3Fr/Z0IILY/Cv+Rdk2MF79fDW2fM0+F7Lxa3PAngQ3DUwJllHl13DXXj4RKG73Q=; 20:ZSPEnjY2/jCQXCD+JKrsJyB8DC/Wa8VnL9tJ54GcvE+EfHaytKqRwBnjYROagGHLylTsvQJ2/EWCr9W58PkzE7rgIf8AzOa1hmUMLPrZ6i3wTRn8eBnu9KO/Fl5M15LSXvtfMTQvAJTqSPph/AnkN0qBwONzj18KgAdur7ZqUquI6WZ9UeohM4UL8FVITmadM2bKGZ4rQagXdWZPm+ef1ezPuZpsRM8dIQmXrEHF60Dcccn+xsgPpGn2uFOmYipV SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2016 19:08:35.0419 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.174]; Helo=[milsmgep12.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR02MB289 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In a later patch a function that can block will be called while iterating over the rch_list. Hence protect that list with a mutex instead of a spinlock. And since it is not allowed to sleep while the task state != TASK_RUNNING, convert the list test in srpt_ch_list_empty() into a lockless test. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Cc: Sagi Grimberg Cc: Alex Estrin --- drivers/infiniband/ulp/srpt/ib_srpt.c | 42 +++++++++++++---------------------- drivers/infiniband/ulp/srpt/ib_srpt.h | 4 ++-- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index d9bac93..c96e139 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1862,12 +1862,11 @@ static void __srpt_close_ch(struct srpt_rdma_ch *ch) */ static void srpt_close_ch(struct srpt_rdma_ch *ch) { - struct srpt_device *sdev; + struct srpt_device *sdev = ch->sport->sdev; - sdev = ch->sport->sdev; - spin_lock_irq(&sdev->spinlock); + mutex_lock(&sdev->mutex); __srpt_close_ch(ch); - spin_unlock_irq(&sdev->spinlock); + mutex_unlock(&sdev->mutex); } /** @@ -1954,11 +1953,11 @@ static void srpt_release_channel_work(struct work_struct *w) ch->sport->sdev, ch->rq_size, ch->rsp_size, DMA_TO_DEVICE); - spin_lock_irq(&sdev->spinlock); + mutex_lock(&sdev->mutex); list_del_init(&ch->list); if (ch->release_done) complete(ch->release_done); - spin_unlock_irq(&sdev->spinlock); + mutex_unlock(&sdev->mutex); wake_up(&sdev->ch_releaseQ); @@ -2039,7 +2038,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, if ((req->req_flags & SRP_MTCH_ACTION) == SRP_MULTICHAN_SINGLE) { rsp->rsp_flags = SRP_LOGIN_RSP_MULTICHAN_NO_CHAN; - spin_lock_irq(&sdev->spinlock); + mutex_lock(&sdev->mutex); list_for_each_entry_safe(ch, tmp_ch, &sdev->rch_list, list) { if (!memcmp(ch->i_port_id, req->initiator_port_id, 16) @@ -2063,7 +2062,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, } } - spin_unlock_irq(&sdev->spinlock); + mutex_unlock(&sdev->mutex); } else rsp->rsp_flags = SRP_LOGIN_RSP_MULTICHAN_MAINTAINED; @@ -2208,9 +2207,9 @@ try_again: goto release_channel; } - spin_lock_irq(&sdev->spinlock); + mutex_lock(&sdev->mutex); list_add_tail(&ch->list, &sdev->rch_list); - spin_unlock_irq(&sdev->spinlock); + mutex_unlock(&sdev->mutex); goto out; @@ -2652,17 +2651,6 @@ static void srpt_refresh_port_work(struct work_struct *work) srpt_refresh_port(sport); } -static int srpt_ch_list_empty(struct srpt_device *sdev) -{ - int res; - - spin_lock_irq(&sdev->spinlock); - res = list_empty(&sdev->rch_list); - spin_unlock_irq(&sdev->spinlock); - - return res; -} - /** * srpt_release_sdev() - Free the channel resources associated with a target. */ @@ -2675,13 +2663,13 @@ static int srpt_release_sdev(struct srpt_device *sdev) BUG_ON(!sdev); - spin_lock_irq(&sdev->spinlock); + mutex_lock(&sdev->mutex); list_for_each_entry_safe(ch, tmp_ch, &sdev->rch_list, list) __srpt_close_ch(ch); - spin_unlock_irq(&sdev->spinlock); + mutex_unlock(&sdev->mutex); res = wait_event_interruptible(sdev->ch_releaseQ, - srpt_ch_list_empty(sdev)); + list_empty_careful(&sdev->rch_list)); if (res) pr_err("%s: interrupted.\n", __func__); @@ -2742,7 +2730,7 @@ static void srpt_add_one(struct ib_device *device) sdev->device = device; INIT_LIST_HEAD(&sdev->rch_list); init_waitqueue_head(&sdev->ch_releaseQ); - spin_lock_init(&sdev->spinlock); + mutex_init(&sdev->mutex); sdev->pd = ib_alloc_pd(device); if (IS_ERR(sdev->pd)) @@ -2970,12 +2958,12 @@ static void srpt_close_session(struct se_session *se_sess) pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num, ch->state); - spin_lock_irq(&sdev->spinlock); + mutex_lock(&sdev->mutex); BUG_ON(ch->release_done); ch->release_done = &release_done; wait = !list_empty(&ch->list); __srpt_close_ch(ch); - spin_unlock_irq(&sdev->spinlock); + mutex_unlock(&sdev->mutex); if (!wait) return; diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h index 9c326c7..5883295 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -342,7 +342,7 @@ struct srpt_port { * @ioctx_ring: Per-HCA SRQ. * @rch_list: Per-device channel list -- see also srpt_rdma_ch.list. * @ch_releaseQ: Enables waiting for removal from rch_list. - * @spinlock: Protects rch_list and tpg. + * @mutex: Protects rch_list. * @port: Information about the ports owned by this HCA. * @event_handler: Per-HCA asynchronous IB event handler. * @list: Node in srpt_dev_list. @@ -356,7 +356,7 @@ struct srpt_device { struct srpt_recv_ioctx **ioctx_ring; struct list_head rch_list; wait_queue_head_t ch_releaseQ; - spinlock_t spinlock; + struct mutex mutex; struct srpt_port port[2]; struct ib_event_handler event_handler; struct list_head list;