[software development] deepin platform power strategy
poster avatar
Super Moderator
2023-11-30 22:54


Recently, we have received feedback from users that when using the deepin system, they have encountered equipment heating and poor battery life caused by excessive CPU power consumption. However, users often do not use high CPU usage in these load scenarios. In order to solve this pain point, the Open Source Community Center has set up a special plan to optimize deepin's power supply. This article aims to analyze and explain the root cause of this problem.

Before special optimization of the power supply, we first conducted an in-depth investigation and analysis of the deepin system to understand its actual operation under load scenarios. After monitoring the CPU usage and power consumption, we discovered a surprising fact: Although the CPU usage is not high in high-load scenarios, its power consumption continues to increase, eventually causing the device to heat up and affecting battery life. . In other words, the power-saving optimization work we did in the early stage was not only ineffective, but also had a counterproductive effect (the author will explain the specific situation in detail below).



The problem was first discovered in the kernel. Some users compared our kernel with that of Ubuntu and found that although the performance of our system and Ubuntu system are similar, our system lags behind Ubuntu in terms of heat generation and battery life. Some users used the configuration files of ubuntu and other open source Linux distributions to compile the kernel separately on the deepin system, and found that the main problem of deepin lies in heat control. Our testing colleagues attach great importance to this community feedback and reproduce the problems reported by community users, which proves this phenomenon.

Regarding this problem, we immediately contacted our colleagues in the kernel R&D department and invited some community users who have done some research on kernel configuration to participate. After everyone's joint investigation, we found that the HWE kernel provided in deepin v23 had some debug and useless kernel options enabled, and some power-saving functions were not actually enabled. These all led to deepin to a certain extent. The battery life of v23 is not good.


At the system level, I re-examined the power scheduling module provided by dde-daemon, compared it with the file interface provided by the kernel documentation, analyzed the power modes used by our users, and found that there is room for optimization. This will be one of the focuses of this article.

Prerequisite knowledge: ACPI

ACPI is the abbreviation of Advanced Configuration and Power Interface. It is an interface specification for exchanging energy-related information between computer hardware and operating systems. It defines energy-related information of computer hardware, such as power supply status, device power consumption, device power factor, etc. ACPI is a standard for operating systems to control computer hardware energy management, and is also a standard for communication between hardware manufacturers and operating systems.

In the deepin system, ACPI is responsible for handling the energy management of computer hardware. It interacts with the power management module of the deepin system to achieve energy management of computer hardware.

When analyzing system-level problems, we need to understand the roles and functions of ACPI and power management modules, and how they work together. In this article, we will explain in detail the working principle of ACPI and the working mode of the power scheduling module in the deepin system, and propose feasible optimization suggestions.

First, let's understand how ACPI works. When a power change occurs to computer hardware, ACPI collects hardware information and sends a power request to the operating system. After the operating system receives the power request, it will automatically adjust the power policy of each hardware according to the user configuration. The power module of the deepin system helps users generate configurations to adjust ACPI behavior. So in this regard, what we can do is provide ACPI with a reasonable power strategy to reduce device temperature and improve battery life while ensuring performance.

Platform power configuration

Related kernel documentation https://docs.kernel.org/userspace-api/sysfs-platform_profile.html

UEFI ACPI documentation https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/index.html

Platform power configuration is an important part of the power management module. It is used to manage the power status of computer platform hardware (referring to all devices that support ACPI), and the CPU is also part of the ACPI device. However, the CPU is the core heat generator of the computer, and the power management of the platform it uses may be coarse-grained. Therefore, APCI has introduced some performance management methods unique to the CPU, which will be explained in detail in the next section.

The platform power configuration provides three optional modes: performance (performance mode), balance (balance mode), and low-power (energy saving mode). Under normal circumstances, users can just use the balanced mode. Performance mode is provided by default on desktop and mini host devices (which do not have any requirements for power consumption and heat generation), and balanced mode is provided by default on mobile devices such as notebooks. The energy-saving mode is not provided by default because some ACPI devices may "sleep to death" when working in energy-saving mode. Therefore, in order to avoid this problem, the low-power power-saving mode is not provided by default.

CPU power configuration

Traditional power mode (SCalling) kernel documentation https://www.kernel.org/doc/html/v6.1/admin-guide/pm/cpufreq.html

Intel PState kernel documentation https://www.kernel.org/doc/html/v6.1/admin-guide/pm/intel_pstate.html

AMD PState kernel documentation https://docs.kernel.org/admin-guide/pm/amd-pstate.html

In fact, if you have time and study the above power supply documents by yourself, it will be easy to understand the relevant content of CPU power configuration. My description here will ignore a lot of technical details and implementation methods, and just tell you how to adjust the power mode of the CPU.

There are many files named policy (x represents the core number) in the /sys/devices/system/cpu/cpufreq directory. These files correspond to the CPU cores on your computer, and the CPU power scheduling details are in these files. Clip inside. There is a file scaling_driver in the policy directory. Use cat or other methods to access it. The result is the scheduler we are currently using:

intel_cpufreq / acpi_cpufreq: use scaling freq scheduling

intel_pastate: Use Intel Pstate scheduling

amd-pstate: Use AMD Pstate scheduling

scaling freq scheduling

This is the most traditional CPU scheduling method. You can obtain the optional power mode in scaling_available_governors under the policy folder:


You may be curious why there are so many balance modes here. In fact, these balance modes all have the same function: balancing performance and battery life, but the algorithms used may be different. I will not explain in detail here. I found some detailed information on the Internet. For reference, interested friends can check it out by themselves:

