General description of the CPUFreq core and CPUFreq notifiers

Originally, it is a part of the Linux Kernel source code, so it will be treated as GPLv2 (recognition that it should be).

https://www.kernel.org/doc/html/latest/index.html

Licensing documentation

The following describes the license of the Linux kernel source code (GPLv2), how to properly mark the license of individual files in the source tree, as well as links to the full license text.

https://www.kernel.org/doc/html/latest/process/license-rules.html#kernel-licensing

https://www.kernel.org/doc/html/latest/cpu-freq/core.html I will read.


General description of the CPUFreq core and CPUFreq notifiers

Authors:  Dominik Brodowski [email protected]  David Kimdon [email protected]  Rafael J. Wysocki [email protected]  Viresh Kumar [email protected]

  1. General Information

The CPUFreq core code is located in drivers/cpufreq/cpufreq.c. This cpufreq code offers a standardized interface for the CPUFreq architecture drivers (those pieces of code that do actual frequency transitions), as well as to “notifiers”. These are device drivers or other part of the kernel that need to be informed of policy changes (ex. thermal modules like ACPI) or of all frequency changes (ex. timing code) or even need to force certain speed limits (like LCD drivers on ARM architecture). Additionally, the kernel “constant” loops_per_jiffy is updated on frequency changes here.

The CPUFreq core code is located in derivers / cpufreq / cpufreq.c. This CPUFreq core code provides a standard interface to CPUFreq architecture drivers. (Part of the code performs frequency changes) Also includes "notifiers" as well. Depending on the device driver or part of the kernel, policy changes (eg thermal modules like ACPI), all frequency changes (timing code etc.) or certain speed limit enforcement (eg in ARM architecture) LCD driver) is required. Furthermore, the kernel constant "loops_per_jiffy" is updated at the frequency change timing.

Reference counting of the cpufreq policies is done by cpufreq_cpu_get and cpufreq_cpu_put, which make sure that the cpufreq driver is correctly registered with the core, and will not be unloaded until cpufreq_put_cpu is called. That also ensures that the respective cpufreq policy doesn’t get freed while being used.

Reference counters for cpufreq policies are implemented by cpufreq_cpu_get () and cpufreq_cpu_put (). This will cause the cpufreq driver to be properly registered with the core and will not be unloaded until cpufreq_put_cpu () is called. This ensures that each cpufreq policy is not released during use.

  1. CPUFreq notifiers

CPUFreq notifiers conform to the standard kernel notifier interface. See linux/include/linux/notifier.h for details on notifiers.

CPUFreq notifiers follow the standard kernel notifier interface. For more information on notifiers, see linux / include / linux / notifier.h.

There are two different CPUFreq notifiers - policy notifiers and transition notifiers.

There are two different CPU Freq notifiers. One is policy notifiers and the other is transition notifiers.

2.1 CPUFreq policy notifiers

These are notified when a new policy is created or removed. There is a notify when a new policy is created or deleted.

The phase is specified in the second argument to the notifier. The phase is CPUFREQ_CREATE_POLICY when the policy is first created and it is CPUFREQ_REMOVE_POLICY when the policy is removed.

This phase is shown in the second argument to the notifier. This phase is CPUFREQ_CREATE_POLCY when the policy was first created. And CPUFREQ_REMOVE_POLICY when the policy is deleted.

The third argument, a void *pointer, points to a struct cpufreq_policy consisting of several values, including min, max (the lower and upper frequencies (in kHz) of the new policy).

The third argument is of type void * pointer. This is a pointer to the cpufreq_policy structure, which consists of several values, including the min, max frequencies (in kHz) of the new policy.

2.2 CPUFreq transition notifiers

These are notified twice for each online CPU in the policy, when the CPUfreq driver switches the CPU core frequency and this change has no any external implications.

In policy, it may notify again for each online CPU. This is because the CPU Freq driver switches CPU core freency and this change has no external impact.

The second argument specifies the phase - CPUFREQ_PRECHANGE or CPUFREQ_POSTCHANGE.

The second argument indicates the phase. CPUFREQ_PRECHANGE or CPUFREQ_POSTCHANGE.

The third argument is a struct cpufreq_freqs with the following values:

The third argument is a cpufreq_freqs structure that contains the following values:

cpu	number of the affected CPU
old	old frequency
new	new frequency
flags	flags of the cpufreq driver
  1. CPUFreq Table Generation with Operating Performance Point (OPP)

For details about OPP, see Documentation/power/opp.rst

See Documentation / power / opp.rst for more information on OPP.

dev_pm_opp_init_cpufreq_table -

This function provides a ready to use conversion routine to translate the OPP layer’s internal information about the available frequencies into a format readily providable to cpufreq.

This function makes available a conversion routine that converts the internal information of the OPP layers about the currently enabled frequencies into a format that cpufreq can decipher.

Warning Do not use this function in interrupt context.

Do not use this function in the interrupt context.

Example

soc_pm_init()
{
       /* Do things */
       r = dev_pm_opp_init_cpufreq_table(dev, &freq_table);
       if (!r)
               policy->freq_table = freq_table;
       /* Do other things */
}

Note This function is available only if CONFIG_CPU_FREQ is enabled in addition to CONFIG_PM_OPP.

This function is valid only when CONFIG_CPUFREQ is enabled and CONFIG_PM_OPP is also added.

dev_pm_opp_free_cpufreq_table

Free up the table allocated by dev_pm_opp_init_cpufreq_table

Release the table allocated by dev_pm_opp_init_cpufreq_table.

Recommended Posts

General description of the CPUFreq core and CPUFreq notifiers
Consider the description of Dockerfile (Django + MySQL②)
This and that of the inclusion notation.
Script to change the description of fasta
Review the concept and terminology of regression
Comparison of class inheritance and constructor description
Find the general terms of the Tribonacci sequence with linear algebra and Python
The story of trying deep3d and losing
Consider the description of docker-compose.yml (Django + MySQL ③)
Summary of the differences between PHP and Python
Full understanding of the concepts of Bellman-Ford and Dijkstra
The answer of "1/2" is different between python2 and 3
Organize the meaning of methods, classes and objects
Specifying the range of ruby and python arrays
Change the color of Fabric errors and warnings
Compare the speed of Python append and map
Organize the super-basic usage of Autotools and pkg-config
I read and implemented the Variants of UKR
About the * (asterisk) argument of python (and itertools.starmap)
A discussion of the strengths and weaknesses of Python
The nice and regrettable parts of Cloud Datalab
Consideration of the difference between ROC curve and PR curve
Get the title of yahoo news and analyze sentiment
The story of Python without increment and decrement operators.
Automatically determine and process the encoding of the text file
relation of the Fibonacci number series and the Golden ratio
The process of installing Atom and getting Python running
Python --Explanation and usage summary of the top 24 packages
Visualize the range of interpolation and extrapolation with python
[FSL] Measurement of segment and volume of the basal ganglia
Referencing and changing the upper bound of Python recursion
I checked out the versions of Blender and Python
I checked the default OS and shell of docker-machine
Visualization of the connection between malware and the callback server
[Django 2.2] Sort and get the value of the relation destination
Personal notes about the integration of vscode and anaconda
Check the type and version of your Linux distribution
Animate the basics of dynamic programming and the knapsack problem