Skip to contentSkip to conversation

RDMA/rxe: Convert mca read locking to RCU

PATCH New Bob Pearson 1 participant 1 message Feb 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v14 1/1 RDMA/rxe: Convert mca read locking to RCU

Replace spinlock with rcu read locks for read side operations on mca in rxe_recv.c and rxe_mcast.c. Minor fixups and name changes for clarity.

---
v14:
This is the last patch left in the series to move multicast out of rxe_pools. I finally found the cause of the failure in v12 and fixed it. I also make some cleanups to names and order of the subroutines to help readability. Also the rxe_destroy_mca subroutine which is called from call_rcu() doesn't have the spinlock set which required a small change.

 drivers/infiniband/sw/rxe/rxe_loc.h   |   2 +-
 drivers/infiniband/sw/rxe/rxe_mcast.c | 144 ++++++++++++++------------
 drivers/infiniband/sw/rxe/rxe_recv.c  |   8 +-
 drivers/infiniband/sw/rxe/rxe_verbs.h |   2 +
 4 files changed, 84 insertions(+), 72 deletions(-)
drivers/infiniband/sw/rxe/rxe_loc.h +1 -1
index 2ffbe3390668..c7ba112d5c67 100644
@@ -41,9 +41,9 @@ void rxe_cq_cleanup(struct rxe_pool_elem *arg);
 
 /* rxe_mcast.c */
 struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid);
+void rxe_free_mcg(struct kref *kref);
 int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid);
 int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid);
-void rxe_cleanup_mcg(struct kref *kref);
 
 /* rxe_mmap.c */
 struct rxe_mmap_info {
drivers/infiniband/sw/rxe/rxe_mcast.c +77 -67

225 lines not on this page · raw message

drivers/infiniband/sw/rxe/rxe_recv.c +4 -4
index 9b21cbb22602..eda9e27e40c0 100644
@@ -265,17 +265,17 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
 	qp_array = kmalloc_array(nmax, sizeof(qp), GFP_KERNEL);
 	n = 0;
 
-	spin_lock_bh(&rxe->mcg_lock);
-	list_for_each_entry(mca, &mcg->qp_list, qp_list) {
+	rcu_read_lock();
+	list_for_each_entry_rcu(mca, &mcg->qp_list, qp_list) {
 		/* protect the qp pointers in the list */
 		rxe_add_ref(mca->qp);
 		qp_array[n++] = mca->qp;
 		if (n == nmax)
 			break;
 	}
-	spin_unlock_bh(&rxe->mcg_lock);
+	rcu_read_unlock();
 	nmax = n;
-	kref_put(&mcg->ref_cnt, rxe_cleanup_mcg);
+	kref_put(&mcg->ref_cnt, rxe_free_mcg);
 
 	for (n = 0; n < nmax; n++) {
 		qp = qp_array[n];
drivers/infiniband/sw/rxe/rxe_verbs.h +2 -0
index e7eff1ca75e9..897f77ff604c 100644
@@ -363,7 +363,9 @@ struct rxe_mcg {
 
 struct rxe_mca {
 	struct list_head	qp_list;
+	struct rcu_head		rcu;
 	struct rxe_qp		*qp;
+	struct rxe_mcg		*mcg;
 };
 
 struct rxe_port {
Signature · 1 line
2.32.0