Skip to content

Commit

Permalink
prov/efa: Reorganize the efa and efa-rdm tp events
Browse files Browse the repository at this point in the history
This patch adjust various tp providers and events:

1. efa_tracepoint_wr_id_post_* should be moved to
efa_rdm_tracepoints.h, as it includes efa_rdm_ope which
only applies to efa_rdm code base. Also the function
names should be adjusted to efa_rdm_*

2. Add send/recv/read/write_begin_msg_context events
for efa tp provider.

3. Make efa_rdm_pke.c use efa_rdm_tracepoint_wr_id to
generate doorbell ringing events. For efa_msg.c and
efa_rma.c, use efa_tracepoint directly.

Signed-off-by: Shi Jin <[email protected]>
  • Loading branch information
shijin-aws committed Dec 12, 2024
1 parent f03fe01 commit 172c520
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 55 deletions.
10 changes: 7 additions & 3 deletions prov/efa/src/efa_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ static inline ssize_t efa_post_recv(struct efa_base_ep *base_ep, const struct fi
ssize_t err, post_recv_err;
size_t i, wr_index = base_ep->recv_wr_index;

efa_tracepoint(recv_begin_msg_context, (size_t) msg->context, (size_t) msg->addr);

if (wr_index >= base_ep->info->rx_attr->size) {
EFA_INFO(FI_LOG_EP_DATA,
"recv_wr_index exceeds the rx limit, "
Expand Down Expand Up @@ -119,6 +121,8 @@ static inline ssize_t efa_post_recv(struct efa_base_ep *base_ep, const struct fi
if (flags & FI_MORE)
return 0;

efa_tracepoint(post_recv, wr->wr_id, (uintptr_t)msg->context);

err = ibv_post_recv(qp->ibv_qp, &base_ep->efa_recv_wr_vec[0].wr, &bad_wr);
if (OFI_UNLIKELY(err)) {
/* On failure, ibv_post_recv() return positive errno.
Expand Down Expand Up @@ -187,6 +191,8 @@ static inline ssize_t efa_post_send(struct efa_base_ep *base_ep, const struct fi
size_t len, i;
int ret = 0;

efa_tracepoint(send_begin_msg_context, (size_t) msg->context, (size_t) msg->addr);

dump_msg(msg, "send");

conn = efa_av_addr_to_conn(base_ep->av, msg->addr);
Expand Down Expand Up @@ -248,9 +254,7 @@ static inline ssize_t efa_post_send(struct efa_base_ep *base_ep, const struct fi
ibv_wr_set_ud_addr(qp->ibv_qp_ex, conn->ah->ibv_ah, conn->ep_addr->qpn,
conn->ep_addr->qkey);

#if HAVE_LTTNG
efa_tracepoint_wr_id_post_send((void *)msg->context);
#endif
efa_tracepoint(post_send, qp->ibv_qp_ex->wr_id, (uintptr_t)msg->context);

if (!(flags & FI_MORE)) {
ret = ibv_wr_complete(qp->ibv_qp_ex);
Expand Down
8 changes: 8 additions & 0 deletions prov/efa/src/efa_rma.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static inline ssize_t efa_rma_post_read(struct efa_base_ep *base_ep,
#endif
int i, err = 0;

efa_tracepoint(read_begin_msg_context, (size_t) msg->context, (size_t) msg->addr);

assert(msg->iov_count > 0 &&
msg->iov_count <= base_ep->domain->info->tx_attr->iov_limit);
assert(msg->rma_iov_count > 0 &&
Expand Down Expand Up @@ -105,6 +107,8 @@ static inline ssize_t efa_rma_post_read(struct efa_base_ep *base_ep,
ibv_wr_set_ud_addr(qp->ibv_qp_ex, conn->ah->ibv_ah, conn->ep_addr->qpn,
conn->ep_addr->qkey);

efa_tracepoint(post_read, qp->ibv_qp_ex->wr_id, (uintptr_t)msg->context);

if (!(flags & FI_MORE)) {
err = ibv_wr_complete(qp->ibv_qp_ex);
base_ep->is_wr_started = false;
Expand Down Expand Up @@ -205,6 +209,8 @@ static inline ssize_t efa_rma_post_write(struct efa_base_ep *base_ep,
size_t len;
int i, err = 0;

efa_tracepoint(write_begin_msg_context, (size_t) msg->context, (size_t) msg->addr);

qp = base_ep->qp;
if (!base_ep->is_wr_started) {
ibv_wr_start(qp->ibv_qp_ex);
Expand Down Expand Up @@ -243,6 +249,8 @@ static inline ssize_t efa_rma_post_write(struct efa_base_ep *base_ep,
ibv_wr_set_ud_addr(qp->ibv_qp_ex, conn->ah->ibv_ah, conn->ep_addr->qpn,
conn->ep_addr->qkey);

efa_tracepoint(post_write, qp->ibv_qp_ex->wr_id, (uintptr_t)msg->context);

if (!(flags & FI_MORE)) {
err = ibv_wr_complete(qp->ibv_qp_ex);
base_ep->is_wr_started = false;
Expand Down
37 changes: 0 additions & 37 deletions prov/efa/src/efa_tp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#if HAVE_LTTNG

#include "efa_tp_def.h"
#include "rdm/efa_rdm_ope.h"

#include <lttng/tracef.h>
#include <lttng/tracelog.h>
Expand All @@ -25,42 +24,6 @@
/* tracelog() is similar to tracef(), but with a log level param */
#define efa_tracelog lttng_ust_tracelog

static inline void efa_tracepoint_wr_id_post_send(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_send, (size_t) wr_id, (size_t) ope, (size_t) ope->cq_entry.op_context);
}

static inline void efa_tracepoint_wr_id_post_recv(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_recv, (size_t) wr_id, (size_t) ope, (size_t) ope->cq_entry.op_context);
}

static inline void efa_tracepoint_wr_id_post_read(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_read, (size_t) wr_id, (size_t) ope, (size_t) ope->cq_entry.op_context);
}

static inline void efa_tracepoint_wr_id_post_write(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_write, (size_t) wr_id, (size_t) ope, (size_t) ope->cq_entry.op_context);
}

#else

#define efa_tracepoint(...) do {} while(0)
Expand Down
35 changes: 33 additions & 2 deletions prov/efa/src/efa_tp_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,45 @@

#define X_PKT_ARGS \
size_t, wr_id, \
size_t, efa_rdm_ope, \
size_t, context

#define X_PKT_FIELDS \
lttng_ust_field_integer_hex(size_t, wr_id, wr_id) \
lttng_ust_field_integer_hex(size_t, efa_rdm_ope, efa_rdm_ope) \
lttng_ust_field_integer_hex(size_t, context, context)

#define MSG_ARGS \
size_t, msg_ctx, \
size_t, addr

#define MSG_FIELDS \
lttng_ust_field_integer_hex(size_t, msg_ctx, msg_ctx) \
lttng_ust_field_integer_hex(size_t, addr, addr)

LTTNG_UST_TRACEPOINT_EVENT_CLASS(EFA_TP_PROV, msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS),
LTTNG_UST_TP_FIELDS(MSG_FIELDS))

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_TP_PROV, msg_context, EFA_TP_PROV,
send_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_TP_PROV, send_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_TP_PROV, msg_context, EFA_TP_PROV,
recv_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_TP_PROV, recv_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_TP_PROV, msg_context, EFA_TP_PROV,
read_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_TP_PROV, read_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_TP_PROV, msg_context, EFA_TP_PROV,
write_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_TP_PROV, write_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)


