warn_reset_hwm() 只在 PermissionDenied 时打印 warning,其他 I/O 错误被静默忽略。
warn_reset_hwm()
PermissionDenied
当 /proc 不可用、容器限制或内核不支持相关接口时,VmHWM 无法重置,但用户不知道,跨 suite 的峰值内存数据可能被污染。
/proc
crates/bench/src/runner.rs:11
对所有 reset_vm_hwm() 错误输出 warning;权限错误可保留专门文案,其他错误输出通用失败原因。
reset_vm_hwm()
commit e945a35
e945a35
runner.rs
AtomicBool
pub
main.rs
can_reset_vm_hwm()
metrics.rs
测试
hwm_warned_flag_prevents_reentry
warn_reset_hwm_does_not_panic
cargo check
cargo test
cargo clippy
No dependencies set.
The note is not visible to the blocked user.
问题
warn_reset_hwm()只在PermissionDenied时打印 warning,其他 I/O 错误被静默忽略。影响
当
/proc不可用、容器限制或内核不支持相关接口时,VmHWM 无法重置,但用户不知道,跨 suite 的峰值内存数据可能被污染。位置
crates/bench/src/runner.rs:11建议
对所有
reset_vm_hwm()错误输出 warning;权限错误可保留专门文案,其他错误输出通用失败原因。修复方案
commit
e945a35变更内容
runner.rs
reset_vm_hwm()错误现在都会输出 warning(不再仅限PermissionDenied)PermissionDenied保留 "Try running as root" 专属提示AtomicBoolwarn-once 机制,7 次 suite 调用只打印 1 次警告warn_reset_hwm()改为pub,供 main.rs 预检共享使用main.rs
can_reset_vm_hwm()(笼统 "no root") 改为调用warn_reset_hwm()metrics.rs
can_reset_vm_hwm()死代码测试
hwm_warned_flag_prevents_reentry— 验证 flag 去重逻辑warn_reset_hwm_does_not_panic— 验证多次调用安全性验证
cargo check✅cargo test(53 tests) ✅cargo clippy无新增 warning ✅