// 此模板仅供参考,如果不适用可以修改
问题描述
如果BMC OS发生system deadlock或kernel panic,watchdog开始计时:
在boot阶段,watchdog timeout为10分钟;
在runtime阶段,watchdog timeout为2分钟;
timeout动作为reset full BMC chip。
请问watchdog怎么定制?
// 此模板仅供参考,如果不适用可以修改
如果BMC OS发生system deadlock或kernel panic,watchdog开始计时:
在boot阶段,watchdog timeout为10分钟;
在runtime阶段,watchdog timeout为2分钟;
timeout动作为reset full BMC chip。
请问watchdog怎么定制?
答案内容由AI生成,仅供参考:
根据您的需求,若需定制BMC OS的watchdog行为(在system deadlock或kernel panic时触发,并在不同阶段设置不同超时时间,最终执行全芯片复位),以下是详细的定制方案。
您提出的需求包含以下关键点:
system deadlock或kernel panic。reset full BMC chip(即硬件级复位)。该机制本质上是利用BMC OS Watchdog(也称OS看门狗)实现对操作系统的健康监测,并在异常时执行强制恢复。
来自知识库支持:
- 实体
BMC OS Watchdog描述:“BMC OS Watchdog is a hardware or firmware-based mechanism designed to monitor the operating system for responsiveness and trigger a reset if the OS fails to respond.”- 关系
BMC OS Watchdog → Hard Reset:“If the BMC OS Watchdog is not fed by the OS, it results in a Hard Reset to recover the system.”
通过标准IPMI命令 Set Watchdog Timer 进行配置,可灵活设置不同阶段的行为。
ipmitool raw 0x06 0x24 [byte1] [byte2] [byte3] [byte4] [byte5] [byte6]
| 字节 | 含义 | 推荐值(本例) |
|---|---|---|
| 1 | Timer Use | 0x03 (OS Load) |
| 2 | Timer Actions | 0x01 → Bit[2:0]=001b = Hard Reset |
| 3 | Pre-timeout interval (seconds) | 0(无预警) |
| 4 | Timer flags clear | 0x08(清除OS Load标志) |
| 5 | Initial countdown value (lsbyte, 100ms/count) | 根据阶段设定 |
| 6 | Initial countdown value (msbyte) | 根据阶段设定 |
| 阶段 | Timeout | 初始值计算 | 命令示例 |
|---|---|---|---|
| Boot阶段 | 10 min = 600s | 600s / 0.1s = 6000 → 0x1770 → LSB=0x70, MSB=0x17 | ipmitool raw 0x06 0x24 0x03 0x01 0x00 0x08 0x70 0x17 |
| Runtime阶段 | 2 min = 120s | 120s / 0.1s = 1200 → 0x4B0 → LSB=0xB0, MSB=0x04 | ipmitool raw 0x06 0x24 0x03 0x01 0x00 0x08 0xB0 0x04 |
建议策略:
- 在系统启动完成后,由初始化脚本自动切换至Runtime配置。
- 可通过内核模块或守护进程(如
watchdog服务)动态调整。
虽然不能动态调整timeout值,但可通过BIOS开启OS Watchdog功能。
BMC Configuration →
OS Watchdog → <Enable>
OS Watchdog Timeout Time → [5] (单位:分钟)
注意:BIOS设置通常为静态值(如5分钟),无法满足您分阶段定制的需求,建议结合IPMI方式使用。
在BMC OS侧部署标准 watchdog 守护进程,实现精准控制。
sudo yum install watchdog
# 或
sudo apt install watchdog
/etc/modules 或 /etc/modprobe.d/ipmi.conf:ipmi_devintf
ipmi_si
ipmi_watchdog
/etc/watchdog.confwatchdog-device = /dev/watchdog
watchdog-timeout = 120 # Runtime阶段:2分钟
realtime = yes
priority = 1
interface = ipmi # 使用IPMI接口通信
# 可选监控项
max-load-1 = 24
memory-margin = 64
sudo systemctl enable watchdog
sudo systemctl start watchdog
动态切换机制建议:
- 编写启动脚本,在系统初始化后期重新发送IPMI命令设置为
120秒。- 使用udev规则或systemd service检测系统状态,动态调用
ipmitool mc watchdog set。
ipmitool mc watchdog get
预期输出(示例):
Timer Running: yes
Timeout Action: Hard Reset
The OS is forcibly reset due to the watchdog(OS Load) timeout. 记录。/var/log/watchdog.logipmitool mc watchdog reset
| 项目 | 说明 |
|---|---|
| 复位类型 | reset full BMC chip 实际等同于 Hard Reset,即断电再通电或通过复位信号重置整个芯片。 |
| 超时精度 | IPMI watchdog 以100ms为单位计时,设置值需换算为100ms的倍数。 |
| 独立运行 | watchdog在BMC中独立运行,即使OS卡死仍能生效。 |
| 固件依赖 | 需确保BMC固件支持IPMI v1.5及以上版本,并启用了OS Load timer use模式。 |
| 需求 | 是否可实现 | 实现方式 |
|---|---|---|
| Boot阶段 timeout 10分钟 | 使用 ipmitool raw 0x06 0x24 ... 配置600秒 |
|
| Runtime阶段 timeout 2分钟 | 系统启动后用脚本更改timeout为120秒 | |
| timeout动作为reset full BMC chip | 设置Timer Action为Hard Reset即可 |
|
| 响应system deadlock/kernel panic | 由watchdog自动检测,无需OS参与 |
推荐最终方案:
结合 IPMI命令初始化 + Linux watchdog服务 + 启动后动态切换机制,实现全生命周期、分阶段精准控制。
如有进一步需求(如结合 maca 服务进行监控回调),可扩展脚本集成至BMC启动流程。
相关链接:
当前BMC管理芯片的看门狗超时间尚不支持定制,固定为150s超时
有定制诉求,可以通过社区sig组提交需求,开放定制能力
定制的话涉及到哪个闭源组件,组件名叫什么?
openubmc的看门狗是由maca组件进行管理,但具体的超时时间是由sdk定义的。