kali20gakki/msAgent / skills/host-cpu/msagent-perf-cpu-config-audit
msagent-perf-cpu-config-audit
Verified昇腾训练/推理主机的环境配置体检:对 NUMA 亲和、大页/THP、governor 频率、cgroup 限流、IRQ smp_affinity、环境变量等 8 个配置域做单点快照审计,输出分级 Finding 与可回滚修改建议,不改动运行状态。触发:检查环境、配置体检、新机器开箱、换容器、 大页没配、governor 不对、cgroup 限流、中断亲和配置、NUMA 配置检查、绑核没生效。 不用于:训练变慢/step 抖动/利用率低的根因归因(→ perf-cpu-perf-triage); 产出绑核方案(→ perf-cpu-bind-tune);运行期实际落核观测(→ perf-cpu-tracing)。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.2 KB |
| references/check-items.md | markdown | 6.5 KB |
| references/process-roles.md | markdown | 1.7 KB |
| references/profiles/ascend910.json | config | 1.6 KB |
| references/profiles/kunpeng920-910b.json | config | 507 B |
| references/rules-locality.md | markdown | 2.3 KB |
| resources/report_template.html | other | 11.5 KB |
| scripts/audit.py | script | 19.6 KB |
| scripts/baseline.py | script | 4.4 KB |
| scripts/checker.py | script | 39.6 KB |
| scripts/classify.py | script | 2.7 KB |
| scripts/discover.py | script | 6.6 KB |
| scripts/npu_query.py | script | 15.0 KB |
| scripts/preflight.py | script | 3.3 KB |
| scripts/procfs.py | script | 9.0 KB |
| scripts/report.py | script | 6.4 KB |
| scripts/rules_locality.py | script | 8.7 KB |
| scripts/static_collect.py | script | 13.8 KB |
| scripts/topology.py | script | 9.4 KB |
| scripts/workspace.py | script | 2.1 KB |
scripts/preflight.py
View on GitHub# -------------------------------------------------------------------------
# This file is part of the MindStudio project.
# Copyright (c) 2026 Huawei Technologies Co.,Ltd.
#
# MindStudio is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# -------------------------------------------------------------------------
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""preflight.py — 权限/容器/工具探测(决定配置侧/现状侧可判性与 view_limited)。"""
from __future__ import annotations
import os
import shutil
from typing import Any, Dict
# 依赖工具可用性由调用方降级(check-items 中声明的等价 /proc、/sys 路径)
_OPTIONAL_TOOLS = ("numactl", "cpupower", "irqbalance", "taskset", "ethtool", "sensors")
def _is_container() -> bool:
"""容器判定:dockerenv/containerenv 标记 + cgroup v1/v2 路径标记。
cgroup v2 下 /proc/1/cgroup 常退化为 "0::/",故同时检查 /proc/self/cgroup,
并补 podman/libpod 标记,避免 v2 容器漏判导致 view_limited 误报 False。
"""
if os.path.exists("/.dockerenv") or os.path.exists("/run/.containerenv"):
return True
markers = ("docker", "kubepods", "containerd", "lxc", "libpod", "podman")
for path in ("/proc/1/cgroup", "/proc/self/cgroup"):
try:
with open(path, "r", encoding="utf-8", errors="replace") as fh:
content = fh.read(65536)
except OSError:
continue
if any(marker in content for marker in markers):
return True
return False
def _cgroup_version() -> str:
"""判定 cgroup v1/v2(v2 以 /sys/fs/cgroup/cgroup.controllers 存在为准)。"""
if os.path.isfile("/sys/fs/cgroup/cgroup.controllers"):
return "v2"
return "v1"
def _cgroup_writable() -> bool:
return os.access("/sys/fs/cgroup", os.W_OK)
def _topology_visible() -> bool:
return os.path.isdir("/sys/devices/system/node")
def _capabilities() -> list:
"""尽力读取 CapEff(/proc/self/status)。"""
try:
with open("/proc/self/status", "r", encoding="utf-8", errors="replace") as fh:
for line in fh.read(65536).splitlines():
if line.startswith("CapEff:"):
return [line.split(":", 1)[1].strip()]
except OSError:
pass
return []
def _optional_tools() -> Dict[str, bool]:
return {tool: shutil.which(tool) is not None for tool in _OPTIONAL_TOOLS}
def run() -> Dict[str, Any]:
"""preflight 探测结果(写入报告元信息)。"""
in_container = _is_container()
topology_visible = _topology_visible()
return {
"in_container": in_container,
"cgroup_ver": _cgroup_version(),
"cgroup_writable": _cgroup_writable(),
"topology_visible": topology_visible,
"caps": _capabilities(),
"optional_tools": _optional_tools(),
"view_limited": in_container or not topology_visible,
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |