Linux power Management (1) _ Overall architecture (transfer from
www.wowotech.net, Snail's Nest technology)1. Preface
In this world, the operation of any system requires energy. If a tree relies on light to grow, as a horse relies on food to run, as a computer system relies on electricity. and energy acquisition is a cost, so if the system can be guaranteed to operate on the basis of minimizing energy consumption, it will greatly improve the survival of the system's competitiveness. In this regard, nature has done very well, such as the leaves of plants, such as the hibernation of animals, and so on. In the world of computers (here, for example, an embedded system running Linux OS), it is called Power Management (Management).
Popularly speaking, power management is: "Want to let the horse run, do not want to eat grass horse." However, from the angle of energy conservation, want to let the horse run how fast, run for how long, must let it eat the corresponding amount of grass. Then we go back to the second: "Only when the horse needs to run, let it eat grass." This is the core idea of power management. What about the method? Can do this:
Method 1: Don't need a horse to run, kill it, so you don't eat grass. If you need a horse to run, raise one more.
In the real world, there should be no one to use this method except fools. Because it takes time to re-raise a horse----where I can wait, there's a need for grass----probably more than a horse to keep.
Method 2: Do not need to run the horse, let it sleep, can not open eyes, can not move, can not be called.
If the horse is willing to sleep, this method can only reduce the number of horses grazing, because its heart is still beating, the blood is still circulating, which also consumes energy. But fortunately, the need for horses to run, should not have to wait too long.
Method 3: Does it mean that the heart beats and blood flow also consumes energy? Well, then stop it, and you can save as much as you want.
Really is a good way, not much to ask the vet first, can be done. But with the current medical level, the estimate can not be achieved AH.
In the computer world, the methods above are normal, and the control is much finer than that. Because the computer is designed by man, but the horse is by the hand of God. But through the example of the horse, we can summarize the basic behavior of power management:
A, a real-time shutdown of temporarily unused portions (which can be referred to as "working state to non-working state transfer"). For example, when the phone is in the pocket, the screen does not need to light.
b, when you need to reuse those closed sections (which can be referred to as "non-working state to work"), there can be no long waits, and the transfer process does not consume too much energy. The above Method 1 is a negative case, but in the computer world, the situation will be much better.
2. Components of Linux power management
Power Management is a large subsystem in the Linux kernel, involving power (power supply), charging (Charger), clock, frequency (Frequency), (Voltage), Sleep/Wake (Suspend/resume) and many other aspects (such as), the scroll will be described in the Linux Power Management series one by one.
Note 1: The picture is just one, and does not divide the software hierarchy, so the relationship between modules is not necessarily a real relationship.
Before you make a detailed description of these components (also called the framework) in the picture, here's a basic idea.
Note 2:framework is a middle-tier software that provides a framework for software development. There are three: one is to block specific implementation details, fixed on the interface, so as to facilitate the development and maintenance of the upper layer of software, and the second is to abstract public logic as much as possible, and implemented within the framework to improve reusability and reduce development; The third is to provide a series of callback functions to the lower level (callback function), the underlying software may face a large difference in reality, but as long as these callbacks are populated, all logic can be completed, reducing the difficulty of development.
- Power supply is a class for the user-space program to monitor the system's power supply status (battery powered, USB powered, AC powered, and so on). In layman's words, it is a battery&charger-driven framework
- Clock Framework,clock-driven Framework for unified management of the system's clocking resources
- Regulator Framework,voltage/current regulator-driven Framework. The driver is used to adjust the voltage and current values of modules such as CPUs
- Dynamic Tick/clock Event, in the traditional Linux kernel, the system tick is a fixed period (such as 10ms), so every tick will result in a timer interrupt. This wakes up the CPU in the idle or sleep state, and many times this wakeup is meaningless. Therefore, the new kernel the concept of dynamic tick, tick is no longer periodic, but based on the situation of the timer in the system, irregular generation, which can reduce a lot of useless timer interrupt
- CPU idle, the framework for controlling the idle state of the CPU
- Generic PM, Power Management in the traditional sense, such as power Off, Suspend to RAM, Suspend to Disk, hibernate, etc.
- Runtime PM and Wakelock, runtime Power Management, no longer require user program interference, unified scheduling by kernel, real-time shutdown or opening of the device in order to find the best balance between usage performance and power saving performance
Note 3:runtime pm is the Linux kernel Biological runtime power management mechanism, Wakelock is the mechanism proposed by Android. The purpose of these two mechanisms is the same, so only one can be supported. In addition, because the wakelock mechanism is too wild to be despised by the Linux community, we do not have too much of a description of the mechanism.
- CPU Freq/device Freq, the framework for CPU and Device frequency tuning
- OPP (Operating Performance point) is a combination of voltages and frequencies that enable SoCs or devices to work properly. The kernel provides this layer to filter out some relatively fixed combinations in a multitude of voltage and frequency combinations, making things easier.
- PM QoS, the so-called PM QoS, refers to the system in the specified operating state (different voltage, frequency, switching between different modes, etc.) of the quality of work, including latency, timeout, throughput three parameters, the units are us, US and kb/s. Through QoS parameters, the performance of the system can be analyzed and improved.
3. Source code kernel related to power management in the
In the Linux 3.10.29 Kernel of the volute, the source code related to power management is located at:
- kernel/power/*
- drivers/power/
- drivers/base/power/*
- drivers/cpuidle/*
- drivers/cpufreq/*
- drivers/devfreq/*
- Include/linux/power_supply.h
- Include/linux/cpuidle.h
- Include/linux/cpufreq.h
- Include/linux/cpu_pm.h
- Include/linux/device.h
- Include/linux/pm.h
- INCLUDE/LINUX/PM Domain.h
- INCLUDE/LINUX/PM runtime.h
- INCLUDE/LINUX/PM Wakeup.h
- Include/linux/suspend.h
- Documentation/power/*.txt
Linux power Management (1) _ Overall architecture (transferred from the Snail Nest Technology, www.wowotech.net)