Skip to content

Commit

Permalink
Capture transparent hugepages config in health report (#258)
Browse files Browse the repository at this point in the history
Add a new node `thp-config` under `sys -> config` and inside it add
values from the following config files:

/sys/kernel/mm/transparent_hugepage/enabled
/sys/kernel/mm/transparent_hugepage/defrag
/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none

ref: https://tip.golang.org/doc/gc-guide#Linux_transparent_huge_pages
  • Loading branch information
anjalshireesh authored Jan 19, 2024
1 parent c0303b5 commit a99e528
Showing 1 changed file with 20 additions and 0 deletions.
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"
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

0 comments on commit a99e528

Please sign in to comment.