Skip to contentSkip to conversation

Proposed trace points for RDMA/core

PATCH Superseded Chuck Lever 4 participants 9 messages Nov 18, 2019 – Nov 19, 2019

Subsystems (2)

v6 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v6 cover Proposed trace points for RDMA/core

Changes since v5:
- Add low-overhead trace points in the Connection Manager
- Address #include heartburn found by lkp

Changes since v4:
- Removed __ib_poll_cq, uninlined ib_poll_cq

Changes since v3:
- Reverted unnecessary behavior change in __ib_process_cq
- Clarified what "id" is in trace point output
- Added comment before new fields in struct ib_cq
- New trace point that fires when there is a CQ allocation failure

Changes since v2:
- Removed extraneous changes to include/trace/events/rdma.h

Changes since RFC:
- Display CQ's global resource ID instead of it's pointer address

---

Chuck Lever (2):
RDMA/core: Trace points for diagnosing completion queue issues RDMA/cma: Add trace points in RDMA Connection Manager

 drivers/infiniband/core/Makefile    |    4 -
 drivers/infiniband/core/cma.c       |   60 ++++++--
 drivers/infiniband/core/cma_trace.c |   16 ++
 drivers/infiniband/core/cq.c        |   36 +++++
 drivers/infiniband/core/trace.c     |   14 ++
 include/rdma/ib_verbs.h             |   11 +-
 include/trace/events/rdma_cma.h     |  218 +++++++++++++++++++++++++++++++
 include/trace/events/rdma_core.h    |  250 +++++++++++++++++++++++++++++++++++
 8 files changed, 585 insertions(+), 24 deletions(-)
 create mode 100644 drivers/infiniband/core/cma_trace.c
 create mode 100644 drivers/infiniband/core/trace.c
 create mode 100644 include/trace/events/rdma_cma.h
 create mode 100644 include/trace/events/rdma_core.h

--
Chuck Lever

#1 lore raw

PATCH v6 1/2 RDMA/core: Trace points for diagnosing completion queue issues

---
 drivers/infiniband/core/Makefile |    2 
 drivers/infiniband/core/cq.c     |   36 +++++
 drivers/infiniband/core/trace.c  |   14 ++
 include/rdma/ib_verbs.h          |   11 +-
 include/trace/events/rdma_core.h |  250 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 306 insertions(+), 7 deletions(-)
 create mode 100644 drivers/infiniband/core/trace.c
 create mode 100644 include/trace/events/rdma_core.h
drivers/infiniband/core/Makefile +1 -1
index 09881bd5f12d..68d9e27c3c61 100644
@@ -11,7 +11,7 @@ ib_core-y :=			packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
 				device.o fmr_pool.o cache.o netlink.o \
 				roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \
 				multicast.o mad.o smi.o agent.o mad_rmpp.o \
-				nldev.o restrack.o counters.o
+				nldev.o restrack.o counters.o trace.o
 
 ib_core-$(CONFIG_SECURITY_INFINIBAND) += security.o
 ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
drivers/infiniband/core/cq.c +35 -1
index bbfded6d5d3d..98931472eaa0 100644
@@ -7,6 +7,8 @@
 #include <linux/slab.h>
 #include <rdma/ib_verbs.h>
 
+#include <trace/events/rdma_core.h>
+
 /* # of WCs to poll for with a single call to ib_poll_cq */
 #define IB_POLL_BATCH			16
 #define IB_POLL_BATCH_DIRECT		8
@@ -41,6 +43,7 @@ static void ib_cq_rdma_dim_work(struct work_struct *w)
 
 	dim->state = DIM_START_MEASURE;
 
+	trace_cq_modify(cq, comps, usec);
 	cq->device->ops.modify_cq(cq, comps, usec);
 }
 
@@ -65,11 +68,35 @@ static void rdma_dim_init(struct ib_cq *cq)
 	INIT_WORK(&dim->work, ib_cq_rdma_dim_work);
 }
 
+/**
+ * ib_poll_cq - poll a CQ for completion(s)
+ * @cq: the CQ being polled
+ * @num_entries: maximum number of completions to return
+ * @wc: array of at least @num_entries &struct ib_wc where completions
+ *      will be returned
+ *
+ * Poll a CQ for (possibly multiple) completions.  If the return value
+ * is < 0, an error occurred.  If the return value is >= 0, it is the
+ * number of completions returned.  If the return value is
+ * non-negative and < num_entries, then the CQ was emptied.
+ */
+int ib_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
+{
+	int rc;
+
+	rc = cq->device->ops.poll_cq(cq, num_entries, wc);
+	trace_cq_poll(cq, num_entries, rc);
+	return rc;
+}
+EXPORT_SYMBOL(ib_poll_cq);
+
 static int __ib_process_cq(struct ib_cq *cq, int budget, struct ib_wc *wcs,
 			   int batch)
 {
 	int i, n, completed = 0;
 
+	trace_cq_process(cq);
+
 	/*
 	 * budget might be (-1) if the caller does not
 	 * want to bound this call, thus we need unsigned
@@ -131,8 +158,10 @@ static int ib_poll_handler(struct irq_poll *iop, int budget)
 	completed = __ib_process_cq(cq, budget, cq->wc, IB_POLL_BATCH);
 	if (completed < budget) {
 		irq_poll_complete(&cq->iop);
-		if (ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0)
+		if (ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) {
+			trace_cq_reschedule(cq);
 			irq_poll_sched(&cq->iop);
+		}
 	}
 
 	if (dim)
@@ -143,6 +172,7 @@ static int ib_poll_handler(struct irq_poll *iop, int budget)
 
 static void ib_cq_completion_softirq(struct ib_cq *cq, void *private)
 {
+	trace_cq_schedule(cq);
 	irq_poll_sched(&cq->iop);
 }
 
@@ -162,6 +192,7 @@ static void ib_cq_poll_work(struct work_struct *work)
 
 static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private)
 {
+	trace_cq_schedule(cq);
 	queue_work(cq->comp_wq, &cq->work);
 }
 
@@ -239,6 +270,7 @@ struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
 		goto out_destroy_cq;
 	}
 
+	trace_cq_alloc(cq, nr_cqe, comp_vector, poll_ctx);
 	return cq;
 
 out_destroy_cq:
@@ -248,6 +280,7 @@ struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
 	kfree(cq->wc);
 out_free_cq:
 	kfree(cq);
+	trace_cq_alloc_error(nr_cqe, comp_vector, poll_ctx, ret);
 	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL(__ib_alloc_cq_user);
@@ -304,6 +337,7 @@ void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata)
 		WARN_ON_ONCE(1);
 	}
 
+	trace_cq_free(cq);
 	rdma_restrack_del(&cq->res);
 	cq->device->ops.destroy_cq(cq, udata);
 	if (cq->dim)
drivers/infiniband/core/trace.c new file +14 -0
new file mode 100644
index 000000000000..6c3514beac4d
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Trace points for core RDMA functions.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#define CREATE_TRACE_POINTS
+
+#include <rdma/ib_verbs.h>
+
+#include <trace/events/rdma_core.h>
include/rdma/ib_verbs.h +6 -5
index e7e733add99f..71353f81caf1 100644
@@ -1555,6 +1555,11 @@ struct ib_cq {
 	};
 	struct workqueue_struct *comp_wq;
 	struct dim *dim;
+
+	/* updated only by trace points */
+	ktime_t timestamp;
+	bool interrupt;
+
 	/*
 	 * Implementation details of the RDMA core, don't use in drivers:
 	 */
@@ -3868,11 +3873,7 @@ static inline void ib_destroy_cq(struct ib_cq *cq)
  * number of completions returned.  If the return value is
  * non-negative and < num_entries, then the CQ was emptied.
  */
-static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
-			     struct ib_wc *wc)
-{
-	return cq->device->ops.poll_cq(cq, num_entries, wc);
-}
+int ib_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
 
 /**
  * ib_req_notify_cq - Request completion notification on a CQ.
include/trace/events/rdma_core.h new file +250 -0

250 lines not on this page · raw message

#2 lore raw

Re: [PATCH v6 1/2] RDMA/core: Trace points for diagnosing completion queue issues

Quoted 15 lines · Chuck Lever
drivers/infiniband/core/cq.c +11 -0
@@ -65,11 +68,35 @@ static void rdma_dim_init(struct ib_cq *cq)
 	INIT_WORK(&dim->work, ib_cq_rdma_dim_work);
 }
 
+/**
+ * ib_poll_cq - poll a CQ for completion(s)
+ * @cq: the CQ being polled
+ * @num_entries: maximum number of completions to return
+ * @wc: array of at least @num_entries &struct ib_wc where completions
+ *      will be returned
+ *
+ * Poll a CQ for (possibly multiple) completions.  If the return value
+ * is < 0, an error occurred.  If the return value is >= 0, it is the
+ * number of completions returned.  If the return value is
+ * non-negative and < num_entries, then the CQ was emptied.

drivers/infiniband/core/cq.c static void rdma_dim_init(struct ib_cq *cq) · line 91

Quoted 10 lines
drivers/infiniband/core/cq.c +10 -0
+ */
+int ib_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
+{
+	int rc;
+
+	rc = cq->device->ops.poll_cq(cq, num_entries, wc);
+	trace_cq_poll(cq, num_entries, rc);
+	return rc;
+}
+EXPORT_SYMBOL(ib_poll_cq);

