Skip to content

UCT: Add outstanding operation extraction support#11580

Open
jeynmann wants to merge 23 commits into
openucx:masterfrom
jeynmann:failover_ext_uct
Open

UCT: Add outstanding operation extraction support#11580
jeynmann wants to merge 23 commits into
openucx:masterfrom
jeynmann:failover_ext_uct

Conversation

@jeynmann

Copy link
Copy Markdown
Contributor

What?

Add UCT-level support for failover ops extraction.
Add impl for token query.

Why?

UCP failover needs map tokens to send ops and resend failed ops.

How?

Introduces a callback-based extraction api.

Comment thread src/uct/api/v2/uct_v2.h
* Operation type from @ref uct_ep_operation_t (e.g. UCT_EP_OP_AM_SHORT,
* UCT_EP_OP_PUT_ZCOPY, UCT_EP_OP_FLUSH, etc.).
*/
uct_ep_operation_t operation;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UCT_EP_OP_INFO_FIELD_OPERATION is missed

Comment thread src/uct/api/v2/uct_v2.h Outdated
Comment on lines +1555 to +1561
UCT_EP_OP_INFO_FIELD_AM = UCS_BIT(0), /**< am_id, am_hdr* fields */
UCT_EP_OP_INFO_FIELD_DATA = UCS_BIT(1), /**< data/length (short/bcopy) */
UCT_EP_OP_INFO_FIELD_IOV = UCS_BIT(2), /**< iov/iovcnt (zcopy) */
UCT_EP_OP_INFO_FIELD_RMA = UCS_BIT(3), /**< remote_addr, rkey */
UCT_EP_OP_INFO_FIELD_ATOMIC = UCS_BIT(4), /**< atomic_op, value, compare */
UCT_EP_OP_INFO_FIELD_COMP = UCS_BIT(5), /**< Original uct_completion_t */
UCT_EP_OP_INFO_FIELD_FLAGS = UCS_BIT(6), /**< Original flags */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls keep the same order as fields of struct uct_ep_op_info

Comment thread src/uct/ib/mlx5/rc/rc_mlx5.inl Outdated
res_count = uct_ib_mlx5_post_send(txwq, ctrl, wqe_size, 1);
num_bb = txwq->sw_pi - pi;

if (txwq->msn != NULL) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant bcz check on init

