Skip to content

Commit 7790db4

Browse files
committed
providers: add support for USDT tracing using libbpf/usdt
Provide lightweight USDT tracing as an alternative to LTTng. This piggybacks on the existing tracing code added for LTTng for a minimal set of changes. > $ sudo bpftrace -l usdt:build/lib/lib*.so:* > usdt:build/lib/libefa-rdmav59.so:rdma_core_efa:post_recv > usdt:build/lib/libefa-rdmav59.so:rdma_core_efa:post_send > usdt:build/lib/libefa-rdmav59.so:rdma_core_efa:process_completion > usdt:build/lib/libefa.so:rdma_core_efa:post_recv > usdt:build/lib/libefa.so:rdma_core_efa:post_send > usdt:build/lib/libefa.so:rdma_core_efa:process_completion > usdt:build/lib/libhns-rdmav59.so:rdma_core_hns:poll_cq > usdt:build/lib/libhns-rdmav59.so:rdma_core_hns:post_recv > usdt:build/lib/libhns-rdmav59.so:rdma_core_hns:post_send > usdt:build/lib/libhns.so:rdma_core_hns:poll_cq > usdt:build/lib/libhns.so:rdma_core_hns:post_recv > usdt:build/lib/libhns.so:rdma_core_hns:post_send > usdt:build/lib/libmlx5-rdmav59.so:rdma_core_mlx5:post_send > usdt:build/lib/libmlx5.so:rdma_core_mlx5:post_send > usdt:build/lib/librxe-rdmav59.so:rdma_core_rxe:post_send The USDT header used here is from the libbpf/usdt project at https://github.com/libbpf/usdt.git Further background discussion for this commit is included in linux-rdma#1621 Signed-off-by: Nathan Scott <[email protected]>
1 parent 7528827 commit 7790db4

File tree

10 files changed

+591
-14
lines changed

10 files changed

+591
-14
lines changed

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# Use the historical search path for providers, in the standard system library.
2525
# -DNO_COMPAT_SYMS=1 (default disabled)
2626
# Do not generate backwards compatibility symbols in the shared
27-
# libraries. This may is necessary if using a dynmic linker that does
27+
# libraries. This may be necessary if using a dynamic linker that does
2828
# not support symbol versions, such as uclibc.
2929
# -DIOCTL_MODE=write (default both)
3030
# Disable new kABI ioctl() support and support only the legacy write
@@ -52,8 +52,10 @@
5252
# Disable man pages. Allows rdma-core to be built and installed
5353
# (without man pages) when neither pandoc/rst2man nor the pandoc-prebuilt
5454
# directory are available.
55-
# -DENABLE_LTTNG (default, no tracing support)
55+
# -DENABLE_LTTNG (default, no LTTng tracing support)
5656
# Enable LTTng tracing.
57+
# -DENABLE_USDT (default, no USDT tracing support)
58+
# Enable USDT tracing.
5759

5860
if (${CMAKE_VERSION} VERSION_LESS "3.18.1")
5961
# Centos 7 support
@@ -573,6 +575,11 @@ if (DEFINED ENABLE_LTTNG)
573575
add_definitions(-DLTTNG_ENABLED)
574576
endif()
575577

578+
# User Static-Defined Tracing (USDT) support
579+
if (DEFINED ENABLE_USDT)
580+
add_definitions(-DUSDT_ENABLED)
581+
endif()
582+
576583
#-------------------------
577584
# Apply fixups
578585

Documentation/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ that are designed to weed out bugs.
6666
Serious errors will result in a red X in the PR and will need to be corrected.
6767
Less serious errors, including checkpatch related, will show up with a green
6868
check but it is necessary to check the details to see that everything is
69-
appropriate. checkpatch is an informative too, not all of its feedback is
69+
appropriate. checkpatch is an informative tool, not all of its feedback is
7070
appropriate to fix.
7171

7272
A build similar to AZP can be run locally using docker and the