Back to the non-inlined function?

Jason

#3 lore raw

Re: [PATCH v6 1/2] RDMA/core: Trace points for diagnosing completion queue issues

Quoted 24 lines · Jason Gunthorpe
Quoted 19 lines · Chuck Lever
drivers/infiniband/core/cq.c +15 -0
@@ -65,11 +68,35 @@ static void rdma_dim_init(struct ib_cq *cq)
 	INIT_WORK(&dim->work, ib_cq_rdma_dim_work);
 }
 
+/**
+ * ib_poll_cq - poll a CQ for completion(s)
+ * @cq: the CQ being polled
+ * @num_entries: maximum number of completions to return
+ * @wc: array of at least @num_entries &struct ib_wc where completions
+ *      will be returned
+ *
+ * Poll a CQ for (possibly multiple) completions.  If the return value
+ * is < 0, an error occurred.  If the return value is >= 0, it is the
+ * number of completions returned.  If the return value is
+ * non-negative and < num_entries, then the CQ was emptied.
+ */
+int ib_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
+{
+	int rc;
Quoted 8 lines

drivers/infiniband/core/cq.c static void rdma_dim_init(struct ib_cq *cq) · line 91

Quoted 6 lines
drivers/infiniband/core/cq.c +6 -0
+
+	rc = cq->device->ops.poll_cq(cq, num_entries, wc);
+	trace_cq_poll(cq, num_entries, rc);
+	return rc;
+}
+EXPORT_SYMBOL(ib_poll_cq);

Back to the non-inlined function?

I never got a clear answer about your preference either way.

IMO making this into a non-inline function is necessary to support either a static trace point here, or to have a place to put a convenient dynamic trace point via eBPF. I don't believe it will add noticeable overhead -- in particular, under heavy load, poll_cq is invoked once every 16 completions.

On the other hand, it's not clear to me that the latency calculation will work correctly with callers outside of cq.c ...

--
Chuck Lever

#4 lore raw

PATCH v6 2/2 RDMA/cma: Add trace points in RDMA Connection Manager

In reply to Chuck Lever

Record state transitions as each connection is established. The IP address of both peers and the Type of Service is reported. These new trace points are not in performance hot paths.

Also, record each cm_event_handler call to ULPs. This eliminates the need for each ULP to add its own similar trace point in its CM event handler function.

These new trace points appear in a new trace subsystem called "rdma_cma".

This patch is based on previous work by:

Saeed Mahameed <[email protected]>
Mukesh Kacker <[email protected]>
Ajaykumar Hotchandani <[email protected]> Aron Silverton <[email protected]>
Avinash Repaka <[email protected]> Somasundaram Krishnasamy <[email protected]>

---
 drivers/infiniband/core/Makefile    |    2 
 drivers/infiniband/core/cma.c       |   60 +++++++---
 drivers/infiniband/core/cma_trace.c |   16 +++
 include/trace/events/rdma_cma.h     |  218 +++++++++++++++++++++++++++++++++++
 4 files changed, 279 insertions(+), 17 deletions(-)
 create mode 100644 drivers/infiniband/core/cma_trace.c
 create mode 100644 include/trace/events/rdma_cma.h
drivers/infiniband/core/Makefile +1 -1
index 68d9e27c3c61..bab7b6f01982 100644
@@ -20,7 +20,7 @@ ib_cm-y :=			cm.o
 
 iw_cm-y :=			iwcm.o iwpm_util.o iwpm_msg.o
 
-rdma_cm-y :=			cma.o
+rdma_cm-y :=			cma.o cma_trace.o
 
 rdma_cm-$(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS) += cma_configfs.o
 
drivers/infiniband/core/cma.c +44 -16

211 lines not on this page · raw message

drivers/infiniband/core/cma_trace.c new file +16 -0
new file mode 100644
index 000000000000..1093fa813bc1
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Trace points for the RDMA Connection Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#define CREATE_TRACE_POINTS
+
+#include <rdma/rdma_cm.h>
+#include <rdma/ib_cm.h>
+#include "cma_priv.h"
+
+#include <trace/events/rdma_cma.h>
include/trace/events/rdma_cma.h new file +218 -0

218 lines not on this page · raw message

#5 lore raw

Re: [PATCH v6 2/2] RDMA/cma: Add trace points in RDMA Connection Manager

Quoted 319 lines · Chuck Lever