Comment thread src/uct/ib/mlx5/rc/rc_mlx5.inl Outdated
Comment on lines +496 to +500
if (opcode != MLX5_OPCODE_NOP) {
uct_rc_mlx5_txwq_set_msn(txwq, pi, num_bb);
} else {
uct_rc_mlx5_txwq_set_msn(txwq, pi, 0);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (opcode != MLX5_OPCODE_NOP) {
uct_rc_mlx5_txwq_set_msn(txwq, pi, num_bb);
} else {
uct_rc_mlx5_txwq_set_msn(txwq, pi, 0);
}
num_bb = ucs_likely(opcode != MLX5_OPCODE_NOP) ?
(txwq->sw_pi - pi) : 0;
uct_rc_mlx5_txwq_set_msn(txwq, pi, num_bb);

Comment thread src/uct/ib/mlx5/rc/rc_mlx5_ep.c Outdated
attr.field_mask |= UCT_IB_MLX5_EXT_QP_QUERY_ATTR_FIELD_QP_NUM;
attr.qp_num = ep->tx.wq.super.qp_num;
#endif
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else return INVALID_PARAM

Comment thread src/uct/ib/mlx5/rc/rc_mlx5_ep.c Outdated
Comment on lines +53 to +55
if (attr.field_mask == 0) {
return UCS_OK;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be checked in advance for ep_attr->field_mask near check at line 38

Comment thread src/uct/ib/mlx5/ib_mlx5_ext.c Outdated
continue;
}

return plugin->ops.ep_outstanding_extract(ep, params);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we query QP in plugin API then it should be plugin->ops.qp_outstanding_extract

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently plugin needs ep ctx, not only the QP: it derives the RC ep, iface, txwq and txqp, then walks the outstanding send queue.
Passing only QP is not sufficient.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so then it should be EP in both cases

Comment thread src/uct/ib/mlx5/ib_mlx5_ext.h Outdated
uct_ib_mlx5_ext_qp_query_func_t qp_query; /**< QP query callback */
uct_ib_mlx5_ext_max_put_sgl_zcopy_count_func_t max_put_sgl_zcopy_count; /**< Maximum PUT SGL zero-copy entry count callback */
uct_ep_put_sgl_zcopy_func_t ep_put_sgl_zcopy; /**< PUT SGL zero-copy callback */
uct_ep_outstanding_extract_func_t ep_outstanding_extract; /**< Outstanding operation extract callback */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to align qp_query/ep_outstanding_extract APIs: QP or EP?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is the 2 APIs need different scope of qp/ep info.

Comment thread src/uct/api/v2/uct_v2.h Outdated
* caller.
*/
ucs_status_t
uct_ep_outstanding_extract(uct_ep_h ep,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about to rename to uct_ep_outstanding_purge? (to align with uct_ep_pending_purge)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operation is not similar as uct_ep_pending_purge: it classifies outstanding WQEs, optionally completes already delivered operations, and reports undelivered operations back to the caller for replay. Maybe "extract" describes this behavior more accurately than "purge", WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, why do we need to extract all the outstanding operations? in terms of IB I would expect to have a converting of failed CQE to WQE and repost it if not delivered. Should not it be enough for reposting failover protocols?

Comment thread src/uct/ib/mlx5/rc/rc_mlx5.inl Outdated
uct_rc_mlx5_txwq_set_msn(uct_ib_mlx5_txwq_t *txwq, uint16_t pi, uint16_t num_bb)
{
unsigned index = pi % txwq->bb_max;
uct_ib_mlx5_txwq_msn_t *entry = &txwq->msn[index];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make msn entry part of uct_rc_iface_send_op to improve mem locality?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not every WQE has a send_op associated with it, while extraction needs MSN information for all outstanding WQEs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide an example? Do we need to repost WQEs (after failure) which do not have send_op

JeynmannZ added 20 commits July 2, 2026 12:16
Arm RC mlx5 endpoints before peer failure so error handling leaves outstanding sends available for extraction.

Suppress user completions while releasing CQ resources, and let endpoint destruction hand the failed QP to asynchronous garbage collection.
Verify that extraction reports posted operations in order and preserves the metadata needed by failover replay.
Use the failover-specific _ft suffix for the completion-backed PUT bcopy entry point and transport operation. Remove the redundant capability bit since availability follows QUERY_TOKEN support.
Organize extracted operation metadata by protocol parameter group, align field-mask ordering with the structure layout, and distinguish AM flags from flush parameters. Also align internal operation initializers touched by outstanding extraction support.

@evgeny-leksikov evgeny-leksikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split the PR to API and impl, PR with API can include stubs if <= 500 lines.

Comment thread src/uct/api/v2/uct_v2.h
Comment on lines +1610 to +1618
struct {
uint8_t am_id; /**< AM handler ID */
unsigned flags; /**< Flags passed to the AM operation */
union {
uint64_t header; /**< AM short 64-bit header word */
const void *header_buffer; /**< AM zcopy header buffer */
};
size_t header_length; /**< AM zcopy header length */
} am;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have such structures under union backward compatible?

num_bb = ucs_likely(opcode != MLX5_OPCODE_NOP) ?
(txwq->sw_pi - pi) : 0;

if (txwq->wqe_priv != NULL) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant check, done in ctor

Comment thread src/uct/ib/mlx5/rc/rc_mlx5.inl Outdated
uct_rc_mlx5_txwq_set_msn(uct_ib_mlx5_txwq_t *txwq, uint16_t pi, uint16_t num_bb)
{
unsigned index = pi % txwq->bb_max;
uct_ib_mlx5_txwq_msn_t *entry = &txwq->msn[index];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide an example? Do we need to repost WQEs (after failure) which do not have send_op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants