Closed
[Bug-Report|缺陷反馈]: 两个独立的endpoint import同一块远端内存,底层UbRegedMemMgr拒绝重复注册 #826
tangjie66Add on  Sep 2Closed at  Sep 17
tangjie66
tangjie66
Sep 2 Create

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

uboe场景发现个问题,hixl目前在做多channel的能力,多个client连接同一个server,每个channel需要独立的endpoint来创建独立的jetty。
但是memimport的attachcache里,两个独立的endpoint import同一块远端内存,底层UbRegedMemMgr拒绝重复注册,感觉不太对,导致多channel创建不了,memimport的时候报错

Environment / 环境信息 (Mandatory / 必填)

A5

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

两个独立的endpoint import同一块远端内存,底层UbRegedMemMgr拒绝重复注册

Describe the expected behavior / 预期结果 (Mandatory / 必填)

多channel创建成功,memimport不报错

无

Special notes for this issue/备注 (Optional / 选填)

likedislike
LLeewisCollaborators
Sep 2 associated Kanban: HCCL
LLeewisCollaborators
Sep 2 associated Kanban: HCOMM
LLeewisCollaborators
Sep 2 removed Kanban: HCCL
LeewisCollaborators
Sep 2 Comments:

感谢对于社区的关注与反馈,当前已有相关类似问题在定位中,待有定位结论后同步;

likedislike
LLeewisCollaborators
Sep 2 changed custom category from 任务 to 缺陷
HHccl_test
Sep 10 Associated pull request
严正行严正行Collaborators
Sep 15 Added label: tech-debt
LeewisCollaborators
Sep 17 Comments:

技术原因:多个 endpointHandle/endpoint 实例若持有相同的 endpointDesc,对相同远端内存执行 HcommMemImport 时会误判为重复导入而报 HCCL_E_INTERNAL(原 E_AGAIN),且进程级共享 mgr 的引用计数跨实例串账,存在 ref 泄漏。

修改方案:将内存管理的"本端"与"远端"两条线拆开,各自回到正确的归属层:

  1. 接口拆分:RegedMemMgr 拆为 LocalRegedMemMgr(注册/注销/导出/枚举)、RemoteRegedMemMgr(导入/关闭)两个独立接口。hccs/aicpu_ts/NIC 插件等本远端操作天然耦合的形态只继承 LocalRegedMemMgr(消除多继承的菱形风险),其远端接口经 RemoteRegedMemMgrForwarder(RemoteRegedMemMgr 派生的纯转发视图)包装后由 GetRemoteRegMemMgr() 对外暴露,转发到同一 mgr 对象的同一实现,行为与拆分前一致。
  2. 远端内存下沉到 Endpoint 实例级:新增实例级 EndpointRemoteRegedMemMgr(RemoteRegedMemMgr 的唯一实现,RoCE/Ub 两族差异通过 MemDescParser/RemoteBufferCreator 注入适配),远端导入的引用计数收缩到 Endpoint 实例内;相同 endpointDesc 的不同实例互不干扰,重复导入在本实例内幂等成功(ref+1),不再报错。进程级 mgr(RoceRegedMemMgr/UbRegedMemMgr/UbMemRegedMemMgr)瘦身为只管本端内存。
  3. 远端内存 key 增加进程维度:memDesc 尾部追加 8 字节 pid,远端内存 key 变为 {endpointDesc, pid, BufferKey},区分同一 endpointDesc 下不同远端进程的内存;旧格式 memDesc 导入直接报错,强制两端同版本。
  4. Endpoint 访问入口拆分:Endpoint::GetRegedMemMgr() 拆为 GetLocalRegMemMgr()(纯虚)+ GetRemoteRegMemMgr()(默认 nullptr,不支持远端导入的 endpoint 无需 override),C API 适配层按操作类型分发到对应 mgr。
  5. memDesc 序列化/反序列化收敛:memDesc 布局(DTO + EndpointDesc + pid)的构建与解析收敛为 reged_mem_mgr.h 中的 BuildMemDesc/ParseMemDesc 一对函数,同文件成对维护,RoCE/Ub 的导出与导入路径统一复用;解析侧保留长度校验、DTO 回读校验(拦截旧格式错位)与异常兜底。

https://gitcode.com/cann/hcomm/pull/5149
相关修改上库;

likedislike
LLeewisCollaborators
Sep 17 Assign Leewis as responsible person
LLeewisCollaborators
Sep 17 changed custom state from 待办的 to 已解决
LLeewisCollaborators
Sep 17 Close issue
LLeewisCollaborators
Sep 17 Associated pull request
LLeewisCollaborators
Sep 17 Deleted associated pull request: 【2026 HCCL通信库创新大赛-东北赛区】【吉速通信】fix: UbRegedMemMgr 重复 import 同一远端内存时幂等复用已有 buffer
CANN-robotCANN-robotCollaborators
Sep 17 Added label: resolved
LLeewisCollaborators
Sep 21 removed Kanban: HCOMM