Record state transitions as each connection is established. The IP address of both peers and the Type of Service is reported. These new trace points are not in performance hot paths.

Also, record each cm_event_handler call to ULPs. This eliminates the need for each ULP to add its own similar trace point in its CM event handler function.

These new trace points appear in a new trace subsystem called "rdma_cma".

This patch is based on previous work by:

Saeed Mahameed <[email protected]>
Mukesh Kacker <[email protected]>
Ajaykumar Hotchandani <[email protected]> Aron Silverton <[email protected]>
Avinash Repaka <[email protected]> Somasundaram Krishnasamy <[email protected]>

---
 drivers/infiniband/core/Makefile    |    2
 drivers/infiniband/core/cma.c       |   60 +++++++---
 drivers/infiniband/core/cma_trace.c |   16 +++
 include/trace/events/rdma_cma.h     |  218 +++++++++++++++++++++++++++++++++++
 4 files changed, 279 insertions(+), 17 deletions(-)
 create mode 100644 drivers/infiniband/core/cma_trace.c
 create mode 100644 include/trace/events/rdma_cma.h
drivers/infiniband/core/Makefile +1 -1
index 68d9e27c3c61..bab7b6f01982 100644
@@ -20,7 +20,7 @@ ib_cm-y :=			cm.o
 
 iw_cm-y :=			iwcm.o iwpm_util.o iwpm_msg.o
 
-rdma_cm-y :=			cma.o
+rdma_cm-y :=			cma.o cma_trace.o
 
 rdma_cm-$(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS) += cma_configfs.o
 
drivers/infiniband/core/cma.c +44 -16
index d78f67623f24..5d5e63336954 100644
@@ -64,6 +64,8 @@
 #include "core_priv.h"
 #include "cma_priv.h"
 
+#include <trace/events/rdma_cma.h>
+
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("Generic RDMA CM Agent");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -1890,6 +1892,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv)
 	if (ret)
 		goto reject;
 
+	trace_cm_send_rtu(id_priv);
 	ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0);
 	if (ret)
 		goto reject;
@@ -1898,6 +1901,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv)
 reject:
 	pr_debug_ratelimited("RDMA CM: CONNECT_ERROR: failed to handle reply. status %d\n", ret);
 	cma_modify_qp_err(id_priv);
+	trace_cm_send_rej(id_priv);
 	ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
 		       NULL, 0, NULL, 0);
 	return ret;
@@ -1917,6 +1921,13 @@ static void cma_set_rep_event_data(struct rdma_cm_event *event,
 	event->param.conn.qp_num = rep_data->remote_qpn;
 }
 
+static int cma_cm_event_handler(struct rdma_id_private *id_priv,
+				struct rdma_cm_event *event)
+{
+	trace_cm_event_handler(id_priv, event);
+	return id_priv->id.event_handler(&id_priv->id, event);
+}
+
 static int cma_ib_handler(struct ib_cm_id *cm_id,
 			  const struct ib_cm_event *ib_event)
 {
@@ -1939,8 +1950,10 @@ static int cma_ib_handler(struct ib_cm_id *cm_id,
 		break;
 	case IB_CM_REP_RECEIVED:
 		if (cma_comp(id_priv, RDMA_CM_CONNECT) &&
-		    (id_priv->id.qp_type != IB_QPT_UD))
+		    (id_priv->id.qp_type != IB_QPT_UD)) {
+			trace_cm_send_mra(id_priv);
 			ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+		}
 		if (id_priv->id.qp) {
 			event.status = cma_rep_recv(id_priv);
 			event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
@@ -1985,7 +1998,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id,
 		goto out;
 	}
 
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 	if (ret) {
 		/* Destroy the CM ID by returning a non-zero value. */
 		id_priv->cm_id.ib = NULL;
@@ -2146,6 +2159,7 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
 	if (IS_ERR(listen_id))
 		return PTR_ERR(listen_id);
 
+	trace_cm_req_handler(listen_id, ib_event->event);
 	if (!cma_ib_check_req_qp_type(&listen_id->id, ib_event)) {
 		ret = -EINVAL;
 		goto net_dev_put;
@@ -2188,7 +2202,7 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
 	 * until we're done accessing it.
 	 */
 	atomic_inc(&conn_id->refcount);
-	ret = conn_id->id.event_handler(&conn_id->id, &event);
+	ret = cma_cm_event_handler(conn_id, &event);
 	if (ret)
 		goto err3;
 	/*
@@ -2197,8 +2211,10 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
 	 */
 	mutex_lock(&lock);
 	if (cma_comp(conn_id, RDMA_CM_CONNECT) &&
-	    (conn_id->id.qp_type != IB_QPT_UD))
+	    (conn_id->id.qp_type != IB_QPT_UD)) {
+		trace_cm_send_mra(cm_id->context);
 		ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+	}
 	mutex_unlock(&lock);
 	mutex_unlock(&conn_id->handler_mutex);
 	mutex_unlock(&listen_id->handler_mutex);
@@ -2313,7 +2329,7 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
 	event.status = iw_event->status;
 	event.param.conn.private_data = iw_event->private_data;
 	event.param.conn.private_data_len = iw_event->private_data_len;
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 	if (ret) {
 		/* Destroy the CM ID by returning a non-zero value. */
 		id_priv->cm_id.iw = NULL;
@@ -2390,7 +2406,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
 	 * until we're done accessing it.
 	 */
 	atomic_inc(&conn_id->refcount);
-	ret = conn_id->id.event_handler(&conn_id->id, &event);
+	ret = cma_cm_event_handler(conn_id, &event);
 	if (ret) {
 		/* User wants to destroy the CM ID */
 		conn_id->cm_id.iw = NULL;
@@ -2462,6 +2478,7 @@ static int cma_listen_handler(struct rdma_cm_id *id,
 
 	id->context = id_priv->id.context;
 	id->event_handler = id_priv->id.event_handler;
+	trace_cm_event_handler(id_priv, event);
 	return id_priv->id.event_handler(id, event);
 }
 
@@ -2636,7 +2653,7 @@ static void cma_work_handler(struct work_struct *_work)
 	if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
 		goto out;
 
-	if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+	if (cma_cm_event_handler(id_priv, &work->event)) {
 		cma_exch(id_priv, RDMA_CM_DESTROYING);
 		destroy = 1;
 	}
@@ -2659,7 +2676,7 @@ static void cma_ndev_work_handler(struct work_struct *_work)
 	    id_priv->state == RDMA_CM_DEVICE_REMOVAL)
 		goto out;
 
-	if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+	if (cma_cm_event_handler(id_priv, &work->event)) {
 		cma_exch(id_priv, RDMA_CM_DESTROYING);
 		destroy = 1;
 	}
@@ -3062,7 +3079,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
 	} else
 		event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
 
-	if (id_priv->id.event_handler(&id_priv->id, &event)) {
+	if (cma_cm_event_handler(id_priv, &event)) {
 		cma_exch(id_priv, RDMA_CM_DESTROYING);
 		mutex_unlock(&id_priv->handler_mutex);
 		rdma_destroy_id(&id_priv->id);
@@ -3709,7 +3726,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
 		goto out;
 	}
 
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 
 	rdma_destroy_ah_attr(&event.param.ud.ah_attr);
 	if (ret) {
@@ -3773,6 +3790,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
 	req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8);
 	req.max_cm_retries = CMA_MAX_CM_RETRIES;
 
+	trace_cm_send_sidr_req(id_priv);
 	ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req);
 	if (ret) {
 		ib_destroy_cm_id(id_priv->cm_id.ib);
@@ -3846,6 +3864,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
 	req.max_cm_retries = CMA_MAX_CM_RETRIES;
 	req.srq = id_priv->srq ? 1 : 0;
 
+	trace_cm_send_req(id_priv);
 	ret = ib_send_cm_req(id_priv->cm_id.ib, &req);
 out:
 	if (ret && !IS_ERR(id)) {
@@ -3959,6 +3978,7 @@ static int cma_accept_ib(struct rdma_id_private *id_priv,
 	rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
 	rep.srq = id_priv->srq ? 1 : 0;
 
+	trace_cm_send_rep(id_priv);
 	ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);
 out:
 	return ret;
@@ -4008,6 +4028,7 @@ static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
 	rep.private_data = private_data;
 	rep.private_data_len = private_data_len;
 
+	trace_cm_send_sidr_rep(id_priv);
 	return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep);
 }
 
@@ -4093,13 +4114,15 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data,
 		return -EINVAL;
 
 	if (rdma_cap_ib_cm(id->device, id->port_num)) {
-		if (id->qp_type == IB_QPT_UD)
+		if (id->qp_type == IB_QPT_UD) {
 			ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0,
 						private_data, private_data_len);
-		else
+		} else {
+			trace_cm_send_rej(id_priv);
 			ret = ib_send_cm_rej(id_priv->cm_id.ib,
 					     IB_CM_REJ_CONSUMER_DEFINED, NULL,
 					     0, private_data, private_data_len);
+		}
 	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		ret = iw_cm_reject(id_priv->cm_id.iw,
 				   private_data, private_data_len);
@@ -4124,8 +4147,13 @@ int rdma_disconnect(struct rdma_cm_id *id)
 		if (ret)
 			goto out;
 		/* Initiate or respond to a disconnect. */
-		if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
-			ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
+		trace_cm_disconnect(id_priv);
+		if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) {
+			if (!ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0))
+				trace_cm_sent_drep(id_priv);
+		} else {
+			trace_cm_sent_dreq(id_priv);
+		}
 	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
 	} else
