CPU freq and num of cores: Difference between revisions

From Variscite Wiki
No edit summary
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{PageHeader|Set the CPU freq. and number of active cores}}
{{INIT_RELEASE_PARAM|mx8mp-yocto-mickledore-6.1.36_2.1.0-v1.2}}<!--
{{DocImage|category1=Yocto|category2=VAR-SOM-MX6}}[[Category:DART-6UL]] [[Category:VAR-SOM-MX7]]
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{COMMON_YOCTO_VARS}} <!-- Include common yocto variables
--> {{PageHeader|Set the CPU freq. and number of active cores}}
{{DocImage|category1=Yocto|category2=Android}}[[Category:Debian]][[Category:VAR-SOM-MX6]][[Category:DART-6UL]][[Category:VAR-SOM-MX7]][[Category:DART-MX8M]][[Category:DART-MX8M-MINI]][[Category:VAR-SOM-MX8X]][[Category:VAR-SOM-MX8]][[Category:VAR-SOM-MX8M-NANO]][[Category:DART-MX8M-PLUS]]


{{Note|If your motivation is to simulate a weaker SOC model (for example, simulate an i.MX6Solo using an i.MX6Quad),<br>
{{Note|If your motivation is to simulate a weaker SOC model (for example, simulate an i.MX6Solo using an i.MX6Quad),<br>
note that there are a few other differences between some of the i.MX SOC models, like RAM bus width (32bit on the Solo, 64bit on the Quad) and some graphics acceleration features.<br>
note that there are a few other differences between some of the i.MX SOC models, like RAM bus width (32bit on the Solo, 64bit on the Quad) and some graphics acceleration features.<br>
See all the differences in the comparison table here:<br>
See all the differences in the following comparison tables:<br>
http://www.nxp.com/docs/en/brochure/FLYRIMXPRDCMPR.pdf}}
[https://www.nxp.com/docs/en/supporting-information/FLYRIMXPRDCMPR.pdf i.MX6 & i.MX7 SoCs Comparison Chart]<br>
[https://www.variscite.com/wp-content/uploads/2020/11/i.MX8_SoC_Comparion_Chart.pdf i.MX8 SoCs Comparison Chart]
}}


__toc__
{{CPU_freq_and_num_of_cores_body}}
= CPU cores =
There are two ways to disable/enable CPU cores:<br>
<br>
1. Add 'maxcpus=n' (n being the number of cores you wish to activate), to the kernel command line (the bootargs from U-Boot).<br>
E.g. Assuming you are using our latest U-Boot, stop at the U-Boot command line and enter:
=> setenv kernelargs maxcpus=2
<br>
2. To disable/enable cores at kernel runtime:<br>
Disbale core X:<br>
# echo 0 > /sys/devices/system/cpu/cpuX/online
Enable core X:<br>
# echo 1 > /sys/devices/system/cpu/cpuX/online
X being the core number you want to enable/disable, and can range from 1 to the number of actual CPU cores (cpu0 is always enabled).<br>
<br>
To see the active cores, run:<br>
# cat /proc/cpuinfo
 
= CPU frequencies =
'''Governors''':<br>
There are several frequency governors which determine the frequency policy.<br>
The default frequency governor is "ondemand", which sets the CPU frequency depending on the current system load.<br>
To list all available governors:
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
To read about the different governors, see the following page from the Linux documentation:<br>
https://github.com/varigit/linux-imx/blob/imx_4.9.11_1.0.0_ga-var01/Documentation/cpu-freq/governors.txt<br>
<br>
To set the current governor:
# echo GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
(GOVERNOR being one of the available governors)<br>
<br>
'''Useful commands''':<br>
To see the available CPU frequencies:<br>
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
<br>
To see the current CPU frequency:<br>
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
<br>
Common scenarios:<br>
1. Use the default "ondemand" governor and limit the maximum allowed CPU freq. using the following commands:<br>
<br>
To see the current maximum allowed CPU frequency:<br>
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
<br>
To set the maximum allowed CPU frequency:<br>
# echo FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
(FREQ being one of the available CPU frequencies)<br>
<br>
2. Use the "userspace" governor and set the CPU to a specific frequency using the following command:<br>
 
# echo FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
(FREQ being one of the available CPU frequencies)<br>

Latest revision as of 17:44, 16 October 2024

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release mx8mp-yocto-mickledore-6.1.36_2.1.0-v1.2.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release



Set the CPU freq. and number of active cores


If your motivation is to simulate a weaker SOC model (for example, simulate an i.MX6Solo using an i.MX6Quad),

note that there are a few other differences between some of the i.MX SOC models, like RAM bus width (32bit on the Solo, 64bit on the Quad) and some graphics acceleration features.
See all the differences in the following comparison tables:
i.MX6 & i.MX7 SoCs Comparison Chart
i.MX8 SoCs Comparison Chart

CPU cores

There are two ways to disable/enable CPU cores:

1. Add 'maxcpus=n' (n being the number of cores you wish to activate), to the kernel command line (the bootargs from U-Boot).
E.g. Assuming you are using our latest U-Boot, stop at the U-Boot command line and enter:

=> setenv kernelargs maxcpus=2


2. To disable/enable cores at kernel runtime:
Disable core X:

# echo 0 > /sys/devices/system/cpu/cpuX/online

Enable core X:

# echo 1 > /sys/devices/system/cpu/cpuX/online

X being the core number you want to enable/disable, and can range from '1' to '(number of actual CPU cores)-1' (cpu0 is always enabled).

To see the active cores, run:

# cat /proc/cpuinfo

CPU frequencies

Governors:
There are several frequency governors which determine the frequency policy.
The default frequency governor is "ondemand", which sets the CPU frequency depending on the current system load.
(Note: the default governor is selected in the kernel defconfig. You can choose a different default governor using menuconfig before building the kernel - to reach this setting, go to: CPU Power Management -> CPU Frequency scaling -> Default CPUFreq governor)

To list all available governors:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

To read about the different governors, see the following page from the Linux documentation:
https://github.com/varigit/linux-imx/blob/5.4-2.1.x-imx_var01/Documentation/admin-guide/pm/cpufreq.rst

To set the current governor:

# echo GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

(GOVERNOR being one of the available governors)

Useful commands:
To see the available CPU frequencies:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies


To see the current CPU frequency:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq


Common scenarios:
1. Use the default "ondemand" governor and limit the maximum allowed CPU freq. using the following commands:

To see the current maximum allowed CPU frequency:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq


To set the maximum allowed CPU frequency:

# echo FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

(FREQ being one of the available CPU frequencies)

2. Use the "userspace" governor and set the CPU to a specific frequency using the following command:

# echo FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

(FREQ being one of the available CPU frequencies)