From patchwork Wed Jan 3 21:39:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10143463 X-Patchwork-Delegate: dledford@redhat.com 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 6E6AB60594 for ; Wed, 3 Jan 2018 21:39:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6241F29361 for ; Wed, 3 Jan 2018 21:39:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56F6429371; Wed, 3 Jan 2018 21:39:52 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 03AEA29361 for ; Wed, 3 Jan 2018 21:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751326AbeACVjt (ORCPT ); Wed, 3 Jan 2018 16:39:49 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:48572 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbeACVjq (ORCPT ); Wed, 3 Jan 2018 16:39:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1515015587; x=1546551587; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1pBGw8JNEtHeRfj/2GVfk3V6Qn1u2VPHmN4Nt1WvJE4=; b=Lt+k4lqnFr63yBYbswyAhm/ozqWW98ThyLBD66klPSm3fSOU7dW1cD6b jP2OxZemPqRz1HmBCwyme847ECGHamJdOaGw3SQJuROTzVYV0kWjZcVhV OQbsHA0Ngzndhb1cZ92m1u1t7izpOPUWrtP4jJF8TKoriYRKOc0DCs/97 SseFXHMAN8CQtP4HGyIO8sbh00hbTbcnVF9lFH4wXV7Mct6ndozb+cQsD ZknlO6xpk78BxaNvxeo8jJd4SCk7vMBiWbzpktiNTQn3rzdgwQc0g8tly uQOBuLJS8X/tGSWxjLY8mee6+9vDXanEL19MUbynokmLMWG6meYbwMpL8 A==; X-IronPort-AV: E=Sophos;i="5.45,504,1508774400"; d="scan'208";a="68005927" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Jan 2018 05:39:41 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Jan 2018 13:35:49 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Jan 2018 13:39:40 -0800 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche Subject: [PATCH 09/28] IB/srpt: Make it safe to use RCU for srpt_device.rch_list Date: Wed, 3 Jan 2018 13:39:19 -0800 Message-Id: <20180103213938.11664-10-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103213938.11664-1-bart.vanassche@wdc.com> References: <20180103213938.11664-1-bart.vanassche@wdc.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The next patch will iterate over rch_list from a context from which it is not allowed to block. Hence make rch_list RCU-safe. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srpt/ib_srpt.c | 5 +++-- drivers/infiniband/ulp/srpt/ib_srpt.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index ebdd5a4f407b..d7143cf6a882 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1852,7 +1852,7 @@ static void srpt_free_ch(struct kref *kref) { struct srpt_rdma_ch *ch = container_of(kref, struct srpt_rdma_ch, kref); - kfree(ch); + kfree_rcu(ch, rcu); } static void srpt_release_channel_work(struct work_struct *w) @@ -2016,6 +2016,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, goto reject; } + init_rcu_head(&ch->rcu); kref_init(&ch->kref); ch->zw_cqe.done = srpt_zerolength_write_done; INIT_WORK(&ch->release_work, srpt_release_channel_work); @@ -2144,7 +2145,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, } mutex_lock(&sdev->mutex); - list_add_tail(&ch->list, &sdev->rch_list); + list_add_tail_rcu(&ch->list, &sdev->rch_list); mutex_unlock(&sdev->mutex); goto out; diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h index 7fff73a5d1e6..d2c08ca2bd74 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -236,6 +236,7 @@ enum rdma_ch_state { * @cm_id: IB CM ID associated with the channel. * @qp: IB queue pair used for communicating over this channel. * @cq: IB completion queue for this channel. + * @rcu: RCU head. * @rq_size: IB receive queue size. * @rsp_size IB response message size in bytes. * @sq_wr_avail: number of work requests available in the send queue. @@ -267,6 +268,7 @@ struct srpt_rdma_ch { struct ib_qp *qp; struct ib_cq *cq; struct ib_cqe zw_cqe; + struct rcu_head rcu; struct kref kref; int rq_size; u32 rsp_size;