@@ -4191,7 +4219,7 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
 	} else
 		event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
 
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 
 	rdma_destroy_ah_attr(&event.param.ud.ah_attr);
 	if (ret) {
@@ -4626,7 +4654,7 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
 		goto out;
 
 	event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 out:
 	mutex_unlock(&id_priv->handler_mutex);
 	return ret;
drivers/infiniband/core/cma_trace.c new file +16 -0
new file mode 100644
index 000000000000..1093fa813bc1
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Trace points for the RDMA Connection Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#define CREATE_TRACE_POINTS
+
+#include <rdma/rdma_cm.h>
+#include <rdma/ib_cm.h>
+#include "cma_priv.h"
+
+#include <trace/events/rdma_cma.h>
include/trace/events/rdma_cma.h new file +9 -0
new file mode 100644
index 000000000000..b6ccdade651c
@@ -0,0 +1,218 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Trace point definitions for the RDMA Connect Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+

include/trace/events/rdma_cma.h line 19

Quoted 10 lines
include/trace/events/rdma_cma.h new file +10 -0
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rdma_cma
+
+#if !defined(_TRACE_RDMA_CMA_H) || defined(TRACE_HEADER_MULTI_READ)
+
+#define _TRACE_RDMA_CMA_H
+
+#include <linux/tracepoint.h>
+#include <rdma/rdma_cm.h>
+#include "cma_priv.h"

Did it compile?
cma_priv.h is located in drivers/infiniband/core/ and unlikely to be accessible from "include/trace/events/rdma_cma.h" file.

BTW, can you please add example of trace output to your commit message? It will help users to understand immediately what they are expected to see after this series is applied.

Thanks

#6 lore raw

RE: [PATCH v6 2/2] RDMA/cma: Add trace points in RDMA Connection Manager

Quoted 362 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Leon Romanovsky
Sent: Tuesday, November 19, 2019 3:45 PM
To: Chuck Lever
Cc: [email protected]
Subject: Re: [PATCH v6 2/2] RDMA/cma: Add trace points in RDMA Connection Manager

Quoted 20 lines · Chuck Lever

Record state transitions as each connection is established. The IP address of both peers and the Type of Service is reported. These new trace points are not in performance hot paths.

Also, record each cm_event_handler call to ULPs. This eliminates the need for each ULP to add its own similar trace point in its CM event handler function.

These new trace points appear in a new trace subsystem called "rdma_cma".

This patch is based on previous work by:

Saeed Mahameed <[email protected]>
Mukesh Kacker <[email protected]>
Ajaykumar Hotchandani <[email protected]> Aron Silverton <[email protected]>
Avinash Repaka <[email protected]> Somasundaram Krishnasamy <[email protected]>

Quoted 6 lines
---
 drivers/infiniband/core/Makefile    |    2
 drivers/infiniband/core/cma.c       |   60 +++++++---
 drivers/infiniband/core/cma_trace.c |   16 +++
 include/trace/events/rdma_cma.h     |  218

+++++++++++++++++++++++++++++++++++

Review

Quoted 5 lines
 4 files changed, 279 insertions(+), 17 deletions(-)
 create mode 100644 drivers/infiniband/core/cma_trace.c
 create mode 100644 include/trace/events/rdma_cma.h
(quoted diff) +0 -0

b/drivers/infiniband/core/Makefile

drivers/infiniband/core/Makefile ib_cm-y := cm.o · line 25

Quoted 11 lines

index 68d9e27c3c61..bab7b6f01982 100644

drivers/infiniband/core/Makefile +1 -1
@@ -20,7 +20,7 @@ ib_cm-y :=			cm.o
 
 iw_cm-y :=			iwcm.o iwpm_util.o iwpm_msg.o
 
-rdma_cm-y :=			cma.o
+rdma_cm-y :=			cma.o cma_trace.o
 
 rdma_cm-$(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS) +=

cma_configfs.o

drivers/infiniband/core/cma.c static int cma_rep_recv(struct rdma_id_private

Quoted 15 lines
drivers/infiniband/core/cma.c +2 -0
index d78f67623f24..5d5e63336954 100644
@@ -64,6 +64,8 @@
 #include "core_priv.h"
 #include "cma_priv.h"
 
+#include <trace/events/rdma_cma.h>
+
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("Generic RDMA CM Agent");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -1890,6 +1892,7 @@ static int cma_rep_recv(struct rdma_id_private

*id_priv)

drivers/infiniband/core/cma.c static int cma_rep_recv(struct rdma_id_private

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	if (ret)
 		goto reject;
 
+	trace_cm_send_rtu(id_priv);
 	ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0);
 	if (ret)
 		goto reject;
@@ -1898,6 +1901,7 @@ static int cma_rep_recv(struct rdma_id_private

*id_priv)

drivers/infiniband/core/cma.c static int cma_rep_recv(struct rdma_id_private · line 1902

Quoted 2 lines
drivers/infiniband/core/cma.c +0 -0
 reject:
 	pr_debug_ratelimited("RDMA CM: CONNECT_ERROR: failed to handle

reply. status %d\n", ret);

drivers/infiniband/core/cma.c static void cma_set_rep_event_data(struct

Quoted 6 lines
drivers/infiniband/core/cma.c +1 -0
 	cma_modify_qp_err(id_priv);
+	trace_cm_send_rej(id_priv);
 	ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
 		       NULL, 0, NULL, 0);
 	return ret;
@@ -1917,6 +1921,13 @@ static void cma_set_rep_event_data(struct

rdma_cm_event *event,

drivers/infiniband/core/cma.c static int cma_ib_handler(struct ib_cm_id

Quoted 14 lines
drivers/infiniband/core/cma.c +7 -0
 	event->param.conn.qp_num = rep_data->remote_qpn;
 }
 
+static int cma_cm_event_handler(struct rdma_id_private *id_priv,
+				struct rdma_cm_event *event)
+{
+	trace_cm_event_handler(id_priv, event);
+	return id_priv->id.event_handler(&id_priv->id, event);
+}
+
 static int cma_ib_handler(struct ib_cm_id *cm_id,
 			  const struct ib_cm_event *ib_event)
 {
@@ -1939,8 +1950,10 @@ static int cma_ib_handler(struct ib_cm_id

*cm_id,

drivers/infiniband/core/cma.c static int cma_ib_handler(struct ib_cm_id *cm_id,

Quoted 11 lines
drivers/infiniband/core/cma.c +3 -1
 		break;
 	case IB_CM_REP_RECEIVED:
 		if (cma_comp(id_priv, RDMA_CM_CONNECT) &&
-		    (id_priv->id.qp_type != IB_QPT_UD))
+		    (id_priv->id.qp_type != IB_QPT_UD)) {
+			trace_cm_send_mra(id_priv);
 			ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+		}
 		if (id_priv->id.qp) {
 			event.status = cma_rep_recv(id_priv);
 			event.event = event.status ?

RDMA_CM_EVENT_CONNECT_ERROR :

drivers/infiniband/core/cma.c static int cma_ib_req_handler(struct ib_cm_id

Quoted 10 lines
drivers/infiniband/core/cma.c +1 -1
@@ -1985,7 +1998,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id,
 		goto out;
 	}
 
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 	if (ret) {
 		/* Destroy the CM ID by returning a non-zero value. */
 		id_priv->cm_id.ib = NULL;
@@ -2146,6 +2159,7 @@ static int cma_ib_req_handler(struct ib_cm_id

*cm_id,

drivers/infiniband/core/cma.c static int cma_ib_req_handler(struct ib_cm_id

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	if (IS_ERR(listen_id))
 		return PTR_ERR(listen_id);
 
+	trace_cm_req_handler(listen_id, ib_event->event);
 	if (!cma_ib_check_req_qp_type(&listen_id->id, ib_event)) {
 		ret = -EINVAL;
 		goto net_dev_put;
@@ -2188,7 +2202,7 @@ static int cma_ib_req_handler(struct ib_cm_id

*cm_id,

drivers/infiniband/core/cma.c static int cma_ib_req_handler(struct ib_cm_id

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	 * until we're done accessing it.
 	 */
 	atomic_inc(&conn_id->refcount);
-	ret = conn_id->id.event_handler(&conn_id->id, &event);
+	ret = cma_cm_event_handler(conn_id, &event);
 	if (ret)
 		goto err3;
 	/*
@@ -2197,8 +2211,10 @@ static int cma_ib_req_handler(struct ib_cm_id

*cm_id,

drivers/infiniband/core/cma.c static int cma_iw_handler(struct iw_cm_id *iw_id,

Quoted 12 lines
drivers/infiniband/core/cma.c +3 -1
 	 */
 	mutex_lock(&lock);
 	if (cma_comp(conn_id, RDMA_CM_CONNECT) &&
-	    (conn_id->id.qp_type != IB_QPT_UD))
+	    (conn_id->id.qp_type != IB_QPT_UD)) {
+		trace_cm_send_mra(cm_id->context);
 		ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+	}
 	mutex_unlock(&lock);
 	mutex_unlock(&conn_id->handler_mutex);
 	mutex_unlock(&listen_id->handler_mutex);
@@ -2313,7 +2329,7 @@ static int cma_iw_handler(struct iw_cm_id *iw_id,

struct iw_cm_event *iw_event)

drivers/infiniband/core/cma.c static int iw_conn_req_handler(struct iw_cm_id

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	event.status = iw_event->status;
 	event.param.conn.private_data = iw_event->private_data;
 	event.param.conn.private_data_len = iw_event->private_data_len;
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 	if (ret) {
 		/* Destroy the CM ID by returning a non-zero value. */
 		id_priv->cm_id.iw = NULL;
@@ -2390,7 +2406,7 @@ static int iw_conn_req_handler(struct iw_cm_id

*cm_id,

drivers/infiniband/core/cma.c static int cma_listen_handler(struct rdma_cm_id

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	 * until we're done accessing it.
 	 */
 	atomic_inc(&conn_id->refcount);
-	ret = conn_id->id.event_handler(&conn_id->id, &event);
+	ret = cma_cm_event_handler(conn_id, &event);
 	if (ret) {
 		/* User wants to destroy the CM ID */
 		conn_id->cm_id.iw = NULL;
@@ -2462,6 +2478,7 @@ static int cma_listen_handler(struct rdma_cm_id

*id,

drivers/infiniband/core/cma.c static void cma_work_handler(struct work_struct

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	id->context = id_priv->id.context;
 	id->event_handler = id_priv->id.event_handler;
+	trace_cm_event_handler(id_priv, event);
 	return id_priv->id.event_handler(id, event);
 }
 
@@ -2636,7 +2653,7 @@ static void cma_work_handler(struct work_struct

*_work)

drivers/infiniband/core/cma.c static void cma_ndev_work_handler(struct

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
 		goto out;
 
-	if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+	if (cma_cm_event_handler(id_priv, &work->event)) {
 		cma_exch(id_priv, RDMA_CM_DESTROYING);
 		destroy = 1;
 	}
@@ -2659,7 +2676,7 @@ static void cma_ndev_work_handler(struct

work_struct *_work)

drivers/infiniband/core/cma.c static void addr_handler(int status, struct

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	    id_priv->state == RDMA_CM_DEVICE_REMOVAL)
 		goto out;
 
-	if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+	if (cma_cm_event_handler(id_priv, &work->event)) {
 		cma_exch(id_priv, RDMA_CM_DESTROYING);
 		destroy = 1;
 	}
@@ -3062,7 +3079,7 @@ static void addr_handler(int status, struct

sockaddr *src_addr,

drivers/infiniband/core/cma.c static int cma_sidr_rep_handler(struct ib_cm_id

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	} else
 		event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
 
-	if (id_priv->id.event_handler(&id_priv->id, &event)) {
+	if (cma_cm_event_handler(id_priv, &event)) {
 		cma_exch(id_priv, RDMA_CM_DESTROYING);
 		mutex_unlock(&id_priv->handler_mutex);
 		rdma_destroy_id(&id_priv->id);
@@ -3709,7 +3726,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id

*cm_id,

drivers/infiniband/core/cma.c static int cma_resolve_ib_udp(struct

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 		goto out;
 	}
 
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 
 	rdma_destroy_ah_attr(&event.param.ud.ah_attr);
 	if (ret) {
@@ -3773,6 +3790,7 @@ static int cma_resolve_ib_udp(struct

rdma_id_private *id_priv,

drivers/infiniband/core/cma.c static int cma_connect_ib(struct rdma_id_private

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8);
 	req.max_cm_retries = CMA_MAX_CM_RETRIES;
 
+	trace_cm_send_sidr_req(id_priv);
 	ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req);
 	if (ret) {
 		ib_destroy_cm_id(id_priv->cm_id.ib);
@@ -3846,6 +3864,7 @@ static int cma_connect_ib(struct rdma_id_private

*id_priv,

drivers/infiniband/core/cma.c static int cma_accept_ib(struct rdma_id_private

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	req.max_cm_retries = CMA_MAX_CM_RETRIES;
 	req.srq = id_priv->srq ? 1 : 0;
 
+	trace_cm_send_req(id_priv);
 	ret = ib_send_cm_req(id_priv->cm_id.ib, &req);
 out:
 	if (ret && !IS_ERR(id)) {
@@ -3959,6 +3978,7 @@ static int cma_accept_ib(struct rdma_id_private

*id_priv,

drivers/infiniband/core/cma.c static int cma_send_sidr_rep(struct

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
 	rep.srq = id_priv->srq ? 1 : 0;
 
+	trace_cm_send_rep(id_priv);
 	ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);
 out:
 	return ret;
@@ -4008,6 +4028,7 @@ static int cma_send_sidr_rep(struct

rdma_id_private *id_priv,

drivers/infiniband/core/cma.c int rdma_reject(struct rdma_cm_id *id, const

Quoted 8 lines
drivers/infiniband/core/cma.c +1 -0
 	rep.private_data = private_data;
 	rep.private_data_len = private_data_len;
 
+	trace_cm_send_sidr_rep(id_priv);
 	return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep);
 }
 
@@ -4093,13 +4114,15 @@ int rdma_reject(struct rdma_cm_id *id, const

void *private_data,

drivers/infiniband/core/cma.c static int cma_ib_mc_handler(int status, struct

Quoted 34 lines
drivers/infiniband/core/cma.c +11 -4
 		return -EINVAL;
 
 	if (rdma_cap_ib_cm(id->device, id->port_num)) {
-		if (id->qp_type == IB_QPT_UD)
+		if (id->qp_type == IB_QPT_UD) {
 			ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0,
 						private_data, private_data_len);
-		else
+		} else {
+			trace_cm_send_rej(id_priv);
 			ret = ib_send_cm_rej(id_priv->cm_id.ib,
 					     IB_CM_REJ_CONSUMER_DEFINED, NULL,
 					     0, private_data, private_data_len);
+		}
 	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		ret = iw_cm_reject(id_priv->cm_id.iw,
 				   private_data, private_data_len);
@@ -4124,8 +4147,13 @@ int rdma_disconnect(struct rdma_cm_id *id)
 		if (ret)
 			goto out;
 		/* Initiate or respond to a disconnect. */
-		if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
-			ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
+		trace_cm_disconnect(id_priv);
+		if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) {
+			if (!ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0))
+				trace_cm_sent_drep(id_priv);
+		} else {
+			trace_cm_sent_dreq(id_priv);
+		}
 	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
 	} else
@@ -4191,7 +4219,7 @@ static int cma_ib_mc_handler(int status, struct

ib_sa_multicast *multicast)

drivers/infiniband/core/cma.c static int cma_remove_id_dev(struct

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 	} else
 		event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
 
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 
 	rdma_destroy_ah_attr(&event.param.ud.ah_attr);
 	if (ret) {
@@ -4626,7 +4654,7 @@ static int cma_remove_id_dev(struct

rdma_id_private *id_priv)

Review

Quoted 9 lines
drivers/infiniband/core/cma.c +1 -1
 		goto out;
 
 	event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
-	ret = id_priv->id.event_handler(&id_priv->id, &event);
+	ret = cma_cm_event_handler(id_priv, &event);
 out:
 	mutex_unlock(&id_priv->handler_mutex);
 	return ret;
(quoted diff) +0 -0

b/drivers/infiniband/core/cma_trace.c

Review

Quoted 22 lines

new file mode 100644
index 000000000000..1093fa813bc1

drivers/infiniband/core/cma_trace.c new file +16 -0
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Trace points for the RDMA Connection Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#define CREATE_TRACE_POINTS
+
+#include <rdma/rdma_cm.h>
+#include <rdma/ib_cm.h>
+#include "cma_priv.h"
+
+#include <trace/events/rdma_cma.h>
(quoted diff) +0 -0

b/include/trace/events/rdma_cma.h

Quoted 8 lines

new file mode 100644
index 000000000000..b6ccdade651c

include/trace/events/rdma_cma.h new file +3 -0
@@ -0,0 +1,218 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Trace point definitions for the RDMA Connect Manager.

include/trace/events/rdma_cma.h line 13

Quoted 10 lines
include/trace/events/rdma_cma.h new file +10 -0
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rdma_cma
+
+#if !defined(_TRACE_RDMA_CMA_H) ||

defined(TRACE_HEADER_MULTI_READ)

Quoted 11 lines

include/trace/events/rdma_cma.h line 19

Quoted 6 lines
include/trace/events/rdma_cma.h new file +6 -0
+
+#define _TRACE_RDMA_CMA_H
+
+#include <linux/tracepoint.h>
+#include <rdma/rdma_cm.h>
+#include "cma_priv.h"

Did it compile?
cma_priv.h is located in drivers/infiniband/core/ and unlikely to be accessible from "include/trace/events/rdma_cma.h" file.

Exactly , I have applied this patch and compile failed, and it seems that just simply remove "#cma_priv.h" works.

Quoted 5 lines

BTW, can you please add example of trace output to your commit message? It will help users to understand immediately what they are expected to see after this series is applied.

Thanks

#7 lore raw

Re: [PATCH v6 2/2] RDMA/cma: Add trace points in RDMA Connection Manager

In reply to Leon Romanovsky
Quoted 327 lines · Leon Romanovsky
Quoted 323 lines · Chuck Lever

Record state transitions as each connection is established. The IP address of both peers and the Type of Service is reported. These new trace points are not in performance hot paths.

Also, record each cm_event_handler call to ULPs. This eliminates the need for each ULP to add its own similar trace point in its CM event handler function.

These new trace points appear in a new trace subsystem called "rdma_cma".

This patch is based on previous work by:

Saeed Mahameed <[email protected]>
Mukesh Kacker <[email protected]>
Ajaykumar Hotchandani <[email protected]> Aron Silverton <[email protected]>
Avinash Repaka <[email protected]> Somasundaram Krishnasamy <[email protected]>

---

drivers/infiniband/core/Makefile    |    2
drivers/infiniband/core/cma.c       |   60 +++++++---
drivers/infiniband/core/cma_trace.c |   16 +++
include/trace/events/rdma_cma.h     |  218 +++++++++++++++++++++++++++++++++++
4 files changed, 279 insertions(+), 17 deletions(-)

create mode 100644 drivers/infiniband/core/cma_trace.c create mode 100644 include/trace/events/rdma_cma.h

drivers/infiniband/core/Makefile +0 -0
index 68d9e27c3c61..bab7b6f01982 100644
@@ -20,7 +20,7 @@ ib_cm-y :=            cm.o
 

iw_cm-y := iwcm.o iwpm_util.o iwpm_msg.o

drivers/infiniband/core/Makefile +1 -1
-rdma_cm-y :=            cma.o
+rdma_cm-y :=            cma.o cma_trace.o

rdma_cm-$(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS) += cma_configfs.o

drivers/infiniband/core/cma.c +3 -0
index d78f67623f24..5d5e63336954 100644
@@ -64,6 +64,8 @@
 #include "core_priv.h"
 #include "cma_priv.h"
 
+#include <trace/events/rdma_cma.h>
+
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("Generic RDMA CM Agent");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -1890,6 +1892,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv)
   if (ret)
       goto reject;
 
+    trace_cm_send_rtu(id_priv);
   ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0);
   if (ret)
       goto reject;
@@ -1898,6 +1901,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv)

reject:

   pr_debug_ratelimited("RDMA CM: CONNECT_ERROR: failed to handle reply. status %d\n", ret);
   cma_modify_qp_err(id_priv);
drivers/infiniband/core/cma.c +26 -10
+    trace_cm_send_rej(id_priv);
   ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
              NULL, 0, NULL, 0);
   return ret;
@@ -1917,6 +1921,13 @@ static void cma_set_rep_event_data(struct rdma_cm_event *event,
   event->param.conn.qp_num = rep_data->remote_qpn;
 }
 
+static int cma_cm_event_handler(struct rdma_id_private *id_priv,
+                struct rdma_cm_event *event)
+{
+    trace_cm_event_handler(id_priv, event);
+    return id_priv->id.event_handler(&id_priv->id, event);
+}
+
 static int cma_ib_handler(struct ib_cm_id *cm_id,
             const struct ib_cm_event *ib_event)
 {
@@ -1939,8 +1950,10 @@ static int cma_ib_handler(struct ib_cm_id *cm_id,
       break;
   case IB_CM_REP_RECEIVED:
       if (cma_comp(id_priv, RDMA_CM_CONNECT) &&
-            (id_priv->id.qp_type != IB_QPT_UD))
+            (id_priv->id.qp_type != IB_QPT_UD)) {
+            trace_cm_send_mra(id_priv);
           ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+        }
       if (id_priv->id.qp) {
           event.status = cma_rep_recv(id_priv);
           event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
@@ -1985,7 +1998,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id,
       goto out;
   }
 
-    ret = id_priv->id.event_handler(&id_priv->id, &event);
+    ret = cma_cm_event_handler(id_priv, &event);
   if (ret) {
       /* Destroy the CM ID by returning a non-zero value. */
       id_priv->cm_id.ib = NULL;
@@ -2146,6 +2159,7 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
   if (IS_ERR(listen_id))
       return PTR_ERR(listen_id);
 
+    trace_cm_req_handler(listen_id, ib_event->event);
   if (!cma_ib_check_req_qp_type(&listen_id->id, ib_event)) {
       ret = -EINVAL;
       goto net_dev_put;
@@ -2188,7 +2202,7 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
    * until we're done accessing it.
    */
   atomic_inc(&conn_id->refcount);
-    ret = conn_id->id.event_handler(&conn_id->id, &event);
+    ret = cma_cm_event_handler(conn_id, &event);
   if (ret)
       goto err3;
   /*
@@ -2197,8 +2211,10 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
    */
   mutex_lock(&lock);
   if (cma_comp(conn_id, RDMA_CM_CONNECT) &&
-        (conn_id->id.qp_type != IB_QPT_UD))
+        (conn_id->id.qp_type != IB_QPT_UD)) {
+        trace_cm_send_mra(cm_id->context);
       ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+    }
   mutex_unlock(&lock);
   mutex_unlock(&conn_id->handler_mutex);
   mutex_unlock(&listen_id->handler_mutex);
@@ -2313,7 +2329,7 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
   event.status = iw_event->status;
   event.param.conn.private_data = iw_event->private_data;
   event.param.conn.private_data_len = iw_event->private_data_len;
-    ret = id_priv->id.event_handler(&id_priv->id, &event);
+    ret = cma_cm_event_handler(id_priv, &event);
   if (ret) {
       /* Destroy the CM ID by returning a non-zero value. */
       id_priv->cm_id.iw = NULL;
@@ -2390,7 +2406,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
    * until we're done accessing it.
    */
   atomic_inc(&conn_id->refcount);
-    ret = conn_id->id.event_handler(&conn_id->id, &event);
+    ret = cma_cm_event_handler(conn_id, &event);
   if (ret) {
       /* User wants to destroy the CM ID */
       conn_id->cm_id.iw = NULL;
@@ -2462,6 +2478,7 @@ static int cma_listen_handler(struct rdma_cm_id *id,
 
   id->context = id_priv->id.context;
   id->event_handler = id_priv->id.event_handler;
+    trace_cm_event_handler(id_priv, event);
   return id_priv->id.event_handler(id, event);
 }
 
@@ -2636,7 +2653,7 @@ static void cma_work_handler(struct work_struct *_work)
   if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
       goto out;
 
-    if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+    if (cma_cm_event_handler(id_priv, &work->event)) {
       cma_exch(id_priv, RDMA_CM_DESTROYING);
       destroy = 1;
   }
@@ -2659,7 +2676,7 @@ static void cma_ndev_work_handler(struct work_struct *_work)
       id_priv->state == RDMA_CM_DEVICE_REMOVAL)
       goto out;
 
-    if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+    if (cma_cm_event_handler(id_priv, &work->event)) {
       cma_exch(id_priv, RDMA_CM_DESTROYING);
       destroy = 1;
   }
@@ -3062,7 +3079,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
   } else
       event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
 
-    if (id_priv->id.event_handler(&id_priv->id, &event)) {
+    if (cma_cm_event_handler(id_priv, &event)) {
       cma_exch(id_priv, RDMA_CM_DESTROYING);
       mutex_unlock(&id_priv->handler_mutex);
       rdma_destroy_id(&id_priv->id);
@@ -3709,7 +3726,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
       goto out;
   }
 
-    ret = id_priv->id.event_handler(&id_priv->id, &event);
+    ret = cma_cm_event_handler(id_priv, &event);
 
   rdma_destroy_ah_attr(&event.param.ud.ah_attr);
   if (ret) {
@@ -3773,6 +3790,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
   req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8);
   req.max_cm_retries = CMA_MAX_CM_RETRIES;
 
+    trace_cm_send_sidr_req(id_priv);
   ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req);
   if (ret) {
       ib_destroy_cm_id(id_priv->cm_id.ib);
@@ -3846,6 +3864,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
   req.max_cm_retries = CMA_MAX_CM_RETRIES;
   req.srq = id_priv->srq ? 1 : 0;
 
+    trace_cm_send_req(id_priv);
   ret = ib_send_cm_req(id_priv->cm_id.ib, &req);

out:

   if (ret && !IS_ERR(id)) {
drivers/infiniband/core/cma.c +1 -0
@@ -3959,6 +3978,7 @@ static int cma_accept_ib(struct rdma_id_private *id_priv,
   rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
   rep.srq = id_priv->srq ? 1 : 0;
 
+    trace_cm_send_rep(id_priv);
   ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);

out:

   return ret;
drivers/infiniband/core/cma.c +14 -6
@@ -4008,6 +4028,7 @@ static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
   rep.private_data = private_data;
   rep.private_data_len = private_data_len;
 
+    trace_cm_send_sidr_rep(id_priv);
   return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep);
 }
 
@@ -4093,13 +4114,15 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data,
       return -EINVAL;
 
   if (rdma_cap_ib_cm(id->device, id->port_num)) {
-        if (id->qp_type == IB_QPT_UD)
+        if (id->qp_type == IB_QPT_UD) {
           ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0,
                       private_data, private_data_len);
-        else
+        } else {
+            trace_cm_send_rej(id_priv);
           ret = ib_send_cm_rej(id_priv->cm_id.ib,
                        IB_CM_REJ_CONSUMER_DEFINED, NULL,
                        0, private_data, private_data_len);
+        }
   } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
       ret = iw_cm_reject(id_priv->cm_id.iw,
                  private_data, private_data_len);
@@ -4124,8 +4147,13 @@ int rdma_disconnect(struct rdma_cm_id *id)
       if (ret)
           goto out;
       /* Initiate or respond to a disconnect. */
-        if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
-            ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
+        trace_cm_disconnect(id_priv);
+        if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) {
+            if (!ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0))
+                trace_cm_sent_drep(id_priv);
+        } else {
+            trace_cm_sent_dreq(id_priv);
+        }
   } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
       ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
   } else
@@ -4191,7 +4219,7 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
   } else
       event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
 
-    ret = id_priv->id.event_handler(&id_priv->id, &event);
+    ret = cma_cm_event_handler(id_priv, &event);
 
   rdma_destroy_ah_attr(&event.param.ud.ah_attr);
   if (ret) {
@@ -4626,7 +4654,7 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
       goto out;
 
   event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
-    ret = id_priv->id.event_handler(&id_priv->id, &event);
+    ret = cma_cm_event_handler(id_priv, &event);

out:

   mutex_unlock(&id_priv->handler_mutex);
   return ret;
drivers/infiniband/core/cma_trace.c new file +16 -0
new file mode 100644
index 000000000000..1093fa813bc1
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Trace points for the RDMA Connection Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#define CREATE_TRACE_POINTS
+
+#include <rdma/rdma_cm.h>
+#include <rdma/ib_cm.h>
+#include "cma_priv.h"
+
+#include <trace/events/rdma_cma.h>
include/trace/events/rdma_cma.h new file +13 -0
new file mode 100644
index 000000000000..b6ccdade651c
@@ -0,0 +1,218 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Trace point definitions for the RDMA Connect Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rdma_cma
+
+#if !defined(_TRACE_RDMA_CMA_H) || defined(TRACE_HEADER_MULTI_READ)
Quoted 8 lines

include/trace/events/rdma_cma.h line 19

Quoted 6 lines
include/trace/events/rdma_cma.h new file +6 -0
+
+#define _TRACE_RDMA_CMA_H
+
+#include <linux/tracepoint.h>
+#include <rdma/rdma_cm.h>
+#include "cma_priv.h"

Did it compile?

Yes, it compiles for me, and passes lkp as well.

I admit though that it seems like a brittle arrangement. Might be better off moving rdma_cma.h to drivers/infiniband/core/ .

Quoted 4 lines

cma_priv.h is located in drivers/infiniband/core/ and unlikely to be accessible from "include/trace/events/rdma_cma.h" file.

BTW, can you please add example of trace output to your commit message?

Will do.

Quoted 4 lines

It will help users to understand immediately what they are expected to see after this series is applied.

Thanks

#8 lore raw

Re: [PATCH v6 2/2] RDMA/cma: Add trace points in RDMA Connection Manager

Quoted 27 lines · Chuck Lever
Quoted 18 lines
Quoted 18 lines
include/trace/events/rdma_cma.h new file +14 -0
new file mode 100644
index 000000000000..b6ccdade651c
+++ b/include/trace/events/rdma_cma.h
@@ -0,0 +1,218 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Trace point definitions for the RDMA Connect Manager.
+ *
+ * Author: Chuck Lever <[email protected]>
+ *
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rdma_cma
+
+#if !defined(_TRACE_RDMA_CMA_H) || defined(TRACE_HEADER_MULTI_READ)
Quoted 8 lines

include/trace/events/rdma_cma.h line 19

Quoted 6 lines
include/trace/events/rdma_cma.h new file +6 -0
+
+#define _TRACE_RDMA_CMA_H
+
+#include <linux/tracepoint.h>
+#include <rdma/rdma_cm.h>
+#include "cma_priv.h"

Did it compile?

Quoted 4 lines

Yes, it compiles for me, and passes lkp as well.

I admit though that it seems like a brittle arrangement. Might be better off moving rdma_cma.h to drivers/infiniband/core/ .

The more headers that can move out of include the better, IMHO

Jason