配置 ThermalD
ThermalD 是一个 Linux 守护进程,通过持续监控温度传感器并使用可用的冷却机制应用热缓解,帮助防止平台过热。它作为一个智能热管理系统,在硬件需要采取激进的纠正措施之前,主动维持安全的工作温度。 ThermalD 使用数字温度传感器监控 CPU 和整个系统的温度,并通过采用多种冷却策略来实施热控制,例如:- CPU 频率调节
- 功率限制
- 风扇控制
/sys/class/thermal)集成,并使用基于 XML 的配置文件扩展或覆盖内核热管理策略。它既支持通过 ACPI 热关系表进行自动配置,也支持手动配置以启用自定义热管理策略。
以下是 ThermalD 的 XML 结构概览:
<?xml version="1.0"?>
<ThermalConfiguration>
<Platform>
<Name>Platform Name</Name>
<ProductName>Product Name or *</ProductName>
<UUID>Optional UUID</UUID>
<Preference>QUIET|PERFORMANCE</Preference>
<ThermalSensors>
<!-- Sensor definitions -->
</ThermalSensors>
<ThermalZones>
<!-- Zone and trip point definitions -->
</ThermalZones>
<CoolingDevices>
<!-- Cooling device configurations -->
</CoolingDevices>
</Platform>
</ThermalConfiguration>
向 ThermalD 推送自定义规则
ThermalD 使用配置文件/etc/thermald/thermal-conf.xml 进行手动配置。
以下示例展示了如何使用 XML 配置文件手动配置 ThermalD 来管理 GPU 和 CPU 热区:
- 该配置指定了三个热传感器,一个用于 GPU,两个用于不同的 CPU 集群,每个传感器都与被动冷却触发点关联。GPU 热区在 35 °C 时触发,而 CPU 集群热区分别在 40 °C 和 45 °C 时激活。
- 所有热区都使用 CPU 或 GPU 频率调节作为冷却机制,采样间隔为 100 ms,并采用 5 °C 的迟滞以防止热振荡。冷却设备配置了定义的状态范围并启用了自动降档控制,从而实现渐进且可控的温度降低。
<ThermalConfiguration>
<Platform>
<Name>*</Name>
<UUID>*</UUID>
<ProductName>*</ProductName>
<Preference>QUIET</Preference>
<!-- 100ms polling interval -->
<PollingInterval>5</PollingInterval>
<ThermalSensors>
<ThermalSensor>
<Type>gpuss-0-thermal</Type>
<AsyncCapable>0</AsyncCapable>
</ThermalSensor>
</ThermalSensors>
<ThermalSensors>
<ThermalSensor>
<Type>cpu-0-0-0-thermal</Type>
<AsyncCapable>0</AsyncCapable>
</ThermalSensor>
</ThermalSensors>
<ThermalSensors>
<ThermalSensor>
<Type>cpu-1-1-1-thermal</Type>
<AsyncCapable>0</AsyncCapable>
</ThermalSensor>
</ThermalSensors>
<ThermalZones>
<ThermalZone>
<Type>gpuss-0-thermal</Type>
<TripPoints>
<TripPoint>
<SensorType>gpuss-0-thermal</SensorType>
<Temperature>35000</Temperature>
<Hysteresis>5000</Hysteresis>
<Hyst>5000</Hyst>
<type>passive</type>
<ControlType>SEQUENTIAL</ControlType>
<CoolingDevice>
<index>0</index>
<type>devfreq-3d00000.gpu</type>
<influence>5000</influence>
<SamplingPeriod>5</SamplingPeriod> <!-- 100ms sampling -->
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>cpu-0-0-0-thermal</Type>
<TripPoints>
<TripPoint>
<SensorType>cpu-0-0-0-thermal</SensorType>
<Temperature>40000</Temperature> <!-- 75°C threshold -->
<Hysteresis>5000</Hysteresis>
<Hyst>5000</Hyst>
<type>passive</type>
<ControlType>SEQUENTIAL</ControlType>
<CoolingDevice>
<index>0</index>
<type>cpufreq-cpu0</type>
<influence>5000</influence>
<SamplingPeriod>5</SamplingPeriod> <!-- 100ms sampling -->
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>cpu-1-1-1-thermal</Type>
<TripPoints>
<TripPoint>
<SensorType>cpu-1-1-1-thermal</SensorType>
<Temperature>45000</Temperature> <!-- 75°C threshold -->
<Hysteresis>5000</Hysteresis>
<Hyst>5000</Hyst>
<type>passive</type>
<ControlType>SEQUENTIAL</ControlType>
<CoolingDevice>
<index>0</index>
<type>cpufreq-cpu4</type>
<influence>5000</influence>
<SamplingPeriod>5</SamplingPeriod> <!-- 100ms sampling -->
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
<CoolingDevices>
<CoolingDevice>
<Index>0</Index>
<Type>devfreq-3d00000.gpu</Type>
<SysfsPath>/sys/class/thermal/cooling_device2</SysfsPath>
<MinState>0</MinState>
<MaxState>3</MaxState>
<IncDecStep>1</IncDecStep>
<ReadBack>1</ReadBack>
<AutoDownControl>1</AutoDownControl>
<TargetState>1</TargetState>
</CoolingDevice>
<CoolingDevice>
<Index>0</Index>
<Type>cpufreq-cpu0</Type>
<SysfsPath>/sys/class/thermal/cooling_device0</SysfsPath>
<MinState>0</MinState>
<MaxState>13</MaxState>
<IncDecStep>1</IncDecStep>
<ReadBack>1</ReadBack>
<AutoDownControl>1</AutoDownControl>
<TargetState>1</TargetState>
</CoolingDevice>
<CoolingDevice>
<Index>0</Index>
<Type>cpufreq-cpu4</Type>
<SysfsPath>/sys/class/thermal/cooling_device1</SysfsPath>
<MinState>0</MinState>
<MaxState>13</MaxState>
<IncDecStep>1</IncDecStep>
<ReadBack>1</ReadBack>
<AutoDownControl>1</AutoDownControl>
<TargetState>1</TargetState>
</CoolingDevice>
</CoolingDevices>
</Platform>
</ThermalConfiguration>
注意 更多信息请参阅 Thermal Daemon。

