Pull Request已成功合入, 合并人@CANN-robot
(感谢 lining23666 的贡献)变更摘要
本 PR 为 bugfix(关联 issue #716):修复 HixlCSServer::RegisterMem 在多 Endpoint 注册同一块内存时,若后续 Endpoint 注册失败(HIXL_CHK_STATUS_RET 直接返回错误)导致此前已成功注册的 Endpoint 残留、无法通过 HixlCSServerUnregMem 清理的问题。修复方案是在注册流程中引入 HIXL_DISMISSABLE_GUARD 回滚:任一 Endpoint 注册失败时,逆序注销本次已成功注册的 Endpoint 后返回原始错误码(单点注销失败仅记录 ERROR 日志并继续,best-effort);全部成功后才写入 reg_mems_ 并 Dismiss,与 Endpoint::RegisterMem 内部既有回滚模式保持一致,同时补充了对应 UT 与 HCCL stub 注入能力。
主要改动
-
引入注册回滚机制:在
src/hixl/cs/hixl_cs_server.cc新增RollbackRegisteredMem(逆序遍历ep_mem_infos调用DeregisterMem,注销失败仅记录日志),并在RegisterMem中通过HIXL_DISMISSABLE_GUARD在任一 Endpoint 注册失败时触发回滚,全部成功后写入reg_mems_前调用HIXL_DISMISS_GUARD取消回滚,保证失败路径无残留注册、mem_handle不写出。 -
新增回滚 UT 用例:在
test_hixl_cs_server.cc新增RegisterMemRollsBackEarlierEndpointsWhenLaterEndpointFails(两个 HOST UBC_CTP Endpoint,第 2 次HcommMemReg注入HCCL_E_INTERNAL,断言注册 2 次、成功 1 次、回滚注销 1 次、mem_handle为 nullptr、恢复后重注册成功)与RegisterMemFirstEndpointFailureRollsBackNothing(首个 Endpoint 即失败时回滚为空操作,无注销调用),并在TearDown中调用ResetMemRegRecord清理记录。 -
扩展 HCCL stub 故障注入与计数:在
hccl_stub.cc/h新增SetMemRegFailureOnCall(第 N 次HcommMemReg注入指定错误码)、GetMemRegCallCount、GetMemUnregCallCount,并在HcommMemReg/HcommMemUnreg中累计调用次数、ResetMemRegRecord中统一重置注入与计数状态。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/hixl | ✅ zhujingjing, youyx, zhaozhihui (3/2) | ✅ zhujingjing (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lining23666, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/approve


提交 PR 前,请先阅读 HIXL贡献指南 ,查看 PR 提交方式并遵守相关提交规范。
类型标签
描述
修复 #716 。
HixlCSServer::RegisterMem依次向所有匹配的 Endpoint 注册同一块内存时,若后续 Endpoint 注册失败,HIXL_CHK_STATUS_RET直接返回错误,此前已成功注册的 Endpoint 不会被注销回滚:RegisterMem会重复注册放大占用;reg_mems_,失败路径调用方无法通过HixlCSServerUnregMem清理残留。本修复为注册流程引入
HIXL_DISMISSABLE_GUARD回滚:任一 Endpoint 注册失败时,逆序注销本次已成功注册的 Endpoint 后再返回原始注册失败错误码(单点注销失败仅记录 ERROR 日志并继续,best-effort);全部成功后在写入reg_mems_前 Dismiss,与Endpoint::RegisterMem内部已有的回滚模式保持一致。测试项
tests/depends/hccl/src/hccl_stub.{h,cc}:新增SetMemRegFailureOnCall(第 N 次HcommMemReg注入指定错误)、GetMemRegCallCount、GetMemUnregCallCount,ResetMemRegRecord统一重置;HixlCSTest.RegisterMemRollsBackEarlierEndpointsWhenLaterEndpointFails:两个 HOST UBC_CTP Endpoint,第 2 次HcommMemReg注入HCCL_E_INTERNAL,断言注册发起 2 次、成功 1 次、回滚注销 1 次、mem_handle不写出、回滚后重新注册成功;HixlCSTest.RegisterMemFirstEndpointFailureRollsBackNothing:首个 Endpoint 即失败时回滚为空操作;GetMemUnregCallCount()为 0,与 issue 716 日志一致),修复后通过。测试结果
bash tests/run_test.sh -s hixl # [PASSED] hixl # [PASSED] log_fallback # All selected C++ test binaries passed.基于 up/master@4cb24f42 + 本修复提交验证通过。
Checklist
其它(可选)
关联 issue:#716 ,修复方案已在 issue 中答复(失败原子性回滚)。