From 4059a297a6d95ce94f3619eac0536fda666d58f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=9B=E9=9C=B2=E5=85=88=E7=94=9F?= Date: Tue, 1 Apr 2025 08:07:42 +0800 Subject: [PATCH] discover: /proc/cpuinfo file open and close. (#9950) Signed-off-by: zhanluxianshen --- discover/gpu_linux.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/discover/gpu_linux.go b/discover/gpu_linux.go index d636a54ed..44c53b440 100644 --- a/discover/gpu_linux.go +++ b/discover/gpu_linux.go @@ -111,6 +111,7 @@ func GetCPUDetails() ([]CPU, error) { if err != nil { return nil, err } + defer file.Close() return linuxCPUDetails(file) } @@ -168,13 +169,11 @@ func linuxCPUDetails(file io.Reader) ([]CPU, error) { for id, s := range socketByID { s.CoreCount = len(coreBySocket[id]) s.ThreadCount = 0 - for _, tc := range threadsByCoreBySocket[id] { - s.ThreadCount += tc - } // This only works if HT is enabled, consider a more reliable model, maybe cache size comparisons? efficiencyCoreCount := 0 for _, threads := range threadsByCoreBySocket[id] { + s.ThreadCount += threads if threads == 1 { efficiencyCoreCount++ }