Pull Request已成功合入, 合并人@CANN-robot
(感谢 Yuanhao Ji 的贡献)变更摘要
本 PR 主要修正了 HcommChannelNotifyWaitOnThread 相关等待接口中 timeout 参数的时间单位,将其从毫秒(ms)统一改为秒(s),并同步调整默认超时常量。改动涉及 experimental/base_comm/channel/host_cpu_roce_channel.cc 与 src/base_comm/resources/endpoint_pairs/channels/host/host_cpu_roce_channel.cc 两处实现,通过把 std::chrono::milliseconds 替换为 std::chrono::seconds,使 NotifyWait 与 NotifyWaitHybrid 的等待时长计算与新的秒级单位保持一致。
主要改动
- 默认超时常量单位调整:将默认超时值由
DEFAULT_NOTIFY_POLL_TIMEOUT_MS = 30000改为DEFAULT_NOTIFY_WAIT_TIMEOUT_S = 30(并在另一文件中新增同名常量),数值从毫秒量级的30000调整为秒量级的30。 NotifyWait等待时长单位修正:将std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(timeout))改为使用std::chrono::seconds(timeout),使timeout参数按秒解析。NotifyWaitHybrid默认值与轮询单位修正:将pollTimeout的默认值从DEFAULT_NOTIFY_POLL_TIMEOUT_MS或硬编码的30000改为DEFAULT_NOTIFY_WAIT_TIMEOUT_S,并将waitTime由std::chrono::milliseconds(pollTimeout)改为std::chrono::seconds(pollTimeout)。


代码审查
审查结论
我已完成对两个变更文件的逐一审查:
src/base_comm/resources/endpoint_pairs/channels/host/host_cpu_roce_channel.cc—— 发现 2 个问题(P2 忙轮询、P3 timeout==0 语义不一致)experimental/base_comm/channel/host_cpu_roce_channel.cc—— 发现 1 个问题(P2 忙轮询)
发现汇总(按优先级)
| 优先级 | 数量 | 说明 |
|---|---|---|
| P0 | 0 | — |
| P1 | 0 | — |
| P2 | 2 | NotifyWait 非混合路径无休眠忙轮询,超时单位 ms→s 后 CPU 空转与 cq_mutex 持锁时长被放大千倍(两个文件各 1 处) |
| P3 | 1 | timeout==0 在 NotifyWait(立即超时)与 NotifyWaitHybrid(默认 30s)间语义不一致 |
总体风险判断
本次改动本身方向正确——调用链(HcommSetNotifyWaitTimeOut/GetNotifyWaitTimeOut → HcommChannelNotifyWaitOnThread)全程以“秒”为单位并打印 timeOut[%u s],此前 channel 侧按毫秒解释确实是一个 bug,改为秒是正确的修复;常量重命名(DEFAULT_NOTIFY_POLL_TIMEOUT_MS→DEFAULT_NOTIFY_WAIT_TIMEOUT_S)无残留引用,无编译问题。
但该修复把非混合 NotifyWait 缺失退避的忙轮询从“约 1.8 秒”放大到“最坏约 30 分钟”,属于中风险性能/可靠性回归,建议在合入前为轮询循环补上退避睡眠;timeout==0 的两模式语义分歧属低风险遗留问题,可顺手对齐。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 2 |
💬 仅评论


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.
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 |
|---|---|---|
| experimental | ✅ 颜业峰, lilin_137 (2/2) | ✅ 颜业峰 (1/1) |
| src/base_comm | ✅ temper7620, 颜业峰, lilin_137 (3/2) | ✅ temper7620, 颜业峰 (2/1) |
| test | ✅ temper7620, 颜业峰, dingweiqin_57, lilin_137 (4/2) | ✅ temper7620, 颜业峰, dingweiqin_57 (3/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
jiyuanhao, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


流水线任务触发成功
任务链接 [1732b4f1a61f41689eb3cfb16d481c60][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| ST_Test | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> | |
| codecheck | ✅ SUCCESS | >>>>> | |
| codecheck_style | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | >>>>> | |
| precommit | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> | |
| PreSmoke_A3_npupool | ✅ SUCCESS | >>>>> |
[2026-08-14 16:15:22] CI执行结束




🟡 Medium Priority
changed line → affected behavior → failure mode → suggested fix:
第 970 行将 std::chrono::milliseconds(timeout) 改为 std::chrono::seconds(timeout),使非混合模式 NotifyWait 轮询超时上限从毫秒级放大到秒级。但该函数 while (true) 循环内只有 ibv_poll_cq(非阻塞),无任何 sleep/yield(对比本文件 NotifyWaitHybrid 每轮 SaluSleep(pollInterval)),且循环整体位于函数开头 std::lock_guard<std::mutex> lock(cq_mutex)(第 961 行)持锁范围。
后果:对端 notify 迟迟未到时,本端线程 100% CPU 空转并长时间持有 cq_mutex,最坏持续整个超时(默认约 30 分钟)。改动前同值按毫秒解释(约 1.8 秒),问题几乎不可触发;改为秒后缺失退避的忙轮询被真实放大。
建议:在非混合模式 NotifyWait 的轮询循环内加入退避睡眠(参考 NotifyWaitHybrid 的 SaluSleep),避免秒级超时下 100% CPU 空转并长时间持有 cq_mutex。


🟡 Medium Priority
changed line → affected behavior → failure mode → suggested fix:
第 902 行将 std::chrono::milliseconds(timeout) 改为 std::chrono::seconds(timeout),使非混合模式 NotifyWait 的轮询超时上限从毫秒级放大到秒级(调用方 HcommChannelNotifyWaitOnThread 传入的 timeOut 单位本就是秒,默认 NOTIFY_WAIT_TIMEOUT_DEFAULT = 1836 秒)。但该函数的 while (true) 循环内只有 ibv_poll_cq(非阻塞),没有任何 sleep/yield(对比 NotifyWaitHybrid 中每轮有 SaluSleep(pollInterval)),且整个循环在函数开头 std::lock_guard<std::mutex> lock(cq_mutex)(第 893 行)的持锁范围内。
后果:当对端 notify 迟迟未到达(对端仍在计算,或发生死锁)时,本端线程会以 100% CPU 空转、并长时间持有 cq_mutex,最坏持续到整个超时(默认约 30 分钟),阻塞其他需要该 CQ 的线程。改动前同样的值被按毫秒解释(约 1.8 秒),此问题几乎不可触发;改为秒后该缺失 backoff 的忙轮询问题被真实放大。
建议:在非混合模式 NotifyWait 的轮询循环内加入退避睡眠(参考 NotifyWaitHybrid 的 SaluSleep),避免秒级超时下 100% CPU 空转并长时间持有 cq_mutex。


/compile


流水线任务触发成功
任务链接 [5df606ba42dc4ec98ca1be7cbfc2c2e1][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| ST_Test | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> | |
| codecheck | ✅ SUCCESS | >>>>> | |
| codecheck_style | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | >>>>> | |
| precommit | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> | |
| PreSmoke_A3_npupool | ✅ SUCCESS | >>>>> |
[2026-08-17 10:22:34] CI执行结束




/approve


/approve


/approve


描述
[Fix] 修改 HcommChannelNotifyWaitOnThread 的 timeout 参数单位为:ms->s
变更类型
请选择本次引入的变更类型:
关联的Issue
测试
已完成的测试用例和场景:
补充的UT用例:
文档更新
合入检查