@@ -26,6 +26,7 @@ const (
2626 globalAvailableGovernorFileName = "scaling_available_governors"
2727 globalBoostFilePath = "/sys/devices/system/cpu/cpufreq/boost"
2828 globalDefaultPath = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
29+ globalDefaultDriverPath = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver"
2930 _isHuaWei = `dmidecode -t 1 | awk "/Product Name:/{print $NF}" | cut -d ":" -f 2`
3031)
3132
@@ -103,13 +104,11 @@ func getIsBalanceSupported(isPstate bool) bool {
103104 }
104105}
105106
106- // TODO: 之后是否需要判断boost 的逻辑需要讨论
107107func getIsHighPerformanceSupported (isPstate bool ) bool {
108- cpus := CpuHandlers {}
109108 if isPstate {
110109 return strv .Strv (getSupportGovernors ()).Contains ("performance" )
111110 }
112- return cpus . IsBoostFileExist () && strv .Strv (getSupportGovernors ()).Contains ("performance" )
111+ return strv .Strv (getSupportGovernors ()).Contains ("performance" )
113112}
114113
115114func getIsPowerSaveSupported (isPstate bool ) bool {
@@ -340,6 +339,22 @@ func (cpus *CpuHandlers) getCpuGovernorPath(isPstate bool) string {
340339 return path
341340}
342341
342+ func cpuHasPstate () bool {
343+ if ! dutils .IsFileExist (globalDefaultDriverPath ) {
344+ return false
345+ }
346+ driverData , err := os .ReadFile (globalDefaultDriverPath )
347+ if err != nil {
348+ return false
349+ }
350+ driver := string (driverData )
351+ return driverHasPstate (driver ) && dutils .IsFileExist (pstateConfPath )
352+ }
353+
354+ func driverHasPstate (driver string ) bool {
355+ return strings .Contains (driver , "pstate" )
356+ }
357+
343358// 通过写文件的返回情况,获取非scaling_available_governors的值是否支持
344359func (cpus * CpuHandlers ) tryWriteGovernor (lines []string , isPstate bool ) []string {
345360 path := cpus .getCpuGovernorPath (isPstate )
0 commit comments