已合并
【UBSE】process_mem 在途迁移量按远端numa实际占用计算, OOM检测常开快速轮询, 清理失败UT #1466
2401_87013476创建于 16 天前
【UBSE】process_mem 在途迁移量按远端numa实际占用计算, OOM检测常开快速轮询, 清理失败UT #1466
已合并
2401_87013476创建于 16 天前
2401_87013476
2401_87013476
16 天前

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

参考:openEuler社区《生成式AI工具使用与开源贡献政策》

PR功能描述 / 为什么需要这个合入**:

  1. 节点空闲判断:MemAvailable → 本地NUMA
    MemFree 之和
  • 前:决策侧每次直接读 /proc/meminfo 的
    MemAvailable
  • 后:采集模块每轮遍历
    /sys/.../node/meminfo,区分本地/远端
    numa(remote 属性),累加本地 MemFree、远端
    MemUsed 写入快照;决策侧经 GetLocalNumaFreeKb()
    读取,UT 通过 reader 注入
  1. 在途迁移量:账本 BORROWING 累计 → 预期账本 −
    远端实际占用
  • 前:GetPendingBorrowTotal() 只累加 BORROWING
    槽位
  • 后:GetPendingMigrateTotal() =
    账本已下发迁移量(BORROWING+COMPLETED)− 远端
    numa 实际 MemUsed;差值为 smap
    未落地部分。快照缺失时返回
    0(保守不扣减),归还侧不参与
  1. OOM 检测:正常/快速双频切换 → 常开快速轮询
  • 前:1s 正常轮询,MemAvailable 低于阈值才切
    200ms
    快速轮询,恢复后关闭;观察窗口只在快速期采样
  • 后:始终 200ms 快轮(NORMAL_POLL_INTERVAL_MS
    删除),窗口持续采样,紧急借用 + 2s 门控紧急广
    播,窗口最小值超阈值触发主动归还;日志带
    oom_round
  1. 借用粒度:原始字节 → blockSize 取整
  • 前:canMigrate/amount 直接按字节
  • 后:GetUbseBlockSizeBytes() 取
    UbseNodeInfo.blockSize(0 回退
    128MB);canMigrate 向下取整、amount
    向上取整(缺口不足一块也整块迁移,shortage
    允许超减),两处除法加除零保护
  1. 日志可定位性:RmrsMigrateToNumas/BuildMigrat
    eTargets 透传 pid+debtId,迁移/归还约 20
    处日志补 pid、debt_id;ReconcileApplyChanges
    跳过 BORROWING 槽位避免误删借用中债务

  2. root 进程拒绝:错误码 UBSE_ERR_INVALID_ARG →
    UBSE_ERR_ACCESS_DENIED,bridge 返回专属消息

  3. 配置改名:scheduler.node_max_lend_gb →
    node_lending_limit(conf 注释、docs、collector
    同步),conf 注释改英文

  4. UT:新增 ubse_election mock、blockSize
    取整用例(4.625GB 缺口 → 借 4.75GB)、mock
    blockSize=256、清理 11 个失败用例、SetUp 重置
    lastEmergencyBroadcast_ 修状态泄漏

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 2401_87013476 的贡献)
2401_870134762401_87013476
16 天前 创建了 pull request,commit ff76e788
atomgit-bot
atomgit-bot
16 天前 评论:

变更摘要

本 PR 主要调整 process_mem 的内存借用决策口径与 OOM 检测逻辑:在途迁移量由「账本中已下发的迁移量」改为「账本期望远端占用与实际远端 NUMA 占用(采集自 sysfs)的差值」来计算,节点空闲判定由 /proc/meminfoMemAvailable 改为本地 NUMA 空闲总和;OOM 检测移除正常/快速轮询切换,改为常开快速轮询;同时将 root 进程拒绝的错误码细化为 UBSE_ERR_ACCESS_DENIED,把 scheduler.node_max_lend_gb 配置项更名为 scheduler.node_lending_limit,并清理了一批失败的 UT。

主要改动

  • 在途迁移量按远端 NUMA 实际占用计算: GetPendingBorrowTotal 重命名为 GetPendingMigrateTotal,统计借用账本中 BORROWING/COMPLETED 状态的 slot 得到期望远端占用,再减去采集快照中的远端 NUMA 实际已用内存,差值即为 smap 尚未落地的在途迁移量,并据此扣减借入缺口。
  • 新增 NUMA 采集与空闲判定口径切换: process_mem_pid_collect.cpp 新增 CollectNodeFreeMemory,通过 /sys/devices/system/node/node<N>/remote 识别远端 NUMA、读取 meminfoMemFree/MemTotal 生成 localNumaFreeKbSnapshot_/remoteNumaUsedKbSnapshot_ 快照;决策侧 GetNodeFreeBytes 从读取 /proc/meminfoMemAvailableReadMemAvailableKb)改为读取本地 NUMA 空闲总和(ReadLocalNumaFreeKb/ReadRemoteNumaUsedKb)。
  • OOM 检测常开快速轮询: OomPollOnce 移除基于 MemAvailable 阈值的快速/正常轮询切换逻辑及 oomFastPoll_ 状态,每次调用恒定返回 fastPollIntervalMs_(200ms)并持续更新快速窗口采样。
  • root 进程拒绝语义与账本对账保护: ValidateProcMemTarget 对 root 进程返回 UBSE_ERR_ACCESS_DENIED(原为 UBSE_ERR_INVALID_ARG),process_mem_pid_bridge.cpp 增加对应错误提示;ReconcileLedgerWithCache 跳过 BORROWING 状态 slot,避免误删债务尚未创建的借入,交由超时检查兜底。
  • 配置项更名与 UT 清理: scheduler.node_max_lend_gb 更名为 scheduler.node_lending_limit(同步更新 ubse_node_controller_collector.cpp 的读取键与注释),删除一批失败/过时的 UT,新增 ubse_election.cpp mock、CollectNodeFreeMemorySnapshot 用例,并将测试 mock 从 memAvailableReader 迁移到 localNumaFreeKbReader/remoteNumaUsedKbReader
likedislike
atomgit-bot
atomgit-bot
16 天前 评论:

代码审查

✅ 未发现问题

likedislike
openeuler-ci-botopeneuler-ci-bot成员
16 天前 将hlinbo,shw030915,Gao_Victor,qmyyxtl,caowaterman设为审查人
openeuler-ci-botopeneuler-ci-bot成员
16 天前 添加了label:sig/sig-UB-ServiceCore
此处折叠了94条消息 查看更多
openeuler-ci-bot
openeuler-ci-bot成员
15 天前 评论:

Review Code Feedback

  • The label lgtm-wangwenlong7, approved was added to this pull request. It means that wangwenlong7 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
xuchenfeng成员
15 天前 评论:

/lgtm
/approve

likedislike
openeuler-ci-botopeneuler-ci-bot成员
15 天前 添加了label:lgtm-xuchenfengcleancode
openeuler-ci-bot
openeuler-ci-bot成员
15 天前 评论:

Review Code Feedback

  • The label lgtm-xuchenfengcleancode was added to this pull request. It means that xuchenfengcleancode reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openeuler-ci-botopeneuler-ci-bot成员
15 天前 合入了pull request,合并节点 SHA:b2c06f45c3f509b23b3778f78b31ee970e15d8b8