From patchwork Fri Jan 29 23:17:21 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: 8168641 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6431DBEEE5 for ; Fri, 29 Jan 2016 23:17:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 484FE20340 for ; Fri, 29 Jan 2016 23:17:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17E6D20328 for ; Fri, 29 Jan 2016 23:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753351AbcA2XR2 (ORCPT ); Fri, 29 Jan 2016 18:17:28 -0500 Received: from mail-by2on0054.outbound.protection.outlook.com ([207.46.100.54]:3520 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756113AbcA2XRY (ORCPT ); Fri, 29 Jan 2016 18:17:24 -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=rYBQZmAm9xOnPbW0Vde3TyqHpQtzvGVul6tu6yTsgyY=; b=GqVvI/4LC+2H2muVupJ/b6X/VgRBZqBoGgzAxQgR2SOurzN+38SRB6nH3vVqZ2Q95IRCDCIAYpCFvgXH52x6zE4IC9jKB7JXSUNofGKARO4EpDa2wRWpZWo8usoTDeN71gA7rH3k24VjUn7hj3zgPkGJrhgljDk3sO68qFcN+bI= Received: from CY1PR0201CA0039.namprd02.prod.outlook.com (10.163.30.177) by CY1PR0201MB0827.namprd02.prod.outlook.com (10.160.141.28) with Microsoft SMTP Server (TLS) id 15.1.365.19; Fri, 29 Jan 2016 23:17:23 +0000 Received: from BN1AFFO11FD051.protection.gbl (2a01:111:f400:7c10::184) by CY1PR0201CA0039.outlook.office365.com (2a01:111:e400:58b9::49) with Microsoft SMTP Server (TLS) id 15.1.390.13 via Frontend Transport; Fri, 29 Jan 2016 23:17:22 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.174) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; 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 BN1AFFO11FD051.mail.protection.outlook.com (10.58.53.66) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Fri, 29 Jan 2016 23:17:21 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by (Symantec Messaging Gateway) with SMTP id 3A.B8.25823.103FBA65; Fri, 29 Jan 2016 15:17:21 -0800 (PST) Received: from milsmgip11.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; Fri, 29 Jan 2016 15:17:22 -0800 X-AuditID: ac160a69-633ff700000064df-ed-56abf301398d Received: from [10.60.52.49] ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id A2.77.02700.103FBA65; Fri, 29 Jan 2016 15:17:21 -0800 (PST) Subject: [PATCH v2 17/22] IB/srpt: Convert rch_list to RCU To: Doug Ledford References: <56ABF16E.7070006@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , "Alex Estrin" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <56ABF301.8080105@sandisk.com> Date: Fri, 29 Jan 2016 15:17:21 -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: <56ABF16E.7070006@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsWyRoxnkS7j59VhBtvn61hcePqdyeLl+Q+s FitXH2WyeHaol8XiRtsDNgdWj8V7XjJ57L7ZwObxbPphJo/3+66yeXzeJBfAGsVlk5Kak1mW WqRvl8CVsfnxM6aC+doVc7q2sTYwPlXuYuTkkBAwkWjZPoO1i5GLQ0hgE6PEyo1vmSGcHYwS d6YtZoGp2jd5KztEYg6jxPmjLcwgCWEBK4n9V88wgtgiAmoSm14tYgexhQS0JM5d+ALWwCyw ilFi09XrYAk2ASOJb+9ngk3lBSqat2Yd2CAWAVWJG5sngtWICkRIHO7sYoeoEZQ4OfMJWD2n gLbEktkXgGwOoKGaEut36YOEmQXkJba/nQN2tYTAXlaJFee+s0AcoS5xcsl8pgmMwrOQjJqF 0D4LSfsCRuZVjGK5mTnFuempBYZGesWJeSmZxdl6yfm5mxjB8cGVuYNxxSTzQ4wCHIxKPLwL VqwOE2JNLCuuzD3EKMHBrCTCW/cCKMSbklhZlVqUH19UmpNafIhRmoNFSZzXukUtTEggPbEk NTs1tSC1CCbLxMEp1cCYlBWuw9RvO/P/bO2JW8Kl/DPqtnZmKftd1Qj+/0ln6jnNo3wbJk/V 3yM2J6EnJdAs86iqt5fP/Glpe68/CJK46/NJbM8E1TkF096szhf3u/y+a5/ar/qCTQ//sOXU yghMNkl8+tyEY0ruRuNk8R0OxqtW6aewbbl8yuDwqY0TEtWjNmdcnGitxFKckWioxVxUnAgA 937sy4sCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPJMWRmVeSWpSXmKPExsXCtZEjRZfx8+owgyf7BCwuPP3OZPHy/AdW i5WrjzJZPDvUy2Jxo+0BmwOrx+I9L5k8dt9sYPN4Nv0wk8f7fVfZPD5vkgtgjeKySUnNySxL LdK3S+DK2Pz4GVPBfO2KOV3bWBsYnyp3MXJySAiYSOybvJW9i5GLQ0hgFqPEpbanbCAJYQEr if1XzzCC2CICahKbXi1iB7GFBLQkzl34AtbALLCKUeL3yg9gDWwCRhLf3s9kAbF5gYrmrVnH DGKzCKhK3Ng8EaxZVCBC4nBnFztEjaDEyZlPwOo5BbQllsy+AGYzC6hL/Jl3iRnClpfY/nYO 8wRGvllIWmYhKZuFpGwBI/MqRrHczJzi3PTMAkNDveLEvJTM4my95PzcTYzgIOWM3MH4dKL5 IUYmDk6pBsaFmy2fiAbIq5+8bK1afnx14q/NZ09H8Zzdf1g58uBRSabcC+e3G344He7+eWOL S+0yFe8Qf26ux2rPZsbwyCwyfZ51wC2+qrY0cMfDaWrKMZ/4eWf4fuuapenwcJUKB/9P4TvK UemsrZe/s8dKHdASX5skeuWk6bO/4Y2XOZf2vtx4x66BwViJpTgj0VCLuag4EQAoRuxEAgIA AA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD051; 1:1jtTK1hq5vdnWy+2hiMf9neeQ2VX/QhiFmxe6XWsWmhvIAIJLW3WbN80VUwJbeXL5bQT5KDLTd4KxM/rGauVcCA39Ke3Q8rkw3HBF1nKk0GIYOWwev51/vSaSAV1G0uF52ZflAqsgsYAVI/QHMrgvwG4P/YY1MF4SshmJXfKuYsAWYOwITzAEXlGc2vb53Xvh0ckatsW7Raj7eZrETjTBnTseW0rj+1YlxPk1HOmvE9sorwJFcUQvO3N5wallnhIF3xfkbMAwuN0KPEWALp0PtIiV3+uGzHhpSShdd7AXJBI3z7Ru+DUYjZDr2QynuAPyAeXVKPZihXz3kGpixg3Qc80bzPY+6zQ3PitLGVMqgmU+NlSe/NrROvvesv4HcVlaEdXe/+/KN0lh0XThDQgFLOZjHm9PfzMP9ormoB879vJ1MiU4RrZ88gFg3IsElRa X-Forefront-Antispam-Report: CIP:63.163.107.174; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(23676002)(50466002)(230700001)(65816999)(106466001)(87266999)(189998001)(54356999)(83506001)(76176999)(33656002)(65806001)(1096002)(110136002)(65956001)(5001960100002)(1220700001)(50986999)(586003)(229853001)(86362001)(575784001)(4326007)(77096005)(36756003)(64126003)(92566002)(19580395003)(87936001)(2950100001)(4001350100001)(19580405001)(80316001)(5008740100001)(47776003)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB0827; H:milsmgep12.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0827; 2:4YrtgVkJkOjRsNituwgATRxyUctRfbmXEN2WgYzxRmAKmNLuDiQbvaGqzaynsHmMkrSc42YB9vcPMrfTIa8zrkhWskPtZEYFTFHiu6Yj1TCOdB3UMb3SMpyHQyRknjAsCgL7eqFFzzvjy+O9Seh7yw==; 3:kyhCH4ryBVAsJapi7E0uAEel9wIXDX8Y7NgBC14dRwdvLjqUtQevzR2ErlVaYJLobqiS1cpjks6tIUUbuS54HB0qZARUGoUg8XnXdU+QlAUUayF8y1v9z6J5JdHcYH+N3vLefxdeblJtdhCBXFKVmnGRXGPVTg4ZKzsJ9a0cXQEFL2EWqgmKyyZBfXCl6pGfaI5ai12ao6UJVoz+xj8CTFVAbDQ0ovWVBS+DWDOSdg3Yzj50Qpu3jzyv2Ne1P87Db3bAqkTUOXQTtzqQa65k/w==; 25:ylX1a2d7wo/MyvAkZl2ZLT3sfS05A+2hyo+SwEPsLvyIDKNK9qosl551UsSkWNx1A9pCUvA64swcJIVCR2CJ2u7t0wEfiScjRl6Us0FyA/fPsGoxGmFKCUaX7uGBKU40ehvGyCTHqh/x4hyv0iTbp0Ls55bYCjhdLqBhNJJPpxh5gMAtVtfR3A6XGa6jZsS6PyZhmzo3IaC73hJjAKAfG/WakEGkoZUWPhvLjBq4Yr0jxQH0x0U0SJW1ObzVJ6Tp X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:CY1PR0201MB0827; X-MS-Office365-Filtering-Correlation-Id: 1c7360e5-29a5-466e-6139-08d329025784 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0827; 20:mWcxDC4a87f2Qqq1mnBbqjTWTiQxcnevTM/akiORVNe6sEwk0HgqCeL64RiMVgzMgMwjUJC4eUt6pLhdASte1G1PEHbA0tkmAwBdnlhr6xvJmmp72ryFE7AgVoz0ne1B4+eskdK/TB5TbBtPB5IsdFjzqN2htK3/JaxlQBr2CqWmR3SzRoeOW8+n3DMFdLBQomq9m77ISi+hG3Y3avc0fAW7RGn1HaEImwyMmk5alLLYa04mC6uzuSFRMRggDtsLyiJLoiYpJcMTGw/uPgOV0olOIx0xUrSSXVtoqf5Wz85fjmyM73jYXXiG0Pnk+0WC2fZ4XDjPTzsQZMdyTOZVAvP3j8tZtBdfb9w0LWiC0VL/F5HjGUycYQdxCvXUSNy/08pd/x8zH7RPEXknQVg6CTSl0CciAb0hCWMOVM5TFpZ23MxoRMLbdutJUY+0RypH6Su0MjgAPzYCzqOuOLcfTegy9kbXoiW7jaWEEiw5Z4PjeUUXkWVh6DmpLsJ+Lcx8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(34787635062028)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13017025)(13024025)(13015025)(13018025)(8121501046)(13023025)(10201501046)(3002001); SRVR:CY1PR0201MB0827; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0201MB0827; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0827; 4:Rj8Zj429QbWpQGJeGQZ4HxXEqUXS+QlYVbOFadtLNJ/t/Ko11rH3h7NEGeuK+07nEjgAvhouDCZChVvX1N86ggZ4EZyHk+XExZVjSZm38yLZ/ms3SdNQ3S5rmVNr+zfird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?= =?utf-8?B?ODJ1U1lxc1d0TmdIRktoMG9yVTkyRzdkRW5mVDlLNitlait3TkNDS0ZJd3VN?= =?utf-8?Q?jNqPPVzoM0PE6Ir0ZZPfKfJHeVaHs?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0827; 5:4AHsawaQM8X/UZ5UW2b6LdOphp/m18btmJNao/C5jm8T5SMmpW0hxPgr4YJ37RX9b7eerurwJzDH/Fjmqr/W/7t5EXttuG9mAKL38d6upF2X5D6dMyNeS+FXYqMcByUe+aF0u6qsYdoAm+VH3VSahg==; 24:QCEjsnL1BKl3dcxDGk5Kj0h7Y7ElkE3iUBEv/4lHivw6SzMLNfZMupVaW+Zq8+1mwocXlpVDqb73LTbwkSofLLyfGGqYUSB5MMcadocG6r0=; 20:O72MgIiTSL9/ZSHHZFj5mRwMxpm9nVtwkeheT6MGtk3vjV2ZwRN/V+PrqgbPCbLE0Uqapgs4TZIua8VEQehQVjHcRCh4C0yMx3r6RkP1sjj+QEac+wfla8fj3HcRu0LQvU54IOHPVuBKAAyu2aZc3m8oTlX3kFQRVZMZiKT0/eW9SokZhOS3EiO664UDpcgEbihSvC/iCjUAG2j+Qo05n9b91J2Yg3ocFuuWNb3QJXd2xYmitXFJve+7Vvs1AQH1 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2016 23:17:21.9190 (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: CY1PR0201MB0827 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 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, protect the list access in srpt_ch_list_empty() with rcu_read_lock() / rcu_read_unlock(). Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Sagi Grimberg --- drivers/infiniband/ulp/srpt/ib_srpt.c | 37 ++++++++++++++++++----------------- drivers/infiniband/ulp/srpt/ib_srpt.h | 5 +++-- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 256b5bf..26aeb0b 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,15 +1953,15 @@ 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); - kfree(ch); + kfree_rcu(ch, rcu); } /** @@ -2038,7 +2037,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) @@ -2062,7 +2061,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; @@ -2203,9 +2202,9 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, 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; @@ -2651,9 +2650,9 @@ static int srpt_ch_list_empty(struct srpt_device *sdev) { int res; - spin_lock_irq(&sdev->spinlock); + rcu_read_lock(); res = list_empty(&sdev->rch_list); - spin_unlock_irq(&sdev->spinlock); + rcu_read_unlock(); return res; } @@ -2670,10 +2669,10 @@ 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)); @@ -2737,7 +2736,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)) @@ -2965,12 +2964,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; @@ -3380,6 +3379,8 @@ out: static void __exit srpt_cleanup_module(void) { + rcu_barrier(); + ib_unregister_client(&srpt_client); target_unregister_template(&srpt_template); } diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h index 9c326c7..d1f2877 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -267,6 +267,7 @@ struct srpt_rdma_ch { struct ib_cm_id *cm_id; struct ib_qp *qp; struct ib_cq *cq; + struct rcu_head rcu; int rq_size; u32 rsp_size; atomic_t sq_wr_avail; @@ -342,7 +343,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 +357,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;