Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture transparent hugepages config in health report #258

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ func GetSysConfig(_ context.Context, addr string) SysConfig {
sc.Config["xfs-error-config"] = xfsErrorConfigs
}

sc.Config["thp-config"] = getTHPConfigs()

return sc
}

Expand All @@ -487,6 +489,24 @@ func readIntFromFile(filePath string) (num int, err error) {
return strconv.Atoi(strings.TrimSpace(string(data)))
}

func getTHPConfigs() map[string]string {
configs := map[string]string{}
captureTHPConfig(configs, "/sys/kernel/mm/transparent_hugepage/enabled", "enabled")
captureTHPConfig(configs, "/sys/kernel/mm/transparent_hugepage/defrag", "defrag")
captureTHPConfig(configs, "/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none", "max_ptes_none")
return configs
}

func captureTHPConfig(configs map[string]string, filePath string, cfgName string) {
errFieldName := "cfgName" + "_error"
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
data, err := os.ReadFile(filePath)
if err != nil {
configs[errFieldName] = err.Error()
return
}
configs[cfgName] = strings.TrimSpace(string(data))
}

func getXFSErrorMaxRetries() XFSErrorConfigs {
xfsErrCfgPattern := "/sys/fs/xfs/*/error/metadata/*/max_retries"
configFiles, err := filepath.Glob(xfsErrCfgPattern)
Expand Down
Loading