
From: wenglianfa <wenglianfa@huawei.com> Create extra provider libraries for tracing so that the regular libraries does not need to have a dependency on LTTng. For example, there will be a new libhns_trace-rdmav*.so for hns tracing. Usage example: $ lttng create my_session $ lttng enable-event -u rdma_core_hns:post_send $ lttng start $ LD_PRELOAD=/usr/lib64/libibverbs/libhns_trace-rdmav*.so ib_send_bw -d hns_0 $ LD_PRELOAD=/usr/lib64/libibverbs/libhns_trace-rdmav*.so ib_send_bw -d hns_0 10.10.10.10 $ lttng stop $ lttng view No additional dependencies or performance penalty will be introduced if users don't load the tracing library explicitly as shown above. This change involves all providers that support LTTng tracing, including efa, hns, mlx5 and rxe. Signed-off-by: wenglianfa <wenglianfa@huawei.com> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- libibverbs/verbs.h | 4 ++++ providers/efa/CMakeLists.txt | 11 +++++++---- providers/efa/efa_trace.c | 1 - providers/efa/verbs.c | 3 +++ providers/hns/CMakeLists.txt | 11 +++++++---- providers/hns/hns_roce_u_hw_v2.c | 3 +++ providers/hns/hns_roce_u_trace.c | 1 - providers/mlx5/CMakeLists.txt | 11 +++++++---- providers/mlx5/mlx5_trace.c | 1 - providers/mlx5/qp.c | 3 +++ providers/rxe/CMakeLists.txt | 11 +++++++---- providers/rxe/rxe.c | 3 +++ providers/rxe/rxe_trace.c | 1 - 13 files changed, 44 insertions(+), 20 deletions(-) diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 47cdc067e..b8ed26470 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -2284,6 +2284,10 @@ extern const struct verbs_device_ops verbs_provider_qedr; extern const struct verbs_device_ops verbs_provider_rxe; extern const struct verbs_device_ops verbs_provider_siw; extern const struct verbs_device_ops verbs_provider_vmw_pvrdma; +extern const struct verbs_device_ops verbs_provider_efa_trace; +extern const struct verbs_device_ops verbs_provider_hns_trace; +extern const struct verbs_device_ops verbs_provider_mlx5_trace; +extern const struct verbs_device_ops verbs_provider_rxe_trace; extern const struct verbs_device_ops verbs_provider_all; extern const struct verbs_device_ops verbs_provider_none; void ibv_static_providers(void *unused, ...); diff --git a/providers/efa/CMakeLists.txt b/providers/efa/CMakeLists.txt index 865317446..12bac46ba 100644 --- a/providers/efa/CMakeLists.txt +++ b/providers/efa/CMakeLists.txt @@ -1,10 +1,11 @@ if (ENABLE_LTTNG AND LTTNGUST_FOUND) - set(TRACE_FILE efa_trace.c) + rdma_provider(efa_trace + efa_trace.c + ) endif() rdma_shared_provider(efa libefa.map 1 1.3.${PACKAGE_VERSION} - ${TRACE_FILE} efa.c verbs.c ) @@ -16,10 +17,12 @@ publish_headers(infiniband rdma_pkg_config("efa" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}") if (ENABLE_LTTNG AND LTTNGUST_FOUND) - target_include_directories(efa PUBLIC ".") target_link_libraries(efa LINK_PRIVATE LTTng::UST) + target_include_directories(efa_trace-rdmav${IBVERBS_PABI_VERSION} PUBLIC ".") + target_link_libraries(efa_trace-rdmav${IBVERBS_PABI_VERSION} LINK_PRIVATE LTTng::UST) if (ENABLE_STATIC) - target_include_directories(efa-static PUBLIC ".") target_link_libraries(efa-static LINK_PRIVATE LTTng::UST) + target_include_directories(efa_trace PUBLIC ".") + target_link_libraries(efa_trace LINK_PRIVATE LTTng::UST) endif() endif() diff --git a/providers/efa/efa_trace.c b/providers/efa/efa_trace.c index 95178e4ba..4dbf91a74 100644 --- a/providers/efa/efa_trace.c +++ b/providers/efa/efa_trace.c @@ -4,6 +4,5 @@ */ #define LTTNG_UST_TRACEPOINT_CREATE_PROBES -#define LTTNG_UST_TRACEPOINT_DEFINE #include "efa_trace.h" diff --git a/providers/efa/verbs.c b/providers/efa/verbs.c index ddb1af989..ea1096e91 100644 --- a/providers/efa/verbs.c +++ b/providers/efa/verbs.c @@ -22,6 +22,9 @@ #include "efa_io_regs_defs.h" #include "efadv.h" #include "verbs.h" + +#define LTTNG_UST_TRACEPOINT_DEFINE +#define LTTNG_UST_TRACEPOINT_PROBE_DYNAMIC_LINKAGE #include "efa_trace.h" #define EFA_DEV_CAP(ctx, cap) \ diff --git a/providers/hns/CMakeLists.txt b/providers/hns/CMakeLists.txt index 7277cd65f..c06611a57 100644 --- a/providers/hns/CMakeLists.txt +++ b/providers/hns/CMakeLists.txt @@ -1,10 +1,11 @@ if (ENABLE_LTTNG AND LTTNGUST_FOUND) - set(TRACE_FILE hns_roce_u_trace.c) + rdma_provider(hns_trace + hns_roce_u_trace.c + ) endif() rdma_shared_provider(hns libhns.map 1 1.0.${PACKAGE_VERSION} - ${TRACE_FILE} hns_roce_u.c hns_roce_u_buf.c hns_roce_u_db.c @@ -19,10 +20,12 @@ publish_headers(infiniband rdma_pkg_config("hns" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}") if (ENABLE_LTTNG AND LTTNGUST_FOUND) - target_include_directories(hns PUBLIC ".") target_link_libraries(hns LINK_PRIVATE LTTng::UST) + target_include_directories(hns_trace-rdmav${IBVERBS_PABI_VERSION} PUBLIC ".") + target_link_libraries(hns_trace-rdmav${IBVERBS_PABI_VERSION} LINK_PRIVATE LTTng::UST) if (ENABLE_STATIC) - target_include_directories(hns-static PUBLIC ".") target_link_libraries(hns-static LINK_PRIVATE LTTng::UST) + target_include_directories(hns_trace PUBLIC ".") + target_link_libraries(hns_trace LINK_PRIVATE LTTng::UST) endif() endif() diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 784841f43..9a12183d8 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -38,6 +38,9 @@ #include "hns_roce_u.h" #include "hns_roce_u_db.h" #include "hns_roce_u_hw_v2.h" + +#define LTTNG_UST_TRACEPOINT_DEFINE +#define LTTNG_UST_TRACEPOINT_PROBE_DYNAMIC_LINKAGE #include "hns_roce_u_trace.h" #define HR_IBV_OPC_MAP(ib_key, hr_key) \ diff --git a/providers/hns/hns_roce_u_trace.c b/providers/hns/hns_roce_u_trace.c index 812f54cfe..aa66d3856 100644 --- a/providers/hns/hns_roce_u_trace.c +++ b/providers/hns/hns_roce_u_trace.c @@ -4,6 +4,5 @@ */ #define LTTNG_UST_TRACEPOINT_CREATE_PROBES -#define LTTNG_UST_TRACEPOINT_DEFINE #include "hns_roce_u_trace.h" diff --git a/providers/mlx5/CMakeLists.txt b/providers/mlx5/CMakeLists.txt index 92f4e1b18..47e0f601a 100644 --- a/providers/mlx5/CMakeLists.txt +++ b/providers/mlx5/CMakeLists.txt @@ -11,12 +11,13 @@ if (MLX5_MW_DEBUG) endif() if (ENABLE_LTTNG AND LTTNGUST_FOUND) - set(TRACE_FILE mlx5_trace.c) + rdma_provider(mlx5_trace + mlx5_trace.c +) endif() rdma_shared_provider(mlx5 libmlx5.map 1 1.25.${PACKAGE_VERSION} - ${TRACE_FILE} buf.c cq.c dbrec.c @@ -55,10 +56,12 @@ publish_headers(infiniband rdma_pkg_config("mlx5" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}") if (ENABLE_LTTNG AND LTTNGUST_FOUND) - target_include_directories(mlx5 PUBLIC ".") target_link_libraries(mlx5 LINK_PRIVATE LTTng::UST) + target_include_directories(mlx5_trace-rdmav${IBVERBS_PABI_VERSION} PUBLIC ".") + target_link_libraries(mlx5_trace-rdmav${IBVERBS_PABI_VERSION} LINK_PRIVATE LTTng::UST) if (ENABLE_STATIC) - target_include_directories(mlx5-static PUBLIC ".") target_link_libraries(mlx5-static LINK_PRIVATE LTTng::UST) + target_include_directories(mlx5_trace PUBLIC ".") + target_link_libraries(mlx5_trace LINK_PRIVATE LTTng::UST) endif() endif() diff --git a/providers/mlx5/mlx5_trace.c b/providers/mlx5/mlx5_trace.c index 07917f620..3b6e88929 100644 --- a/providers/mlx5/mlx5_trace.c +++ b/providers/mlx5/mlx5_trace.c @@ -4,6 +4,5 @@ */ #define LTTNG_UST_TRACEPOINT_CREATE_PROBES -#define LTTNG_UST_TRACEPOINT_DEFINE #include "mlx5_trace.h" diff --git a/providers/mlx5/qp.c b/providers/mlx5/qp.c index 76e1a428b..c38e6f26d 100644 --- a/providers/mlx5/qp.c +++ b/providers/mlx5/qp.c @@ -42,6 +42,9 @@ #include "mlx5.h" #include "mlx5_ifc.h" + +#define LTTNG_UST_TRACEPOINT_DEFINE +#define LTTNG_UST_TRACEPOINT_PROBE_DYNAMIC_LINKAGE #include "mlx5_trace.h" #include "wqe.h" diff --git a/providers/rxe/CMakeLists.txt b/providers/rxe/CMakeLists.txt index 8a0a16842..77e82b21c 100644 --- a/providers/rxe/CMakeLists.txt +++ b/providers/rxe/CMakeLists.txt @@ -1,17 +1,20 @@ if (ENABLE_LTTNG AND LTTNGUST_FOUND) - set(TRACE_FILE rxe_trace.c) + rdma_provider(rxe_trace + rxe_trace.c + ) endif() rdma_provider(rxe - ${TRACE_FILE} rxe.c ) if (ENABLE_LTTNG AND LTTNGUST_FOUND) - target_include_directories("rxe-rdmav${IBVERBS_PABI_VERSION}" PUBLIC ".") target_link_libraries("rxe-rdmav${IBVERBS_PABI_VERSION}" LINK_PRIVATE LTTng::UST) + target_include_directories("rxe_trace-rdmav${IBVERBS_PABI_VERSION}" PUBLIC ".") + target_link_libraries("rxe_trace-rdmav${IBVERBS_PABI_VERSION}" LINK_PRIVATE LTTng::UST) if (ENABLE_STATIC) - target_include_directories(rxe PUBLIC ".") target_link_libraries(rxe LINK_PRIVATE LTTng::UST) + target_include_directories("rxe_trace" PUBLIC ".") + target_link_libraries("rxe_trace" LINK_PRIVATE LTTng::UST) endif() endif() diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c index 306c7796d..e2b825085 100644 --- a/providers/rxe/rxe.c +++ b/providers/rxe/rxe.c @@ -55,6 +55,9 @@ #include "rxe_queue.h" #include "rxe-abi.h" #include "rxe.h" + +#define LTTNG_UST_TRACEPOINT_DEFINE +#define LTTNG_UST_TRACEPOINT_PROBE_DYNAMIC_LINKAGE #include "rxe_trace.h" static void rxe_free_context(struct ibv_context *ibctx); diff --git a/providers/rxe/rxe_trace.c b/providers/rxe/rxe_trace.c index a2f9fab2f..71cefc54e 100644 --- a/providers/rxe/rxe_trace.c +++ b/providers/rxe/rxe_trace.c @@ -4,6 +4,5 @@ */ #define LTTNG_UST_TRACEPOINT_CREATE_PROBES -#define LTTNG_UST_TRACEPOINT_DEFINE #include "rxe_trace.h" -- 2.33.0