providers/efa/efa_trace.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,19 @@ LTTNG_UST_TRACEPOINT_EVENT(
109109

110110
#include <lttng/tracepoint-event.h>
111111

112-
#else
112+
#elif defined (USDT_ENABLED)
113113

114114
#ifndef __EFA_TRACE_H__
115115
#define __EFA_TRACE_H__
116116

117+
#include <util/usdt.h>
118+
119+
#define rdma_tracepoint(arg...) USDT(arg)
120+
121+
#else /* __EFA_TRACE_H__*/
122+
117123
#define rdma_tracepoint(arg...)
118124

119125
#endif /* __EFA_TRACE_H__*/
120126

121-
#endif /* defined(LTTNG_ENABLED) */
127+
#endif /* defined(LTTNG_ENABLED) || defined(USDT_ENABLED) */

providers/efa/verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ static void efa_set_common_ctrl_flags(struct efa_io_tx_meta_desc *desc,
21702170
EFA_SET(&desc->ctrl2, EFA_IO_TX_META_DESC_COMP_REQ, 1);
21712171
}
21722172

2173-
#ifdef LTTNG_ENABLED
2173+
#if defined(LTTNG_ENABLED) || defined(USDT_ENABLED)
21742174
static uint32_t efa_get_wqe_length(struct efa_io_tx_wqe *tx_wqe)
21752175
{
21762176
enum efa_io_send_op_type op_type;

providers/hns/hns_roce_u_hw_v2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static int parse_cqe_for_cq(struct hns_roce_context *ctx, struct hns_roce_cq *cq
678678
return 0;
679679
}
680680

681-
#ifdef LTTNG_ENABLED
681+
#if defined(LTTNG_ENABLED) || defined(USDT_ENABLED)
682682
static uint8_t read_wc_sl(struct hns_roce_qp *hr_qp,
683683
struct hns_roce_v2_cqe *cqe,
684684
struct ibv_wc *wc)
@@ -687,6 +687,7 @@ static uint8_t read_wc_sl(struct hns_roce_qp *hr_qp,
687687
hr_reg_read(cqe, CQE_S_R) == CQE_FOR_RQ ?
688688
wc->sl : UINT8_MAX;
689689
}
690+
#endif
690691

691692
static uint32_t read_wc_rqpn(struct hns_roce_qp *hr_qp,
692693
struct hns_roce_v2_cqe *cqe,
@@ -750,7 +751,6 @@ static uint8_t get_send_wr_tclass(struct ibv_send_wr *wr,
750751
return qp_type == IBV_QPT_UD ?
751752
to_hr_ah(wr->wr.ud.ah)->av.tclass : UINT8_MAX;
752753
}
753-
#endif
754754

755755
static int hns_roce_poll_one(struct hns_roce_context *ctx,
756756
struct hns_roce_qp **cur_qp, struct hns_roce_cq *cq,

providers/hns/hns_roce_u_trace.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,19 @@ LTTNG_UST_TRACEPOINT_EVENT(
121121

122122
#include <lttng/tracepoint-event.h>
123123

124-
#else
124+
#elif defined(USDT_ENABLED)
125125

126126
#ifndef __HNS_TRACE_H__
127127
#define __HNS_TRACE_H__
128128

129+
#include <util/usdt.h>
130+
131+
#define rdma_tracepoint(arg...) USDT(arg)
132+
133+
#else
134+
129135
#define rdma_tracepoint(arg...)
130136

131137
#endif /* __HNS_TRACE_H__*/
132138

133-
#endif /* defined(LTTNG_ENABLED) */
139+
#endif /* defined(LTTNG_ENABLED) || defined(USDT_ENABLED) */

providers/mlx5/mlx5_trace.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ LTTNG_UST_TRACEPOINT_EVENT(
4747

4848
#include <lttng/tracepoint-event.h>
4949

50-
#else
50+
#elif defined(USDT_ENABLED)
5151

5252
#ifndef __MLX5_TRACE_H__
5353
#define __MLX5_TRACE_H__
5454

55+
#include <util/usdt.h>
56+
57+
#define rdma_tracepoint(arg...) USDT(arg)
58+
59+
#else
60+
5561
#define rdma_tracepoint(arg...)
5662

5763
#endif /* __MLX5_TRACE_H__*/
5864

59-
#endif /* defined(LTTNG_ENABLED) */
65+
#endif /* defined(LTTNG_ENABLED) || defined(USDT_ENABLED) */

providers/rxe/rxe_trace.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ LTTNG_UST_TRACEPOINT_EVENT(
4747

4848
#include <lttng/tracepoint-event.h>
4949

50-
#else
50+
#elif defined(USDT_ENABLED)
5151

5252
#ifndef __RXE_TRACE_H__
5353
#define __RXE_TRACE_H__
5454

55+
#include <util/usdt.h>
56+
57+
#define rdma_tracepoint(arg...) USDT(arg)
58+
59+
#else
60+
5561
#define rdma_tracepoint(arg...)
5662

5763
#endif /* __RXE_TRACE_H__*/
5864

59-
#endif /* defined(LTTNG_ENABLED) */
65+
#endif /* defined(LTTNG_ENABLED) || defined(USDT_ENABLED) */

util/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ publish_internal_headers(util
66
node_name_map.h
77
rdma_nl.h
88
symver.h
9+
usdt.h
910
util.h
1011
)
1112

0 commit comments

Comments
 (0)