Proposed trace points for RDMA/core
Subsystems (2)
v8 cover Proposed trace points for RDMA/core
Hi-
Refresh of the RDMA/core trace point patches.
I've been working on improving how RPC/RDMA handles device removal and disconnect, so I've added some trace points in the core CMA code to report rdma_cm_id lifetime-related events.
I've also had need to record creation and release of MRs. I had an old patch to do that, so that is also included here. The patch description can be improved, but it's ready for review comments, at least.
Changes since v7:
- Capture the return value from the ULP's CM event handler
- Record the lifetime of each rdma_cm_id
- Include an example patch for capturing MR lifetime
Changes since v6:
- Move include/trace/events/rmda_cma.h to drivers/infiniband/core/cma_trace.h
- Add sample trace log output to the patch descriptions
- Back to the inlined version of ib_poll_cq()
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 (3):
RDMA/cma: Add trace points in RDMA Connection Manager RDMA/core: Trace points for diagnosing completion queue issues RDMA/core: Add trace points to follow MR allocation
drivers/infiniband/core/Makefile | 4 drivers/infiniband/core/cma.c | 68 +++++- drivers/infiniband/core/cma_trace.c | 16 ++ drivers/infiniband/core/cma_trace.h | 302 ++++++++++++++++++++++++++++ drivers/infiniband/core/cq.c | 27 ++- drivers/infiniband/core/trace.c | 14 + drivers/infiniband/core/verbs.c | 39 +++- include/rdma/ib_verbs.h | 5 include/trace/events/rdma_core.h | 373 +++++++++++++++++++++++++++++++++++ 9 files changed, 816 insertions(+), 32 deletions(-) create mode 100644 drivers/infiniband/core/cma_trace.c create mode 100644 drivers/infiniband/core/cma_trace.h create mode 100644 drivers/infiniband/core/trace.c create mode 100644 include/trace/events/rdma_core.h
--
Chuck Lever
PATCH v8 1/3 RDMA/cma: Add trace points in RDMA Connection Manager
Record state transitions as each connection is established. The IP address of both peers and the Type of Service is reported. These 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".
Sample events:
kworker/u24:2-2127 [011] 696.746254: cm_event_handler: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0 ADDR_RESOLVED (0/0)
kworker/u24:2-2127 [011] 696.746880: cm_event_handler: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0 ROUTE_RESOLVED (2/0)
kworker/u28:2-2214 [001] 696.776316: cm_send_req: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0 qp_num=526
kworker/1:3-972 [001] 696.777603: cm_send_mra: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0
kworker/1:3-972 [001] 696.778062: cm_send_rtu: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0
kworker/1:3-972 [001] 696.778198: cm_event_handler: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0 ESTABLISHED (9/0)
kworker/1:3-972 [001] 700.621750: cm_disconnect: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0
kworker/1:3-972 [001] 700.621881: cm_sent_dreq: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0
kworker/3:2-512 [003] 700.622354: cm_event_handler: cm_id.id=1 src: 192.168.2.51:57696 dst: 192.168.2.55:20049 tos=0 DISCONNECTED (10/0)Some features to note:
- restracker ID of the rdma_cm_id is tagged on each trace event
- The source and destination IP addresses and TOS are reported
- CM event upcalls are shown with decoded event and status
- CM state transitions are reported
- rdma_cm_id lifetime events are captured
- The latency of ULP CM event handlers is reported
- Device removal and insertion is reported
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 | 68 ++++++-- drivers/infiniband/core/cma_trace.c | 16 ++ drivers/infiniband/core/cma_trace.h | 302 +++++++++++++++++++++++++++++++++++ 4 files changed, 371 insertions(+), 17 deletions(-) create mode 100644 drivers/infiniband/core/cma_trace.c create mode 100644 drivers/infiniband/core/cma_trace.h
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 +52 -16
243 lines not on this page · raw message
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 "cma_trace.h"
drivers/infiniband/core/cma_trace.h new file +302 -0
302 lines not on this page · raw message
PATCH v8 2/3 RDMA/core: Trace points for diagnosing completion queue issues
In reply to Chuck LeverSample trace events:
kworker/u29:0-300 [007] 120.042217: cq_alloc: cq.id=4 nr_cqe=161 comp_vector=2 poll_ctx=WORKQUEUE
<idle>-0 [002] 120.056292: cq_schedule: cq.id=4
kworker/2:1H-482 [002] 120.056402: cq_process: cq.id=4 wake-up took 109 [us] from interrupt
kworker/2:1H-482 [002] 120.056407: cq_poll: cq.id=4 requested 16, returned 1
<idle>-0 [002] 120.067503: cq_schedule: cq.id=4
kworker/2:1H-482 [002] 120.067537: cq_process: cq.id=4 wake-up took 34 [us] from interrupt
kworker/2:1H-482 [002] 120.067541: cq_poll: cq.id=4 requested 16, returned 1
<idle>-0 [002] 120.067657: cq_schedule: cq.id=4
kworker/2:1H-482 [002] 120.067672: cq_process: cq.id=4 wake-up took 15 [us] from interrupt
kworker/2:1H-482 [002] 120.067674: cq_poll: cq.id=4 requested 16, returned 1...
systemd-1 [002] 122.392653: cq_schedule: cq.id=4
kworker/2:1H-482 [002] 122.392688: cq_process: cq.id=4 wake-up took 35 [us] from interrupt
kworker/2:1H-482 [002] 122.392693: cq_poll: cq.id=4 requested 16, returned 16
kworker/2:1H-482 [002] 122.392836: cq_poll: cq.id=4 requested 16, returned 16
kworker/2:1H-482 [002] 122.392970: cq_poll: cq.id=4 requested 16, returned 16
kworker/2:1H-482 [002] 122.393083: cq_poll: cq.id=4 requested 16, returned 16
kworker/2:1H-482 [002] 122.393195: cq_poll: cq.id=4 requested 16, returned 3Several features to note in this output:
- The WCE count and context type are reported at allocation time
- The CPU and kworker for each CQ is evident
- The CQ's restracker ID is tagged on each trace event
- CQ poll scheduling latency is measured
- Details about how often single completions occur versus multiple completions are evident
- The cost of the ULP's completion handler is recorded
--- drivers/infiniband/core/Makefile | 2 drivers/infiniband/core/cq.c | 27 ++++ drivers/infiniband/core/trace.c | 14 ++ include/rdma/ib_verbs.h | 5 + include/trace/events/rdma_core.h | 250 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 294 insertions(+), 4 deletions(-) create mode 100644 drivers/infiniband/core/trace.c create mode 100644 include/trace/events/rdma_core.h
drivers/infiniband/core/Makefile +1 -1
@@ -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 +24 -3
@@ -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,18 +68,29 @@ static void rdma_dim_init(struct ib_cq *cq)INIT_WORK (&dim->work, ib_cq_rdma_dim_work); } +static int __poll_cq (struct ib_cq *cq,int num_entries,struct ib_wc *wc) +{ +int rc; + + rc =ib_poll_cq (cq, num_entries, wc); +trace_cq_poll (cq, num_entries, rc); +return rc; +} +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 * minimum here. */ -while ((n =ib_poll_cq (cq,min_t (u32, batch, - budget - completed), wcs)) >0 ) { +while ((n =__poll_cq (cq,min_t (u32, batch, + budget - completed), wcs)) >0 ) {for (i =0 ; i < n; i++) {struct ib_wc *wc = &wcs[i];
@@ -131,8 +145,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 +159,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 +179,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 +257,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 +267,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 +324,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
@@ -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 +5 -0
@@ -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: */
include/trace/events/rdma_core.h new file +250 -0
250 lines not on this page · raw message
PATCH v8 3/3 RDMA/core: Add trace points to follow MR allocation
In reply to Chuck LeverTrack the lifetime of ib_mr objects.
--- drivers/infiniband/core/verbs.c | 39 +++++++++--- include/trace/events/rdma_core.h | 123 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 11 deletions(-)
drivers/infiniband/core/verbs.c +28 -11
@@ -52,6 +52,7 @@#include <rdma/rw.h> #include "core_priv.h" +#include <trace/events/rdma_core.h> static int ib_resolve_eth_dmac (struct ib_device *device,struct rdma_ah_attr *ah_attr);
@@ -1995,6 +1996,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)struct ib_sig_attrs *sig_attrs = mr->sig_attrs;int ret; +trace_mr_dereg (mr);rdma_restrack_del (&mr->res); ret = mr->device->ops.dereg_mr (mr, udata);if (!ret) {
@@ -2026,11 +2028,16 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type, {struct ib_mr *mr; -if (!pd->device->ops.alloc_mr) -return ERR_PTR (-EOPNOTSUPP ); +if (!pd->device->ops.alloc_mr) { + mr =ERR_PTR (-EOPNOTSUPP ); + goto out; + } -if (WARN_ON_ONCE (mr_type ==IB_MR_TYPE_INTEGRITY )) -return ERR_PTR (-EINVAL ); +if (mr_type ==IB_MR_TYPE_INTEGRITY ) { +WARN_ON_ONCE (1 ); + mr =ERR_PTR (-EINVAL ); + goto out; + } mr = pd->device->ops.alloc_mr (pd, mr_type, max_num_sg, udata);if (!IS_ERR (mr)) {
@@ -2046,6 +2053,8 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type, mr->sig_attrs =NULL ; } +out: +trace_mr_alloc (pd, mr_type, max_num_sg, mr);return mr; }EXPORT_SYMBOL (ib_alloc_mr_user);
@@ -2070,21 +2079,27 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,struct ib_sig_attrs *sig_attrs;if (!pd->device->ops.alloc_mr_integrity || - !pd->device->ops.map_mr_sg_pi) -return ERR_PTR (-EOPNOTSUPP ); + !pd->device->ops.map_mr_sg_pi) { + mr =ERR_PTR (-EOPNOTSUPP ); + goto out; + } -if (!max_num_meta_sg) -return ERR_PTR (-EINVAL ); +if (!max_num_meta_sg) { + mr =ERR_PTR (-EINVAL ); + goto out; + } sig_attrs =kzalloc (sizeof (struct ib_sig_attrs ),GFP_KERNEL ); -if (!sig_attrs) -return ERR_PTR (-ENOMEM ); +if (!sig_attrs) { + mr =ERR_PTR (-ENOMEM ); + goto out; + } mr = pd->device->ops.alloc_mr_integrity (pd, max_num_data_sg, max_num_meta_sg);if (IS_ERR (mr)) {kfree (sig_attrs); -return mr; + goto out; } mr->device = pd->device;
@@ -2098,6 +2113,8 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd, mr->type =IB_MR_TYPE_INTEGRITY ; mr->sig_attrs = sig_attrs; +out: +trace_mr_integ_alloc (pd, max_num_data_sg, max_num_meta_sg, mr);return mr; }EXPORT_SYMBOL (ib_alloc_mr_integrity);
include/trace/events/rdma_core.h +123 -0
129 lines not on this page · raw message