@@ -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;
@@ -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;
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 <bart.vanassche@wdc.com> --- drivers/infiniband/ulp/srpt/ib_srpt.c | 5 +++-- drivers/infiniband/ulp/srpt/ib_srpt.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)