LTTNG_UST_TRACEPOINT_EVENT_CLASS(EFA_TP_PROV, post_wr_id,
LTTNG_UST_TP_ARGS(X_PKT_ARGS),
LTTNG_UST_TP_FIELDS(X_PKT_FIELDS))
Expand Down
10 changes: 5 additions & 5 deletions prov/efa/src/rdm/efa_rdm_pke.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ ssize_t efa_rdm_pke_sendv(struct efa_rdm_pke **pkt_entry_vec,
#endif

#if HAVE_LTTNG
efa_tracepoint_wr_id_post_send((void *)pkt_entry);
efa_rdm_tracepoint_wr_id_post_send((void *)pkt_entry);
#endif
}

Expand Down Expand Up @@ -510,7 +510,7 @@ int efa_rdm_pke_read(struct efa_rdm_pke *pkt_entry,
}

#if HAVE_LTTNG
efa_tracepoint_wr_id_post_read((void *)pkt_entry);
efa_rdm_tracepoint_wr_id_post_read((void *)pkt_entry);
#endif

err = ibv_wr_complete(qp->ibv_qp_ex);
Expand Down Expand Up @@ -602,7 +602,7 @@ int efa_rdm_pke_write(struct efa_rdm_pke *pkt_entry)
}

#if HAVE_LTTNG
efa_tracepoint_wr_id_post_write((void *)pkt_entry);
efa_rdm_tracepoint_wr_id_post_write((void *)pkt_entry);
#endif