oppo kernel team:

schedutil governor scenario analysis: http://www.wowotech.net/process_management/schedutil_governor.html

Linux kernel documentation: schedutil governor: https://www.kernel.org/doc/html/next/translations/zh_CN/scheduler/schedutil.html

Arch wiki: https://wiki.archlinux.org/title/CPU_frequency_scaling

We can change scaling_governors to change the power schedule of this core (note, it can only be changed to the power schedule listed in the scaling_available_governors file, which may be different for different computers)

Intel Pstate

This is a moment exclusive to recent generations of Intel CPUs. After turning on intel pstate in the kernel (the V23 kernel turns it on by default), you will find several more files in the policy folder:

We only need to pay attention to:

energy_performance_available_perference: Available pstate power scheduling

energy_performance_perference: The currently selected pstate power schedule, the content of this file can be changed to change the power schedule

Two new scheduling schemes have appeared in Intel Pstate:

balance_performance: Balance favors performance, usually the working frequency is not high, and it can respond quickly when the load increases.

balance_power: Balanced towards energy saving, power strategy is more conservative

There is also a default plan on some computers. This plan is a balance strategy optimized by pstate.

For the specific black magic used by PState and the scheduling strategies of active mode and passive mode, you can refer to the kernel documentation for analysis.

AMD PState

This is a moment exclusive to AMD ZEN2 and above users, as well as users running kernel 6.4.x. In fact, AMD has already supported PState in the 6.1 kernel, but it is in passive mode.

(Active Mode) Active mode

Active Mode is only available when the kernel version is greater than 6.4 and the kernel option turns on AMD PState. You may need to add startup parameters in grub to turn on this function: amd_pstate=active, or you can modify the file to achieve this

The power strategy of Active Mode is similar to Intel PStatewi

(Passive Mode) Passive Mode

Passive Mode is only available when the kernel is greater than 6.1 and the kernel option turns on AMD PState. You may need to add startup parameters to grub to enable this function: amd_pstate=passive, or you can modify the file to achieve this.

Passive Mode provides two power modes, which can be adjusted in the /sys/device/system/cpu/cpufreq/scaling_governor file:

Performance is configured using platform_profile, which also makes scheduling more proactive.

scheutils adjusts the scheduling granularity (the time between two schedules) in the /sys/device/system/cpu/cpufreq/schedutil/rate_limit_us file, and the ACPI scheutils class /sys/device/system/cpu/cpufreq/scaling_governor

(Guided Mode) boot mode

Guided Mode is only available when the kernel is greater than 6.1 and the kernel option turns on AMD PState. You may need to add startup parameters to grub to enable this function: amd_pstate=guided, or you can modify the file to achieve this.

It's like a car's automatic transmission, where the driver requests minimum and maximum performance levels, and the platform automatically selects the performance level within this range that's appropriate for the current workload.

GPU power management section


If it is amdgpu, you need to change two files (use the tee command to write):

/sys/class/drm/card0/device/power_dpm_state (This is a legacy interface for backward compatibility)

performance high performance mode

balance balance mode

battery energy saving mode


The following settings are from the official AMD driver documentation:

  • auto: When auto is selected, the device will try to dynamically select the best power curve for the current conditions in the drive
  • low: When low is selected, the GPU is forced to the lowest power state.
  • high: When high is selected, the GPU is forced to the highest power state
  • manual: When manual is selected, the user can manually adjust the power state enabled for each clock domain through the sysfs pp_dpm_mclk, pp_dpm_sclk and pp_dpm_pcie files, and adjust the power state transition method through the pp_power_profile_mode sysfs file.
  • profile_standard Fixed clock level analysis mode. This mode sets the clock to a fixed level that varies from ASIC to ASIC. This is useful for analyzing specific workloads (not commonly used)
  • profile_min_sclk Minimum sclk profiling mode. This mode forces sclk to the lowest level. This is useful for analyzing minimal power consumption scenarios (not commonly used)
  • profile_min_mclk Minimum mclk profiling mode. This mode forces mclk to the lowest level. This is useful for analyzing minimal power consumption scenarios (not commonly used)
  • profile_peak peak analysis mode. This mode sets all clocks (mclk, sclk, pcie) to the highest level. This is useful for analyzing maximum performance scenarios. (uncommonly used),

AMD core display AnTuTu verification data

When the mode is set to low, the gpu score is 12144


When the mode is set to auto, the gpu score is 88544


When the mode is set to high, the gpu score is 89575


Intel GPU

The i915 driver used by Intel GPU does not want you to adjust it, because the power policy of the driver is already smart enough. However, you can also adjust and obtain information through intel-gpu-tools provided by Intel.

sudo apt install intel-gpu-tools

and then use

sudo intel_gpu_frequency

to get the current frequency (currently using Intel A750)


You can see that Intel's graphics card driver dynamically adjusts between 600 MHz and 2400 MHz.

The Intel core graphics running scores under the test notebook are as follows:



Nothing to say, go and adjust the driver

he author of this article is developed by deepin Open Source Community Center longlong This article is distributed under CC-BY-NC-SA-4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh


Thanks to the deepin community kernel team. Thanks to the community testing team. Thanks to @fslong and other community users who participated in the v23 kernel endurance test.

Reply Favorite View the author
All Replies
2023-12-01 07:57

Edit: My mistake, i thought this applied to 20.9 aswell

Reply View the author
Super Moderator
Product Manager
2023-12-04 17:29

Hello, don't you know what problem you have with screen zoom right now?

Reply View the author