if (!(txe->fi_flags & FI_MORE)) {
Expand Down Expand Up @@ -650,7 +650,7 @@ ssize_t efa_rdm_pke_recvv(struct efa_rdm_pke **pke_vec,
if (i > 0)
ep->base_ep.efa_recv_wr_vec[i-1].wr.next = &recv_wr->wr;
#if HAVE_LTTNG
efa_tracepoint_wr_id_post_recv(pke_vec[i]);
efa_rdm_tracepoint_wr_id_post_recv(pke_vec[i]);
#endif
}

Expand Down Expand Up @@ -699,7 +699,7 @@ ssize_t efa_rdm_pke_user_recvv(struct efa_rdm_pke **pke_vec,
if (wr_index > 0)
ep->base_ep.user_recv_wr_vec[wr_index - 1].wr.next = &recv_wr->wr;
#if HAVE_LTTNG
efa_tracepoint_wr_id_post_recv(pke_vec[i]);
efa_rdm_tracepoint_wr_id_post_recv(pke_vec[i]);
#endif
wr_index++;
}
Expand Down
37 changes: 37 additions & 0 deletions prov/efa/src/rdm/efa_rdm_tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#if HAVE_LTTNG

#include "efa_tp.h"
#include "efa_rdm_tracepoint_def.h"

#include <lttng/tracef.h>
Expand All @@ -25,6 +26,42 @@
/* tracelog() is similar to tracef(), but with a log level param */
#define efa_rdm_tracelog lttng_ust_tracelog

static inline void efa_rdm_tracepoint_wr_id_post_send(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_send, (size_t) wr_id, (size_t) ope->cq_entry.op_context);
}

static inline void efa_rdm_tracepoint_wr_id_post_recv(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_recv, (size_t) wr_id, (size_t) ope->cq_entry.op_context);
}

static inline void efa_rdm_tracepoint_wr_id_post_read(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_read, (size_t) wr_id, (size_t) ope->cq_entry.op_context);
}

static inline void efa_rdm_tracepoint_wr_id_post_write(const void *wr_id)
{
struct efa_rdm_pke *pkt_entry = (struct efa_rdm_pke *) wr_id;
struct efa_rdm_ope *ope = pkt_entry->ope;
if (!ope)
return;
efa_tracepoint(post_write, (size_t) wr_id, (size_t) ope->cq_entry.op_context);
}

#else

#define efa_rdm_tracepoint(...) do {} while (0)
Expand Down
16 changes: 8 additions & 8 deletions prov/efa/src/rdm/efa_rdm_tracepoint_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,36 @@ LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_RDM_TP_PROV, x_entry, EFA_RDM_TP_PROV,
LTTNG_UST_TP_ARGS(X_ENTRY_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_RDM_TP_PROV, runtread_read_posted, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

#define MSG_ARGS \
#define RDM_MSG_ARGS \
size_t, msg_ctx, \
size_t, addr

#define MSG_FIELDS \
#define RDM_MSG_FIELDS \
lttng_ust_field_integer_hex(size_t, msg_ctx, msg_ctx) \
lttng_ust_field_integer_hex(size_t, addr, addr)

LTTNG_UST_TRACEPOINT_EVENT_CLASS(EFA_RDM_TP_PROV, msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS),
LTTNG_UST_TP_FIELDS(MSG_FIELDS))
LTTNG_UST_TP_ARGS(RDM_MSG_ARGS),
LTTNG_UST_TP_FIELDS(RDM_MSG_FIELDS))

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_RDM_TP_PROV, msg_context, EFA_RDM_TP_PROV,
send_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TP_ARGS(RDM_MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_RDM_TP_PROV, send_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_RDM_TP_PROV, msg_context, EFA_RDM_TP_PROV,
recv_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TP_ARGS(RDM_MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_RDM_TP_PROV, recv_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_RDM_TP_PROV, msg_context, EFA_RDM_TP_PROV,
read_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TP_ARGS(RDM_MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_RDM_TP_PROV, read_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(EFA_RDM_TP_PROV, msg_context, EFA_RDM_TP_PROV,
write_begin_msg_context,
LTTNG_UST_TP_ARGS(MSG_ARGS))
LTTNG_UST_TP_ARGS(RDM_MSG_ARGS))
LTTNG_UST_TRACEPOINT_LOGLEVEL(EFA_RDM_TP_PROV, write_begin_msg_context, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO)

#define CQ_ENTRY_ARGS \
Expand Down

0 comments on commit 172c520

Please sign in to comment.